Annotation of Net2/arch/hp300/stand/dcm.c, revision 1.1.1.2

1.1       root        1: /*
                      2:  * Copyright (c) 1988 University of Utah.
                      3:  * Copyright (c) 1990 The Regents of the University of California.
                      4:  * All rights reserved.
                      5:  *
                      6:  * This code is derived from software contributed to Berkeley by
                      7:  * the Systems Programming Group of the University of Utah Computer
                      8:  * Science Department.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *     This product includes software developed by the University of
                     21:  *     California, Berkeley and its contributors.
                     22:  * 4. Neither the name of the University nor the names of its contributors
                     23:  *    may be used to endorse or promote products derived from this software
                     24:  *    without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     28:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     29:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     30:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     31:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     32:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     33:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     34:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     35:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     36:  * SUCH DAMAGE.
                     37:  *
1.1.1.2 ! root       38:  *     from: @(#)dcm.c 7.3 (Berkeley) 5/7/91
        !            39:  *     dcm.c,v 1.2 1993/05/22 07:58:52 cgd Exp
1.1       root       40:  */
                     41: 
                     42: #ifdef DCMCONSOLE
                     43: #include "sys/param.h"
                     44: #include "../hp300/cons.h"
                     45: #include "../dev/device.h"
                     46: #include "../dev/dcmreg.h"
                     47: 
                     48: struct dcmdevice *dcmcnaddr = NULL;
                     49: 
                     50: dcmprobe(cp)
                     51:        struct consdev *cp;
                     52: {
                     53:        extern struct hp_hw sc_table[];
                     54:        register struct hp_hw *hw;
                     55:        register struct dcmdevice *dcm;
                     56: 
                     57:        for (hw = sc_table; hw < &sc_table[MAXCTLRS]; hw++)
                     58:                if (HW_ISDEV(hw, D_COMMDCM) && !badaddr((caddr_t)hw->hw_kva))
                     59:                        break;
                     60:        if (!HW_ISDEV(hw, D_COMMDCM)) {
                     61:                cp->cn_pri = CN_DEAD;
                     62:                return;
                     63:        }
                     64:        dcmcnaddr = (struct dcmdevice *) hw->hw_kva;
                     65: 
                     66:        dcm = dcmcnaddr;
                     67:        switch (dcm->dcm_rsid) {
                     68:        case DCMID:
                     69:                cp->cn_pri = CN_NORMAL;
                     70:                break;
                     71:        case DCMID|DCMCON:
                     72:                cp->cn_pri = CN_REMOTE;
                     73:                break;
                     74:        default:
                     75:                cp->cn_pri = CN_DEAD;
                     76:                break;
                     77:        }
                     78: }
                     79: 
                     80: dcminit(cp)
                     81:        struct consdev *cp;
                     82: {
                     83:        register struct dcmdevice *dcm = dcmcnaddr;
                     84:        register int port = CONUNIT;
                     85: 
                     86:        dcm->dcm_ic = IC_ID;
                     87:        while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr)
                     88:                ;
                     89:        dcm->dcm_data[port].dcm_baud = BR_9600;
                     90:        dcm->dcm_data[port].dcm_conf = LC_8BITS | LC_1STOP;
                     91:        SEM_LOCK(dcm);
                     92:        dcm->dcm_cmdtab[port].dcm_data |= CT_CON;
                     93:        dcm->dcm_cr |= (1 << port);
                     94:        SEM_UNLOCK(dcm);
                     95:        DELAY(15000);
                     96: }
                     97: 
                     98: #ifndef SMALL
                     99: dcmgetchar()
                    100: {
                    101:        register struct dcmdevice *dcm = dcmcnaddr;
                    102:        register struct dcmrfifo *fifo;
                    103:        register struct dcmpreg *pp;
                    104:        register unsigned head;
                    105:        int c, stat, port;
                    106: 
                    107:        port = CONUNIT;
                    108:        pp = dcm_preg(dcm, port);
                    109:        head = pp->r_head & RX_MASK;
                    110:        if (head == (pp->r_tail & RX_MASK))
                    111:                return(0);
                    112:        fifo = &dcm->dcm_rfifos[3-port][head>>1];
                    113:        c = fifo->data_char;
                    114:        stat = fifo->data_stat;
                    115:        pp->r_head = (head + 2) & RX_MASK;
                    116:        SEM_LOCK(dcm);
                    117:        stat = dcm->dcm_iir;
                    118:        SEM_UNLOCK(dcm);
                    119:        return(c);
                    120: }
                    121: #else
                    122: dcmgetchar()
                    123: {
                    124:        return(0);
                    125: }
                    126: #endif
                    127: 
                    128: dcmputchar(c)
                    129:        register int c;
                    130: {
                    131:        register struct dcmdevice *dcm = dcmcnaddr;
                    132:        register struct dcmpreg *pp;
                    133:        register int timo;
                    134:        unsigned tail;
                    135:        int port, stat;
                    136: 
                    137:        port = CONUNIT;
                    138:        pp = dcm_preg(dcm, port);
                    139:        tail = pp->t_tail & TX_MASK;
                    140:        timo = 50000;
                    141:        while (tail != (pp->t_head & TX_MASK) && --timo)
                    142:                ;
                    143:        dcm->dcm_tfifos[3-port][tail].data_char = c;
                    144:        pp->t_tail = tail = (tail + 1) & TX_MASK;
                    145:        SEM_LOCK(dcm);
                    146:        dcm->dcm_cmdtab[port].dcm_data |= CT_TX;
                    147:        dcm->dcm_cr |= (1 << port);
                    148:        SEM_UNLOCK(dcm);
                    149:        timo = 1000000;
                    150:        while (tail != (pp->t_head & TX_MASK) && --timo)
                    151:                ;
                    152:        SEM_LOCK(dcm);
                    153:        stat = dcm->dcm_iir;
                    154:        SEM_UNLOCK(dcm);
                    155: }
                    156: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.