|
|
1.1 ! root 1: /* ct.c 6.1 83/07/29 */ ! 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: #include "../machine/pte.h" ! 12: ! 13: #include "../h/param.h" ! 14: #include "../h/systm.h" ! 15: #include "../h/tty.h" ! 16: #include "../h/map.h" ! 17: #include "../h/buf.h" ! 18: #include "../h/conf.h" ! 19: #include "../h/dir.h" ! 20: #include "../h/user.h" ! 21: ! 22: #include "../vaxuba/ubareg.h" ! 23: #include "../vaxuba/ubavar.h" ! 24: ! 25: #define PCAT (PZERO+9) ! 26: #define CATHIWAT 100 ! 27: #define CATLOWAT 30 ! 28: ! 29: struct ct_softc { ! 30: int sc_openf; ! 31: struct clist sc_oq; ! 32: } ct_softc[NCT]; ! 33: ! 34: struct ctdevice { ! 35: short ctcsr; ! 36: short ctbuf; ! 37: }; ! 38: ! 39: int ctprobe(), ctattach(), ctintr(); ! 40: struct uba_device *ctdinfo[NCT]; ! 41: u_short ctstd[] = { 0 }; ! 42: struct uba_driver ctdriver = ! 43: { ctprobe, 0, ctattach, 0, ctstd, "ct", ctdinfo }; ! 44: ! 45: #define CTUNIT(dev) (minor(dev)) ! 46: ! 47: ctprobe(reg) ! 48: caddr_t reg; ! 49: { ! 50: register int br, cvec; /* value-result */ ! 51: register struct ctdevice *ctaddr = (struct ctdevice *)reg; ! 52: ! 53: #ifdef lint ! 54: br = 0; cvec = br; br = cvec; ! 55: ctintr(0); ! 56: #endif ! 57: ctaddr->ctcsr = IENABLE; ! 58: DELAY(10000); ! 59: ctaddr->ctcsr = 0; ! 60: return (sizeof (struct ctdevice)); ! 61: } ! 62: ! 63: /*ARGSUSED*/ ! 64: ctattach(ui) ! 65: register struct uba_device *ui; ! 66: { ! 67: ! 68: } ! 69: ! 70: ctopen(dev) ! 71: dev_t dev; ! 72: { ! 73: register struct ct_softc *sc; ! 74: register struct uba_device *ui; ! 75: register struct ctdevice *ctaddr; ! 76: ! 77: if (CTUNIT(dev) >= NCT || (ui = ctdinfo[CTUNIT(dev)]) == 0 || ! 78: ui->ui_alive == 0 || (sc = &ct_softc[CTUNIT(dev)])->sc_openf) ! 79: return (ENXIO); ! 80: sc->sc_openf = 1; ! 81: ctaddr->ctcsr |= IENABLE; ! 82: return (0); ! 83: } ! 84: ! 85: ctclose(dev) ! 86: dev_t dev; ! 87: { ! 88: ! 89: ct_softc[CTUNIT(dev)].sc_openf = 0; ! 90: ctintr(dev); ! 91: } ! 92: ! 93: ctwrite(dev, uio) ! 94: dev_t dev; ! 95: struct uio *uio; ! 96: { ! 97: register struct ct_softc *sc = &ct_softc[CTUNIT(dev)]; ! 98: register int c; ! 99: ! 100: while ((c=cupass(uio)) >= 0) { ! 101: (void) spl5(); ! 102: while (sc->sc_oq.c_cc > CATHIWAT) ! 103: sleep((caddr_t)&sc->sc_oq, PCAT); ! 104: while (putc(c, &sc->sc_oq) < 0) ! 105: sleep((caddr_t)&lbolt, PCAT); ! 106: ctintr(dev); ! 107: (void) spl0(); ! 108: } ! 109: } ! 110: ! 111: ctintr(dev) ! 112: dev_t dev; ! 113: { ! 114: register int c; ! 115: register struct ct_softc *sc = &ct_softc[CTUNIT(dev)]; ! 116: register struct ctdevice *ctaddr = ! 117: (struct ctdevice *)ctdinfo[CTUNIT(dev)]->ui_addr; ! 118: ! 119: if (ctaddr->ctcsr&DONE) { ! 120: if ((c = getc(&sc->sc_oq)) >= 0) { ! 121: ctaddr->ctbuf = c; ! 122: if (sc->sc_oq.c_cc==0 || sc->sc_oq.c_cc==CATLOWAT) ! 123: wakeup(&sc->sc_oq); ! 124: } else { ! 125: if (sc->sc_openf==0) ! 126: ctaddr->ctcsr = 0; ! 127: } ! 128: } ! 129: ! 130: } ! 131: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.