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

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:  *
                     38:  *     @(#)dcm.c       7.3 (Berkeley) 5/7/91
                     39:  */
                     40: 
                     41: #ifdef DCMCONSOLE
                     42: #include "sys/param.h"
                     43: #include "../hp300/cons.h"
                     44: #include "../dev/device.h"
                     45: #include "../dev/dcmreg.h"
                     46: 
                     47: struct dcmdevice *dcmcnaddr = NULL;
                     48: 
                     49: dcmprobe(cp)
                     50:        struct consdev *cp;
                     51: {
                     52:        extern struct hp_hw sc_table[];
                     53:        register struct hp_hw *hw;
                     54:        register struct dcmdevice *dcm;
                     55: 
                     56:        for (hw = sc_table; hw < &sc_table[MAXCTLRS]; hw++)
                     57:                if (HW_ISDEV(hw, D_COMMDCM) && !badaddr((caddr_t)hw->hw_kva))
                     58:                        break;
                     59:        if (!HW_ISDEV(hw, D_COMMDCM)) {
                     60:                cp->cn_pri = CN_DEAD;
                     61:                return;
                     62:        }
                     63:        dcmcnaddr = (struct dcmdevice *) hw->hw_kva;
                     64: 
                     65:        dcm = dcmcnaddr;
                     66:        switch (dcm->dcm_rsid) {
                     67:        case DCMID:
                     68:                cp->cn_pri = CN_NORMAL;
                     69:                break;
                     70:        case DCMID|DCMCON:
                     71:                cp->cn_pri = CN_REMOTE;
                     72:                break;
                     73:        default:
                     74:                cp->cn_pri = CN_DEAD;
                     75:                break;
                     76:        }
                     77: }
                     78: 
                     79: dcminit(cp)
                     80:        struct consdev *cp;
                     81: {
                     82:        register struct dcmdevice *dcm = dcmcnaddr;
                     83:        register int port = CONUNIT;
                     84: 
                     85:        dcm->dcm_ic = IC_ID;
                     86:        while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr)
                     87:                ;
                     88:        dcm->dcm_data[port].dcm_baud = BR_9600;
                     89:        dcm->dcm_data[port].dcm_conf = LC_8BITS | LC_1STOP;
                     90:        SEM_LOCK(dcm);
                     91:        dcm->dcm_cmdtab[port].dcm_data |= CT_CON;
                     92:        dcm->dcm_cr |= (1 << port);
                     93:        SEM_UNLOCK(dcm);
                     94:        DELAY(15000);
                     95: }
                     96: 
                     97: #ifndef SMALL
                     98: dcmgetchar()
                     99: {
                    100:        register struct dcmdevice *dcm = dcmcnaddr;
                    101:        register struct dcmrfifo *fifo;
                    102:        register struct dcmpreg *pp;
                    103:        register unsigned head;
                    104:        int c, stat, port;
                    105: 
                    106:        port = CONUNIT;
                    107:        pp = dcm_preg(dcm, port);
                    108:        head = pp->r_head & RX_MASK;
                    109:        if (head == (pp->r_tail & RX_MASK))
                    110:                return(0);
                    111:        fifo = &dcm->dcm_rfifos[3-port][head>>1];
                    112:        c = fifo->data_char;
                    113:        stat = fifo->data_stat;
                    114:        pp->r_head = (head + 2) & RX_MASK;
                    115:        SEM_LOCK(dcm);
                    116:        stat = dcm->dcm_iir;
                    117:        SEM_UNLOCK(dcm);
                    118:        return(c);
                    119: }
                    120: #else
                    121: dcmgetchar()
                    122: {
                    123:        return(0);
                    124: }
                    125: #endif
                    126: 
                    127: dcmputchar(c)
                    128:        register int c;
                    129: {
                    130:        register struct dcmdevice *dcm = dcmcnaddr;
                    131:        register struct dcmpreg *pp;
                    132:        register int timo;
                    133:        unsigned tail;
                    134:        int port, stat;
                    135: 
                    136:        port = CONUNIT;
                    137:        pp = dcm_preg(dcm, port);
                    138:        tail = pp->t_tail & TX_MASK;
                    139:        timo = 50000;
                    140:        while (tail != (pp->t_head & TX_MASK) && --timo)
                    141:                ;
                    142:        dcm->dcm_tfifos[3-port][tail].data_char = c;
                    143:        pp->t_tail = tail = (tail + 1) & TX_MASK;
                    144:        SEM_LOCK(dcm);
                    145:        dcm->dcm_cmdtab[port].dcm_data |= CT_TX;
                    146:        dcm->dcm_cr |= (1 << port);
                    147:        SEM_UNLOCK(dcm);
                    148:        timo = 1000000;
                    149:        while (tail != (pp->t_head & TX_MASK) && --timo)
                    150:                ;
                    151:        SEM_LOCK(dcm);
                    152:        stat = dcm->dcm_iir;
                    153:        SEM_UNLOCK(dcm);
                    154: }
                    155: #endif

unix.superglobalmegacorp.com

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