Annotation of 43BSDReno/sys/hpstand/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 is only permitted until one year after the first shipment
                     11:  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
                     12:  * binary forms are permitted provided that: (1) source distributions retain
                     13:  * this entire copyright notice and comment, and (2) distributions including
                     14:  * binaries display the following acknowledgement:  This product includes
                     15:  * software developed by the University of California, Berkeley and its
                     16:  * contributors'' in the documentation or other materials provided with the
                     17:  * distribution and in all advertising materials mentioning features or use
                     18:  * of this software.  Neither the name of the University nor the names of
                     19:  * its contributors may be used to endorse or promote products derived from
                     20:  * this software without specific prior written permission.
                     21:  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     22:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     23:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     24:  *
                     25:  *     @(#)dcm.c       7.1 (Berkeley) 5/25/90
                     26:  */
                     27: 
                     28: #ifdef DCMCONSOLE
                     29: #include "param.h"
                     30: #include "machine/cons.h"
                     31: #include "../hpdev/device.h"
                     32: #include "../hpdev/dcmreg.h"
                     33: 
                     34: #define CONSPORT       (1)
                     35: struct dcmdevice *CONSOLE = NULL;
                     36: 
                     37: dcmprobe(cp)
                     38:        struct consdev *cp;
                     39: {
                     40:        extern struct hp_hw sc_table[];
                     41:        register struct hp_hw *hw;
                     42:        register struct dcmdevice *dcm;
                     43: 
                     44:        for (hw = sc_table; hw < &sc_table[MAX_CTLR]; hw++)
                     45:                if (hw->hw_type == COMMDCM && !badaddr((caddr_t)hw->hw_addr))
                     46:                        break;
                     47:        if (hw->hw_type != COMMDCM) {
                     48:                cp->cn_pri = CN_DEAD;
                     49:                return;
                     50:        }
                     51:        CONSOLE = (struct dcmdevice *)hw->hw_addr;
                     52: 
                     53:        dcm = CONSOLE;
                     54:        switch (dcm->dcm_rsid) {
                     55:        case DCMID:
                     56:                cp->cn_pri = CN_NORMAL;
                     57:                break;
                     58:        case DCMID|DCMCON:
                     59:                cp->cn_pri = CN_REMOTE;
                     60:                break;
                     61:        default:
                     62:                cp->cn_pri = CN_DEAD;
                     63:                break;
                     64:        }
                     65: }
                     66: 
                     67: dcminit(cp)
                     68:        struct consdev *cp;
                     69: {
                     70:        register struct dcmdevice *dcm = CONSOLE;
                     71:        register int port = CONSPORT;
                     72: 
                     73:        dcm->dcm_ic = IC_ID;
                     74:        while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr)
                     75:                ;
                     76:        dcm->dcm_data[port].dcm_baud = BR_9600;
                     77:        dcm->dcm_data[port].dcm_conf = LC_8BITS | LC_1STOP;
                     78:        SEM_LOCK(dcm);
                     79:        dcm->dcm_cmdtab[port].dcm_data |= CT_CON;
                     80:        dcm->dcm_cr |= (1 << port);
                     81:        SEM_UNLOCK(dcm);
                     82:        DELAY(15000);
                     83: }
                     84: 
                     85: #ifndef SMALL
                     86: dcmgetchar()
                     87: {
                     88:        register struct dcmdevice *dcm = CONSOLE;
                     89:        register struct dcmrfifo *fifo;
                     90:        register struct dcmpreg *pp;
                     91:        register unsigned head;
                     92:        int c, stat, port;
                     93: 
                     94:        port = CONSPORT;
                     95:        pp = dcm_preg(dcm, port);
                     96:        head = pp->r_head & RX_MASK;
                     97:        if (head == (pp->r_tail & RX_MASK))
                     98:                return(0);
                     99:        fifo = &dcm->dcm_rfifos[3-port][head>>1];
                    100:        c = fifo->data_char;
                    101:        stat = fifo->data_stat;
                    102:        pp->r_head = (head + 2) & RX_MASK;
                    103:        SEM_LOCK(dcm);
                    104:        stat = dcm->dcm_iir;
                    105:        SEM_UNLOCK(dcm);
                    106:        return(c);
                    107: }
                    108: #else
                    109: dcmgetchar()
                    110: {
                    111:        return(0);
                    112: }
                    113: #endif
                    114: 
                    115: dcmputchar(c)
                    116:        register int c;
                    117: {
                    118:        register struct dcmdevice *dcm = CONSOLE;
                    119:        register struct dcmpreg *pp;
                    120:        register int timo;
                    121:        unsigned tail;
                    122:        int port, stat;
                    123: 
                    124:        port = CONSPORT;
                    125:        pp = dcm_preg(dcm, port);
                    126:        tail = pp->t_tail & TX_MASK;
                    127:        timo = 50000;
                    128:        while (tail != (pp->t_head & TX_MASK) && --timo)
                    129:                ;
                    130:        dcm->dcm_tfifos[3-port][tail].data_char = c;
                    131:        pp->t_tail = tail = (tail + 1) & TX_MASK;
                    132:        SEM_LOCK(dcm);
                    133:        dcm->dcm_cmdtab[port].dcm_data |= CT_TX;
                    134:        dcm->dcm_cr |= (1 << port);
                    135:        SEM_UNLOCK(dcm);
                    136:        timo = 1000000;
                    137:        while (tail != (pp->t_head & TX_MASK) && --timo)
                    138:                ;
                    139:        SEM_LOCK(dcm);
                    140:        stat = dcm->dcm_iir;
                    141:        SEM_UNLOCK(dcm);
                    142: }
                    143: #endif

unix.superglobalmegacorp.com

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