Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/hp300/dev Pull HP-IB probe fixes from OpenBSD/hp300.



details:   https://anonhg.NetBSD.org/src/rev/c72f7a1c1ace
branches:  trunk
changeset: 1022121:c72f7a1c1ace
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Mon Jul 05 14:03:46 2021 +0000

description:
Pull HP-IB probe fixes from OpenBSD/hp300.

https://marc.info/?l=openbsd-cvs&m=113217630426615&w=2
> Overhaul the way HP-IB devices are probed. We will now do an exhaustive
> probe of the (slave, punit) tuple space, since this is the only way we
> can get a dual disk or dual tape enclosure to attach two devices of the
> same kind.

This allows using multiple rd(4) disk images on the same slave emulated
by HPDisk (and probably the real 9122D with dual floppy disk drives).

Thanks to Miod Vallat for suggesting this fix.

diffstat:

 sys/arch/hp300/dev/ct.c      |    9 +-
 sys/arch/hp300/dev/hpib.c    |  136 ++++++++++++------------------------------
 sys/arch/hp300/dev/hpibvar.h |    8 +--
 sys/arch/hp300/dev/mt.c      |    7 +-
 sys/arch/hp300/dev/rd.c      |   31 ++-------
 5 files changed, 57 insertions(+), 134 deletions(-)

diffs (truncated from 356 to 300 lines):

diff -r e142c323f2e7 -r c72f7a1c1ace sys/arch/hp300/dev/ct.c
--- a/sys/arch/hp300/dev/ct.c   Mon Jul 05 13:41:08 2021 +0000
+++ b/sys/arch/hp300/dev/ct.c   Mon Jul 05 14:03:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ct.c,v 1.61 2014/07/25 08:10:33 dholland Exp $ */
+/*     $NetBSD: ct.c,v 1.62 2021/07/05 14:03:46 tsutsui Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ct.c,v 1.61 2014/07/25 08:10:33 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ct.c,v 1.62 2021/07/05 14:03:46 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -270,13 +270,12 @@
 
        /* Is it one of the tapes we support? */
        for (id = 0; id < nctinfo; id++)
-               if (ha->ha_id == ctinfo[id].hwid)
+               if (ha->ha_id == ctinfo[id].hwid &&
+                   ha->ha_punit == ctinfo[id].punit)
                        break;
        if (id == nctinfo)
                return 0;
 
-       ha->ha_punit = ctinfo[id].punit;
-
        /*
         * So far, so good.  Get drive parameters.  Note command
         * is always issued to unit 0.
diff -r e142c323f2e7 -r c72f7a1c1ace sys/arch/hp300/dev/hpib.c
--- a/sys/arch/hp300/dev/hpib.c Mon Jul 05 13:41:08 2021 +0000
+++ b/sys/arch/hp300/dev/hpib.c Mon Jul 05 14:03:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hpib.c,v 1.42 2021/04/24 23:36:37 thorpej Exp $        */
+/*     $NetBSD: hpib.c,v 1.43 2021/07/05 14:03:46 tsutsui Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpib.c,v 1.42 2021/04/24 23:36:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpib.c,v 1.43 2021/07/05 14:03:46 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -89,14 +89,9 @@
     hpibbusmatch, hpibbusattach, NULL, NULL);
 
 static void    hpibbus_attach_children(struct hpibbus_softc *);
-static int     hpibbussearch(device_t, cfdata_t, const int *, void *);
+static int     hpibbussubmatch(device_t, cfdata_t, const int *ldesc, void *);
 static int     hpibbusprint(void *, const char *);
 
-static int     hpibbus_alloc(struct hpibbus_softc *, int, int);
-#if 0
-static void    hpibbus_free(struct hpibbus_softc *, int, int);
-#endif
-
 static void    hpibstart(void *);
 static void    hpibdone(void *);
 
@@ -121,17 +116,9 @@
  * have ID tags, and often the host cannot even tell if such
  * a device is attached to the system!
  *
- * These two nasty bits mean that we have to treat HP-IB as
- * an indirect bus.  However, since we are given some ID
- * information, it is unreasonable to disallow cloning of
- * CS/80 devices.
- *
- * To deal with all of this, we use the semi-twisted scheme
- * in hpibbus_attach_children().  For each HP-IB slave, we loop
- * through all of the possibly-configured children, allowing
- * them to modify the punit parameter (but NOT the slave!).
- *
- * This is evil, but what can you do?
+ * * We nevertheless probe the whole (slave, punit) tuple space, since
+ * drivers for devices with a unique ID know exactly where to attach; 
+ * and we disallow ``star'' locators for other drivers.
  */
 
 static int
@@ -177,64 +164,51 @@
 hpibbus_attach_children(struct hpibbus_softc *sc)
 {
        struct hpibbus_attach_args ha;
-       int slave;
+       int id, slave, punit;
+       int i;
 
-       for (slave = 0; slave < 8; slave++) {
+       for (slave = 0; slave < HPIB_NSLAVES; slave++) {
                /*
                 * Get the ID tag for the device, if any.
                 * Plotters won't identify themselves, and
                 * get the same value as non-existent devices.
+                * However, aging HP-IB drives are slow to respond; try up
+                * to three times to get a valid ID.
                 */
-               ha.ha_id = hpibid(device_unit(sc->sc_dev), slave);
-
-               ha.ha_slave = slave;    /* not to be modified by children */
-               ha.ha_punit = 0;        /* children modify this */
+               for (i = 0; i < 3; i++) {
+                       id = hpibid(device_unit(sc->sc_dev), slave);
+                       if ((id & 0x200) != 0)
+                               break;
+                       delay(10000);
+               }
 
-               /*
-                * Search though all configured children for this bus.
-                */
-               config_search(sc->sc_dev, &ha,
-                   CFARG_SEARCH, hpibbussearch,
-                   CFARG_EOL);
+               for (punit = 0; punit < HPIB_NPUNITS; punit++) {
+                       /*
+                        * Search through all configured children for this bus.
+                        */
+                       ha.ha_id = id;
+                       ha.ha_slave = slave;
+                       ha.ha_punit = punit;
+                       config_found(sc->sc_dev, &ha, hpibbusprint,
+                           CFARG_SUBMATCH, hpibbussubmatch,
+                           CFARG_EOL);
+               }
        }
 }
 
 static int
-hpibbussearch(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
+hpibbussubmatch(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
 {
-       struct hpibbus_softc *sc = device_private(parent);
        struct hpibbus_attach_args *ha = aux;
 
-       /* Make sure this is in a consistent state. */
-       ha->ha_punit = 0;
+       if (cf->hpibbuscf_slave != HPIBBUSCF_SLAVE_DEFAULT &&
+           cf->hpibbuscf_slave != ha->ha_slave)
+               return 0;
+       if (cf->hpibbuscf_punit != HPIBBUSCF_PUNIT_DEFAULT &&
+           cf->hpibbuscf_punit != ha->ha_punit)
+               return 0;
 
-       if (config_probe(parent, cf, ha)) {
-               /*
-                * The device probe has succeeded, and filled in
-                * the punit information.  Make sure the configuration
-                * allows for this slave/punit combination.
-                */
-               if (cf->hpibbuscf_slave != HPIBBUSCF_SLAVE_DEFAULT &&
-                   cf->hpibbuscf_slave != ha->ha_slave)
-                       goto out;
-               if (cf->hpibbuscf_punit != HPIBBUSCF_PUNIT_DEFAULT &&
-                   cf->hpibbuscf_punit != ha->ha_punit)
-                       goto out;
-
-               /*
-                * Allocate the device's address from the bus's
-                * resource map.
-                */
-               if (hpibbus_alloc(sc, ha->ha_slave, ha->ha_punit))
-                       goto out;
-
-               /*
-                * This device is allowed; attach it.
-                */
-               config_attach(parent, cf, ha, hpibbusprint, CFARG_EOL);
-       }
- out:
-       return 0;
+       return config_match(parent, cf, aux);
 }
 
 static int
@@ -242,6 +216,11 @@
 {
        struct hpibbus_attach_args *ha = aux;
 
+       if (pnp != NULL) {
+               if (ha->ha_id == 0 || ha->ha_punit != 0 /* XXX */)
+                       return QUIET;
+               printf("HP-IB device (id %04X) at %s", ha->ha_id, pnp);
+       }
        aprint_normal(" slave %d punit %d", ha->ha_slave, ha->ha_punit);
        return UNCONF;
 }
@@ -418,36 +397,3 @@
 
        return (sc->sc_ops->hpib_intr)(arg);
 }
-
-static int
-hpibbus_alloc(struct hpibbus_softc *sc, int slave, int punit)
-{
-
-       if (slave >= HPIB_NSLAVES ||
-           punit >= HPIB_NPUNITS)
-               panic("hpibbus_alloc: device address out of range");
-
-       if (sc->sc_rmap[slave][punit] == 0) {
-               sc->sc_rmap[slave][punit] = 1;
-               return 0;
-       }
-       return 1;
-}
-
-#if 0
-static void
-hpibbus_free(struct hpibbus_softc *sc, int slave, int punit)
-{
-
-       if (slave >= HPIB_NSLAVES ||
-           punit >= HPIB_NPUNITS)
-               panic("hpibbus_free: device address out of range");
-
-#ifdef DIAGNOSTIC
-       if (sc->sc_rmap[slave][punit] == 0)
-               panic("hpibbus_free: not allocated");
-#endif
-
-       sc->sc_rmap[slave][punit] = 0;
-}
-#endif
diff -r e142c323f2e7 -r c72f7a1c1ace sys/arch/hp300/dev/hpibvar.h
--- a/sys/arch/hp300/dev/hpibvar.h      Mon Jul 05 13:41:08 2021 +0000
+++ b/sys/arch/hp300/dev/hpibvar.h      Mon Jul 05 14:03:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hpibvar.h,v 1.21 2012/10/13 06:12:23 tsutsui Exp $     */
+/*     $NetBSD: hpibvar.h,v 1.22 2021/07/05 14:03:46 tsutsui Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -174,12 +174,6 @@
        char    *sc_addr;
        int     sc_count;
        int     sc_curcnt;
-
-       /*
-        * HP-IB is an indirect bus; this cheezy resource map
-        * keeps track of slave/punit allocations.
-        */
-       char    sc_rmap[HPIB_NSLAVES][HPIB_NPUNITS];
 };
 
 /* sc_flags */
diff -r e142c323f2e7 -r c72f7a1c1ace sys/arch/hp300/dev/mt.c
--- a/sys/arch/hp300/dev/mt.c   Mon Jul 05 13:41:08 2021 +0000
+++ b/sys/arch/hp300/dev/mt.c   Mon Jul 05 14:03:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mt.c,v 1.54 2014/07/25 08:10:33 dholland Exp $ */
+/*     $NetBSD: mt.c,v 1.55 2021/07/05 14:03:46 tsutsui Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mt.c,v 1.54 2014/07/25 08:10:33 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mt.c,v 1.55 2021/07/05 14:03:46 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -224,7 +224,8 @@
        int i;
 
        for (i = 0; i < nmtinfo; i++) {
-               if (ha->ha_id == mtinfo[i].hwid) {
+               if (ha->ha_id == mtinfo[i].hwid &&
+                   ha->ha_punit == 0) {
                        if (sc != NULL) {
                                sc->sc_type = mtinfo[i].hwid;
                                aprint_normal(": %s tape\n", mtinfo[i].desc);
diff -r e142c323f2e7 -r c72f7a1c1ace sys/arch/hp300/dev/rd.c
--- a/sys/arch/hp300/dev/rd.c   Mon Jul 05 13:41:08 2021 +0000
+++ b/sys/arch/hp300/dev/rd.c   Mon Jul 05 14:03:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rd.c,v 1.104 2021/06/30 14:54:03 tsutsui Exp $ */
+/*     $NetBSD: rd.c,v 1.105 2021/07/05 14:03:46 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.104 2021/06/30 14:54:03 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.105 2021/07/05 14:03:46 tsutsui Exp $");
 
 #include "opt_useleds.h"



Home | Main Index | Thread Index | Old Index