fix to reeves fix of dgo handling (reset b_active to 1)
[unix-history] / usr / src / sys / vax / uba / ct.c
CommitLineData
89b8a44c 1/* ct.c 4.7 81/11/18 */
99aa0ab4 2
a53c8506 3#include "ct.h"
99aa0ab4
BJ
4#if NCT > 0
5/*
6 * GP DR11C driver used for C/A/T
2b50de22
KB
7 *
8 * BUGS:
9 * This driver hasn't been tested in 4.1bsd
99aa0ab4
BJ
10 */
11
12#include "../h/param.h"
a53c8506 13#include "../h/systm.h"
99aa0ab4
BJ
14#include "../h/tty.h"
15#include "../h/pte.h"
16#include "../h/map.h"
99aa0ab4 17#include "../h/buf.h"
a53c8506
BJ
18#include "../h/ubareg.h"
19#include "../h/ubavar.h"
99aa0ab4
BJ
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
a53c8506
BJ
28struct ct_softc {
29 int sc_openf;
30 struct clist sc_oq;
31} ct_softc[NCT];
99aa0ab4 32
a53c8506
BJ
33struct ctdevice {
34 short ctcsr;
35 short ctbuf;
99aa0ab4
BJ
36};
37
a53c8506
BJ
38int ctprobe(), ctattach(), ctintr();
39struct uba_device *ctdinfo[NCT];
40u_short ctstd[] = { 0 };
41struct uba_driver ctdriver =
42 { ctprobe, 0, ctattach, 0, ctstd, "ct", ctdinfo };
43
042f22be
BJ
44#define CTUNIT(dev) (minor(dev))
45
a53c8506
BJ
46ctprobe(reg)
47 caddr_t reg;
48{
2b50de22 49 register int br, cvec; /* value-result */
a53c8506
BJ
50 register struct ctdevice *ctaddr = (struct ctdevice *)reg;
51
89b8a44c
BJ
52#ifdef lint
53 br = 0; cvec = br; br = cvec;
54 ctintr(0);
55#endif
a53c8506
BJ
56 ctaddr->ctcsr = IENABLE;
57 DELAY(10000);
58 ctaddr->ctcsr = 0;
59}
99aa0ab4 60
042f22be
BJ
61/*ARGSUSED*/
62ctattach(ui)
63 register struct uba_device *ui;
64{
65
66}
67
99aa0ab4 68ctopen(dev)
a53c8506 69 dev_t dev;
99aa0ab4 70{
a53c8506
BJ
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) {
99aa0ab4 77 u.u_error = ENXIO;
a53c8506
BJ
78 return;
79 }
80 sc->sc_openf = 1;
81 ctaddr->ctcsr |= IENABLE;
99aa0ab4
BJ
82}
83
a53c8506
BJ
84ctclose(dev)
85 dev_t dev;
99aa0ab4 86{
a53c8506
BJ
87
88 ct_softc[CTUNIT(dev)].sc_openf = 0;
89 ctintr(dev);
99aa0ab4
BJ
90}
91
92ctwrite(dev)
a53c8506 93 dev_t dev;
99aa0ab4 94{
a53c8506
BJ
95 register struct ct_softc *sc = &ct_softc[CTUNIT(dev)];
96 register int c;
99aa0ab4
BJ
97
98 while ((c=cpass()) >= 0) {
a0eab615 99 (void) spl5();
a53c8506
BJ
100 while (sc->sc_oq.c_cc > CATHIWAT)
101 sleep((caddr_t)&sc->sc_oq, PCAT);
102 while (putc(c, &sc->sc_oq) < 0)
99aa0ab4 103 sleep((caddr_t)&lbolt, PCAT);
a53c8506 104 ctintr(dev);
a0eab615 105 (void) spl0();
99aa0ab4
BJ
106 }
107}
108
a53c8506
BJ
109ctintr(dev)
110 dev_t dev;
99aa0ab4
BJ
111{
112 register int c;
a53c8506
BJ
113 register struct ct_softc *sc = &ct_softc[CTUNIT(dev)];
114 register struct ctdevice *ctaddr =
115 (struct ctdevice *)ctdinfo[CTUNIT(dev)]->ui_addr;
99aa0ab4 116
a53c8506
BJ
117 if (ctaddr->ctcsr&DONE) {
118 if ((c = getc(&sc->sc_oq)) >= 0) {
a53c8506
BJ
119 ctaddr->ctbuf = c;
120 if (sc->sc_oq.c_cc==0 || sc->sc_oq.c_cc==CATLOWAT)
121 wakeup(&sc->sc_oq);
99aa0ab4 122 } else {
a53c8506
BJ
123 if (sc->sc_openf==0)
124 ctaddr->ctcsr = 0;
99aa0ab4
BJ
125 }
126 }
127
128}
129#endif