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