Annotation of researchv8dc/sys/dev/ct.c, revision 1.1

1.1     ! root        1: /*     ct.c    4.6     81/07/05        */
        !             2: 
        !             3: #include "ct.h"
        !             4: #if NCT > 0
        !             5: /*
        !             6:  * GP DR11C driver used for C/A/T
        !             7:  *
        !             8:  * BUGS:
        !             9:  *     This driver hasn't been tested in 4.1bsd
        !            10:  */
        !            11: 
        !            12: #include "../h/param.h"
        !            13: #include "../h/systm.h"
        !            14: #include "../h/pte.h"
        !            15: #include "../h/map.h"
        !            16: #include "../h/buf.h"
        !            17: #include "../h/ubareg.h"
        !            18: #include "../h/ubavar.h"
        !            19: #include "../h/conf.h"
        !            20: #include "../h/dir.h"
        !            21: #include "../h/user.h"
        !            22: 
        !            23: #define        PCAT    (PZERO+9)
        !            24: #define        CATHIWAT        100
        !            25: #define        CATLOWAT        30
        !            26: 
        !            27: struct ct_softc {
        !            28:        int     sc_openf;
        !            29:        struct  clist sc_oq;
        !            30: } ct_softc[NCT];
        !            31: 
        !            32: struct ctdevice {
        !            33:        short   ctcsr;
        !            34:        short   ctbuf;
        !            35: };
        !            36: 
        !            37: int    ctprobe(), ctattach(), ctintr();
        !            38: struct uba_device *ctdinfo[NCT];
        !            39: u_short        ctstd[] = { 0 };
        !            40: struct uba_driver ctdriver = 
        !            41:     { ctprobe, 0, ctattach, 0, ctstd, "ct", ctdinfo };
        !            42: 
        !            43: #define        CTUNIT(dev)     (minor(dev))
        !            44: 
        !            45: ctprobe(reg)
        !            46:        caddr_t reg;
        !            47: {
        !            48:        register int br, cvec;          /* value-result */
        !            49:        register struct ctdevice *ctaddr = (struct ctdevice *)reg;
        !            50: 
        !            51:        ctaddr->ctcsr = IENABLE;
        !            52:        DELAY(10000);
        !            53:        ctaddr->ctcsr = 0;
        !            54: }
        !            55: 
        !            56: /*ARGSUSED*/
        !            57: ctattach(ui)
        !            58:        register struct uba_device *ui;
        !            59: {
        !            60: 
        !            61: }
        !            62: 
        !            63: ctopen(dev)
        !            64:        dev_t dev;
        !            65: {
        !            66:        register struct ct_softc *sc;
        !            67:        register struct uba_device *ui;
        !            68:        register struct ctdevice *ctaddr;
        !            69: 
        !            70:        if (CTUNIT(dev) >= NCT || (ui = ctdinfo[CTUNIT(dev)]) == 0 ||
        !            71:            ui->ui_alive == 0 || (sc = &ct_softc[CTUNIT(dev)])->sc_openf) {
        !            72:                u.u_error = ENXIO;
        !            73:                return;
        !            74:        }
        !            75:        sc->sc_openf = 1;
        !            76:        ctaddr->ctcsr |= IENABLE;
        !            77: }
        !            78: 
        !            79: ctclose(dev)
        !            80:        dev_t dev;
        !            81: {
        !            82: 
        !            83:        ct_softc[CTUNIT(dev)].sc_openf = 0;
        !            84:        ctintr(dev);
        !            85: }
        !            86: 
        !            87: ctwrite(dev)
        !            88:        dev_t dev;
        !            89: {
        !            90:        register struct ct_softc *sc = &ct_softc[CTUNIT(dev)];
        !            91:        register int c;
        !            92: 
        !            93:        while ((c=cpass()) >= 0) {
        !            94:                (void) spl5();
        !            95:                while (sc->sc_oq.c_cc > CATHIWAT)
        !            96:                        sleep((caddr_t)&sc->sc_oq, PCAT);
        !            97:                while (putc(c, &sc->sc_oq) < 0)
        !            98:                        sleep((caddr_t)&lbolt, PCAT);
        !            99:                ctintr(dev);
        !           100:                (void) spl0();
        !           101:        }
        !           102: }
        !           103: 
        !           104: ctintr(dev)
        !           105:        dev_t dev;
        !           106: {
        !           107:        register int c;
        !           108:        register struct ct_softc *sc = &ct_softc[CTUNIT(dev)];
        !           109:        register struct ctdevice *ctaddr =
        !           110:            (struct ctdevice *)ctdinfo[CTUNIT(dev)]->ui_addr;
        !           111: 
        !           112:        if (ctaddr->ctcsr&DONE) {
        !           113:                if ((c = getc(&sc->sc_oq)) >= 0) {
        !           114: #if MH135A
        !           115:                        c |= (c & 01) << 8;     /* for dr11c bug */
        !           116: #endif         
        !           117:                        ctaddr->ctbuf = c;
        !           118:                        if (sc->sc_oq.c_cc==0 || sc->sc_oq.c_cc==CATLOWAT)
        !           119:                                wakeup(&sc->sc_oq);
        !           120:                } else {
        !           121:                        if (sc->sc_openf==0)
        !           122:                                ctaddr->ctcsr = 0;
        !           123:                }
        !           124:        }
        !           125: 
        !           126: }
        !           127: #endif

unix.superglobalmegacorp.com

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