fix to silo and bk bug
[unix-history] / usr / src / sys / vax / uba / ct.c
index 7489700..ecd0f3b 100644 (file)
@@ -1,17 +1,22 @@
-/*     ct.c    4.3     81/03/09        */
+/*     ct.c    4.6     81/07/05        */
 
 
-#include "cat.h"
+#include "ct.h"
 #if NCT > 0
 /*
  * GP DR11C driver used for C/A/T
 #if NCT > 0
 /*
  * GP DR11C driver used for C/A/T
+ *
+ * BUGS:
+ *     This driver hasn't been tested in 4.1bsd
  */
 
 #include "../h/param.h"
  */
 
 #include "../h/param.h"
+#include "../h/systm.h"
 #include "../h/tty.h"
 #include "../h/pte.h"
 #include "../h/map.h"
 #include "../h/tty.h"
 #include "../h/pte.h"
 #include "../h/map.h"
-#include "../h/uba.h"
 #include "../h/buf.h"
 #include "../h/buf.h"
+#include "../h/ubareg.h"
+#include "../h/ubavar.h"
 #include "../h/conf.h"
 #include "../h/dir.h"
 #include "../h/user.h"
 #include "../h/conf.h"
 #include "../h/dir.h"
 #include "../h/user.h"
 #define        CATHIWAT        100
 #define        CATLOWAT        30
 
 #define        CATHIWAT        100
 #define        CATLOWAT        30
 
-struct {
-       int     catlock;
-       struct  clist   oq;
-} cat;
+struct ct_softc {
+       int     sc_openf;
+       struct  clist sc_oq;
+} ct_softc[NCT];
 
 
-struct device {
-       short   catcsr;
-       short   catbuf;
+struct ctdevice {
+       short   ctcsr;
+       short   ctbuf;
 };
 
 };
 
-int ctintr();
+int    ctprobe(), ctattach(), ctintr();
+struct uba_device *ctdinfo[NCT];
+u_short        ctstd[] = { 0 };
+struct uba_driver ctdriver = 
+    { ctprobe, 0, ctattach, 0, ctstd, "ct", ctdinfo };
+
+#define        CTUNIT(dev)     (minor(dev))
+
+ctprobe(reg)
+       caddr_t reg;
+{
+       register int br, cvec;          /* value-result */
+       register struct ctdevice *ctaddr = (struct ctdevice *)reg;
+
+       ctaddr->ctcsr = IENABLE;
+       DELAY(10000);
+       ctaddr->ctcsr = 0;
+}
+
+/*ARGSUSED*/
+ctattach(ui)
+       register struct uba_device *ui;
+{
+
+}
 
 ctopen(dev)
 
 ctopen(dev)
+       dev_t dev;
 {
 {
-       if (cat.catlock==0) {
-               cat.catlock++;
-               CATADDR->catcsr |= IENABLE;
-       } else
+       register struct ct_softc *sc;
+       register struct uba_device *ui;
+       register struct ctdevice *ctaddr;
+
+       if (CTUNIT(dev) >= NCT || (ui = ctdinfo[CTUNIT(dev)]) == 0 ||
+           ui->ui_alive == 0 || (sc = &ct_softc[CTUNIT(dev)])->sc_openf) {
                u.u_error = ENXIO;
                u.u_error = ENXIO;
+               return;
+       }
+       sc->sc_openf = 1;
+       ctaddr->ctcsr |= IENABLE;
 }
 
 }
 
-ctclose()
+ctclose(dev)
+       dev_t dev;
 {
 {
-       cat.catlock = 0;
-       ctintr();
+
+       ct_softc[CTUNIT(dev)].sc_openf = 0;
+       ctintr(dev);
 }
 
 ctwrite(dev)
 }
 
 ctwrite(dev)
+       dev_t dev;
 {
 {
-       register c;
-       extern lbolt;
+       register struct ct_softc *sc = &ct_softc[CTUNIT(dev)];
+       register int c;
 
        while ((c=cpass()) >= 0) {
                (void) spl5();
 
        while ((c=cpass()) >= 0) {
                (void) spl5();
-               while (cat.oq.c_cc > CATHIWAT)
-                       sleep((caddr_t)&cat.oq, PCAT);
-               while (putc(c, &cat.oq) < 0)
+               while (sc->sc_oq.c_cc > CATHIWAT)
+                       sleep((caddr_t)&sc->sc_oq, PCAT);
+               while (putc(c, &sc->sc_oq) < 0)
                        sleep((caddr_t)&lbolt, PCAT);
                        sleep((caddr_t)&lbolt, PCAT);
-               ctintr();
+               ctintr(dev);
                (void) spl0();
        }
 }
 
                (void) spl0();
        }
 }
 
-ctintr()
+ctintr(dev)
+       dev_t dev;
 {
        register int c;
 {
        register int c;
+       register struct ct_softc *sc = &ct_softc[CTUNIT(dev)];
+       register struct ctdevice *ctaddr =
+           (struct ctdevice *)ctdinfo[CTUNIT(dev)]->ui_addr;
 
 
-       if (CATADDR->catcsr&DONE) {
-               if ((c = getc(&cat.oq)) >= 0) {
+       if (ctaddr->ctcsr&DONE) {
+               if ((c = getc(&sc->sc_oq)) >= 0) {
 #if MH135A
                        c |= (c & 01) << 8;     /* for dr11c bug */
 #endif         
 #if MH135A
                        c |= (c & 01) << 8;     /* for dr11c bug */
 #endif         
-                       CATADDR->catbuf = c;
-                       if (cat.oq.c_cc==0 || cat.oq.c_cc==CATLOWAT)
-                               wakeup(&cat.oq);
+                       ctaddr->ctbuf = c;
+                       if (sc->sc_oq.c_cc==0 || sc->sc_oq.c_cc==CATLOWAT)
+                               wakeup(&sc->sc_oq);
                } else {
                } else {
-                       if (cat.catlock==0)
-                               CATADDR->catcsr = 0;
+                       if (sc->sc_openf==0)
+                               ctaddr->ctcsr = 0;
                }
        }
 
                }
        }