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