merge with latest Utah version
[unix-history] / usr / src / sys / hp300 / stand / hpib.c
index 5c46a4b..a1f5b36 100644 (file)
@@ -4,55 +4,44 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)hpib.c      7.4 (Berkeley) %G%
+ *     @(#)hpib.c      7.6 (Berkeley) %G%
  */
 
 /*
  * HPIB driver
  */
  */
 
 /*
  * HPIB driver
  */
-#include <sys/param.h>
-#include <sys/reboot.h>
-#include "../dev/device.h"
+#include "sys/param.h"
+#include "sys/reboot.h"
+#include "hp/dev/device.h"
 #include "hpibvar.h"
 
 #include "saio.h"
 #include "samachdep.h"
 
 #include "hpibvar.h"
 
 #include "saio.h"
 #include "samachdep.h"
 
-int    internalhpib = 0x478000;
+int    internalhpib = IIOV(0x478000);
 int    fhpibppoll(), nhpibppoll();
 
 struct hpib_softc hpib_softc[NHPIB];
 
 int    fhpibppoll(), nhpibppoll();
 
 struct hpib_softc hpib_softc[NHPIB];
 
-#define        hpibunit(x)     ((x) >> 3)
-#define        hpibslave(x)    ((x) & 7)
-
 hpibinit()
 {
        extern struct hp_hw sc_table[];
        register struct hp_hw *hw;
        register struct hpib_softc *hs;
        register int i, addr;
 hpibinit()
 {
        extern struct hp_hw sc_table[];
        register struct hp_hw *hw;
        register struct hpib_softc *hs;
        register int i, addr;
-       static int first = 1;
-       
+
        i = 0;
        i = 0;
-       for (hw = sc_table; i < NHPIB && hw < &sc_table[MAX_CTLR]; hw++) {
-               if (hw->hw_type != HPIB)
+       for (hw = sc_table; i < NHPIB && hw < &sc_table[MAXCTLRS]; hw++) {
+               if (!HW_ISHPIB(hw))
                        continue;
                hs = &hpib_softc[i];
                        continue;
                hs = &hpib_softc[i];
-               hs->sc_addr = hw->hw_addr;
+               hs->sc_addr = hw->hw_kva;
                if (nhpibinit(i) == 0)
                        if (fhpibinit(i) == 0)
                                continue;
                if (howto & RB_ASKNAME)
                        printf("hpib%d at sc%d\n", i, hw->hw_sc);
                if (nhpibinit(i) == 0)
                        if (fhpibinit(i) == 0)
                                continue;
                if (howto & RB_ASKNAME)
                        printf("hpib%d at sc%d\n", i, hw->hw_sc);
-               /*
-                * Adjust devtype on first call.  This routine assumes that
-                * adaptor is in the high byte of devtype.
-                */
-               if (first && ((devtype >> 24) & 0xff) == hw->hw_sc) {
-                       devtype = (devtype & 0x00ffffff) | (i << 24);
-                       first = 0;
-               }
+               hw->hw_pa = (caddr_t) i;        /* XXX for autoconfig */
                hs->sc_alive = 1;
                i++;
        }
                hs->sc_alive = 1;
                i++;
        }
@@ -61,68 +50,53 @@ hpibinit()
 hpibalive(unit)
        register int unit;
 {
 hpibalive(unit)
        register int unit;
 {
-       unit = hpibunit(unit);
        if (unit >= NHPIB || hpib_softc[unit].sc_alive == 0)
                return (0);
        return (1);
 }
 
        if (unit >= NHPIB || hpib_softc[unit].sc_alive == 0)
                return (0);
        return (1);
 }
 
-hpibid(unit)
-       register int unit;
+hpibid(unit, slave)
+       int unit, slave;
 {
 {
-       register struct hpib_softc *hs = &hpib_softc[hpibunit(unit)];
-       register int slave;
        short id;
        short id;
+       int rv;
 
 
-       slave = hpibslave(unit);
-       unit = hpibunit(unit);
-       if (hs->sc_type == HPIBC)
-               slave = fhpibrecv(unit, 31, slave, &id, 2);
+       if (hpib_softc[unit].sc_type == HPIBC)
+               rv = fhpibrecv(unit, 31, slave, &id, 2);
        else
        else
-               slave = nhpibrecv(unit, 31, slave, &id, 2);
-       if (slave != 2)
+               rv = nhpibrecv(unit, 31, slave, &id, 2);
+       if (rv != 2)
                return (0);
        return (id);
 }
 
                return (0);
        return (id);
 }
 
-hpibsend(unit, sec, buf, cnt)
-       register char *buf;
-       register int cnt;
+hpibsend(unit, slave, sec, buf, cnt)
+       int unit, slave;
+       char *buf;
+       int cnt;
 {
 {
-       register struct hpib_softc *hs = &hpib_softc[hpibunit(unit)];
-       register int slave;
-
-       slave = hpibslave(unit);
-       unit = hpibunit(unit);
-       if (hs->sc_type == HPIBC)
+       if (hpib_softc[unit].sc_type == HPIBC)
                return (fhpibsend(unit, slave, sec, buf, cnt));
                return (fhpibsend(unit, slave, sec, buf, cnt));
-       else
-               return (nhpibsend(unit, slave, sec, buf, cnt));
+       return (nhpibsend(unit, slave, sec, buf, cnt));
 }
 
 }
 
-hpibrecv(unit, sec, buf, cnt)
-       register char *buf;
-       register int cnt;
+hpibrecv(unit, slave, sec, buf, cnt)
+       int unit, slave;
+       char *buf;
+       int cnt;
 {
 {
-       register struct hpib_softc *hs = &hpib_softc[hpibunit(unit)];
-       register int slave;
-
-       slave = hpibslave(unit);
-       unit = hpibunit(unit);
-       if (hs->sc_type == HPIBC)
+       if (hpib_softc[unit].sc_type == HPIBC)
                return (fhpibrecv(unit, slave, sec, buf, cnt));
                return (fhpibrecv(unit, slave, sec, buf, cnt));
-       else
-               return (nhpibrecv(unit, slave, sec, buf, cnt));
+       return (nhpibrecv(unit, slave, sec, buf, cnt));
 }
 
 }
 
-hpibswait(unit)
-       register int unit;
+hpibswait(unit, slave)
+       register int unit, slave;
 {
        register int timo = 1000000;
 {
        register int timo = 1000000;
-       register int slave = 0x80 >> hpibslave(unit);
        register int (*poll)();
 
        register int (*poll)();
 
-       unit = hpibunit(unit);
+       slave = 0x80 >> slave;
        if (hpib_softc[unit].sc_type == HPIBC)
                poll = fhpibppoll;
        else
        if (hpib_softc[unit].sc_type == HPIBC)
                poll = fhpibppoll;
        else
@@ -135,14 +109,10 @@ hpibswait(unit)
        return (0);
 }
 
        return (0);
 }
 
-hpibgo(unit, sec, addr, count, flag)
-       register int unit;
+hpibgo(unit, slave, sec, addr, count, flag)
+       int unit, slave;
        char *addr;
 {
        char *addr;
 {
-       register int slave;
-
-       slave = hpibslave(unit);
-       unit = hpibunit(unit);
        if (hpib_softc[unit].sc_type == HPIBC)
                if (flag == F_READ)
                        fhpibrecv(unit, slave, sec, addr, count);
        if (hpib_softc[unit].sc_type == HPIBC)
                if (flag == F_READ)
                        fhpibrecv(unit, slave, sec, addr, count);