1 /* ct.c 4.7 81/11/18 */ 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 #ifdef lint 53 br = 0; cvec = br; br = cvec; 54 ctintr(0); 55 #endif 56 ctaddr->ctcsr = IENABLE; 57 DELAY(10000); 58 ctaddr->ctcsr = 0; 59 } 60 61 /*ARGSUSED*/ 62 ctattach(ui) 63 register struct uba_device *ui; 64 { 65 66 } 67 68 ctopen(dev) 69 dev_t dev; 70 { 71 register struct ct_softc *sc; 72 register struct uba_device *ui; 73 register struct ctdevice *ctaddr; 74 75 if (CTUNIT(dev) >= NCT || (ui = ctdinfo[CTUNIT(dev)]) == 0 || 76 ui->ui_alive == 0 || (sc = &ct_softc[CTUNIT(dev)])->sc_openf) { 77 u.u_error = ENXIO; 78 return; 79 } 80 sc->sc_openf = 1; 81 ctaddr->ctcsr |= IENABLE; 82 } 83 84 ctclose(dev) 85 dev_t dev; 86 { 87 88 ct_softc[CTUNIT(dev)].sc_openf = 0; 89 ctintr(dev); 90 } 91 92 ctwrite(dev) 93 dev_t dev; 94 { 95 register struct ct_softc *sc = &ct_softc[CTUNIT(dev)]; 96 register int c; 97 98 while ((c=cpass()) >= 0) { 99 (void) spl5(); 100 while (sc->sc_oq.c_cc > CATHIWAT) 101 sleep((caddr_t)&sc->sc_oq, PCAT); 102 while (putc(c, &sc->sc_oq) < 0) 103 sleep((caddr_t)&lbolt, PCAT); 104 ctintr(dev); 105 (void) spl0(); 106 } 107 } 108 109 ctintr(dev) 110 dev_t dev; 111 { 112 register int c; 113 register struct ct_softc *sc = &ct_softc[CTUNIT(dev)]; 114 register struct ctdevice *ctaddr = 115 (struct ctdevice *)ctdinfo[CTUNIT(dev)]->ui_addr; 116 117 if (ctaddr->ctcsr&DONE) { 118 if ((c = getc(&sc->sc_oq)) >= 0) { 119 ctaddr->ctbuf = c; 120 if (sc->sc_oq.c_cc==0 || sc->sc_oq.c_cc==CATLOWAT) 121 wakeup(&sc->sc_oq); 122 } else { 123 if (sc->sc_openf==0) 124 ctaddr->ctcsr = 0; 125 } 126 } 127 128 } 129 #endif 130