summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2005-11-16 21:23:56 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2005-11-16 21:23:56 +0000
commit0d1aa5f96a850ba0cf8fd63ad83371a0ff327735 (patch)
tree9a423e846e7063c82aeeb25b8953db734935da63 /sys/arch
parent16a5da772a487189e3873a0910c24b232b1c1104 (diff)
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 us to get rid of the hpibbus resource map and related functions.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/hp300/dev/ct.c9
-rw-r--r--sys/arch/hp300/dev/hd.c30
-rw-r--r--sys/arch/hp300/dev/hpib.c129
-rw-r--r--sys/arch/hp300/dev/hpibvar.h10
-rw-r--r--sys/arch/hp300/dev/mt.c5
5 files changed, 50 insertions, 133 deletions
diff --git a/sys/arch/hp300/dev/ct.c b/sys/arch/hp300/dev/ct.c
index 93cfa3eccb0..10b453964a9 100644
--- a/sys/arch/hp300/dev/ct.c
+++ b/sys/arch/hp300/dev/ct.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ct.c,v 1.11 2005/01/15 21:13:08 miod Exp $ */
+/* $OpenBSD: ct.c,v 1.12 2005/11/16 21:23:55 miod Exp $ */
/* $NetBSD: ct.c,v 1.21 1997/04/02 22:37:23 scottr Exp $ */
/*
@@ -134,7 +134,7 @@ void ctcommand(dev_t, int, int);
cdev_decl(ct);
bdev_decl(ct);
-struct ctinfo {
+const struct ctinfo {
short hwid;
short punit;
char *desc;
@@ -217,13 +217,12 @@ ctident(parent, sc, ha)
/* 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 --git a/sys/arch/hp300/dev/hd.c b/sys/arch/hp300/dev/hd.c
index 6b2258a068a..9a9a83d01c7 100644
--- a/sys/arch/hp300/dev/hd.c
+++ b/sys/arch/hp300/dev/hd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hd.c,v 1.34 2005/11/15 21:09:44 miod Exp $ */
+/* $OpenBSD: hd.c,v 1.35 2005/11/16 21:23:55 miod Exp $ */
/* $NetBSD: rd.c,v 1.33 1997/07/10 18:14:08 kleink Exp $ */
/*
@@ -162,13 +162,13 @@ const char *err_info[16] = {
NULL
};
-int hddebug = 0x80;
#define HDB_FOLLOW 0x01
#define HDB_STATUS 0x02
#define HDB_IDENT 0x04
#define HDB_IO 0x08
#define HDB_ASYNC 0x10
#define HDB_ERROR 0x80
+int hddebug = HDB_ERROR | HDB_IDENT;
#endif
/*
@@ -271,28 +271,9 @@ hdmatch(parent, match, aux)
struct device *parent;
void *match, *aux;
{
- struct cfdata *cf = match;
struct hpibbus_attach_args *ha = aux;
- /*
- * Set punit if operator specified one in the kernel
- * configuration file.
- */
- if (cf->hpibbuscf_punit != HPIBBUS_PUNIT_UNK &&
- cf->hpibbuscf_punit < HPIB_NPUNITS)
- ha->ha_punit = cf->hpibbuscf_punit;
-
- if (hdident(parent, NULL, ha) == 0) {
- /*
- * XXX Some aging HP-IB drives are slow to
- * XXX respond; give them a chance to catch
- * XXX up and probe them again.
- */
- delay(10000);
- ha->ha_id = hpibid(parent->dv_unit, ha->ha_slave);
- return (hdident(parent, NULL, ha));
- }
- return (1);
+ return (hdident(parent, NULL, ha));
}
void
@@ -359,9 +340,10 @@ hdident(parent, sc, ha)
/* Is it one of the disks we support? */
for (id = 0; id < numhdidentinfo; id++)
- if (ha->ha_id == hdidentinfo[id].ri_hwid)
+ if (ha->ha_id == hdidentinfo[id].ri_hwid &&
+ ha->ha_punit <= hdidentinfo[id].ri_maxunum)
break;
- if (id == numhdidentinfo || ha->ha_punit > hdidentinfo[id].ri_maxunum)
+ if (id == numhdidentinfo)
return (0);
/*
diff --git a/sys/arch/hp300/dev/hpib.c b/sys/arch/hp300/dev/hpib.c
index f8a39b5d85f..703158a0051 100644
--- a/sys/arch/hp300/dev/hpib.c
+++ b/sys/arch/hp300/dev/hpib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hpib.c,v 1.12 2005/11/14 20:21:42 miod Exp $ */
+/* $OpenBSD: hpib.c,v 1.13 2005/11/16 21:23:55 miod Exp $ */
/* $NetBSD: hpib.c,v 1.16 1997/04/27 20:58:57 thorpej Exp $ */
/*
@@ -62,12 +62,9 @@ struct cfdriver hpibbus_cd = {
};
void hpibbus_attach_children(struct hpibbus_softc *);
-int hpibbussearch(struct device *, void *, void *);
+int hpibbussubmatch(struct device *, void *, void *);
int hpibbusprint(void *, const char *);
-int hpibbus_alloc(struct hpibbus_softc *, int, int);
-void hpibbus_free(struct hpibbus_softc *, int, int);
-
void hpibstart(void *);
void hpibdone(void *);
@@ -82,7 +79,7 @@ int hpibdmathresh = 3; /* byte count beyond which to attempt dma */
* probably Amigo, too) are tagged with a 16-bit ID.
*
* HP-IB has a 2-level addressing scheme; slave, the analog
- * of a SCSI ID, and punit, the analog of a SCSI LUN. Unforunately,
+ * of a SCSI ID, and punit, the analog of a SCSI LUN. Unfortunately,
* IDs are on a per-slave basis; punits are often used for disk
* drives that have an accompanying tape drive on the second punit.
*
@@ -92,17 +89,9 @@ int hpibdmathresh = 3; /* byte count beyond which to attempt dma */
* 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.
*/
int
@@ -157,63 +146,52 @@ hpibbus_attach_children(sc)
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(sc->sc_dev.dv_unit, 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(sc->sc_dev.dv_unit, slave);
+ if ((id & 0x200) != 0)
+ break;
+ delay(10000);
+ }
- /*
- * Search though all configured children for this bus.
- */
- (void)config_found_sm(&sc->sc_dev, &ha, hpibbusprint,
- hpibbussearch);
+ 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;
+ (void)config_found_sm(&sc->sc_dev, &ha, hpibbusprint,
+ hpibbussubmatch);
+ }
}
}
int
-hpibbussearch(parent, match, aux)
+hpibbussubmatch(parent, match, aux)
struct device *parent;
void *match, *aux;
{
struct cfdata *cf = match;
- struct hpibbus_softc *sc = (struct hpibbus_softc *)parent;
struct hpibbus_attach_args *ha = aux;
- int pri;
-
- /* Make sure this is in a consistent state. */
- ha->ha_punit = 0;
- pri = (*cf->cf_attach->ca_match)(parent, cf, ha);
- if (pri > 0) {
- /*
- * 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 != HPIBBUS_SLAVE_UNK &&
- cf->hpibbuscf_slave != ha->ha_slave)
- return (0);
- if (cf->hpibbuscf_punit != HPIBBUS_PUNIT_UNK &&
- cf->hpibbuscf_punit != ha->ha_punit)
- return (0);
-
- /*
- * Allocate the device's address from the bus's
- * resource map.
- */
- if (hpibbus_alloc(sc, ha->ha_slave, ha->ha_punit))
- return (0);
- }
-
- return (pri);
+ if (cf->hpibbuscf_slave != HPIBBUS_SLAVE_UNK &&
+ cf->hpibbuscf_slave != ha->ha_slave)
+ return (0);
+ if (cf->hpibbuscf_punit != HPIBBUS_PUNIT_UNK &&
+ cf->hpibbuscf_punit != ha->ha_punit)
+ return (0);
+ return ((*cf->cf_attach->ca_match)(parent, match, aux));
}
int
@@ -224,7 +202,7 @@ hpibbusprint(aux, pnp)
struct hpibbus_attach_args *ha = aux;
if (pnp != NULL) {
- if (ha->ha_id == 0)
+ if (ha->ha_id == 0 || ha->ha_punit != 0 /* XXX */)
return (QUIET);
printf("HP-IB device (id %04X) at %s", ha->ha_id, pnp);
}
@@ -429,38 +407,3 @@ hpibintr(arg)
return ((sc->sc_ops->hpib_intr)(arg));
}
-
-int
-hpibbus_alloc(sc, slave, punit)
- struct hpibbus_softc *sc;
- int slave, 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);
-}
-
-void
-hpibbus_free(sc, slave, punit)
- struct hpibbus_softc *sc;
- int slave, 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;
-}
diff --git a/sys/arch/hp300/dev/hpibvar.h b/sys/arch/hp300/dev/hpibvar.h
index 70c1e40587d..c0bb1c41357 100644
--- a/sys/arch/hp300/dev/hpibvar.h
+++ b/sys/arch/hp300/dev/hpibvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hpibvar.h,v 1.8 2003/06/02 23:27:44 millert Exp $ */
+/* $OpenBSD: hpibvar.h,v 1.9 2005/11/16 21:23:55 miod Exp $ */
/* $NetBSD: hpibvar.h,v 1.10 1997/03/31 07:34:25 scottr Exp $ */
/*
@@ -148,12 +148,6 @@ struct hpibbus_softc {
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 */
@@ -184,8 +178,6 @@ int hpibid(int, int);
int hpibreq(struct device *, struct hpibqueue *);
void hpibfree(struct device *, struct hpibqueue *);
-int hpibbus_alloc(struct hpibbus_softc *, int, int);
-void hpibbus_free(struct hpibbus_softc *, int, int);
int hpibintr(void *);
int hpibdevprint(void *, const char *);
diff --git a/sys/arch/hp300/dev/mt.c b/sys/arch/hp300/dev/mt.c
index d25c9617baf..338f818afc0 100644
--- a/sys/arch/hp300/dev/mt.c
+++ b/sys/arch/hp300/dev/mt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mt.c,v 1.13 2005/01/15 21:13:08 miod Exp $ */
+/* $OpenBSD: mt.c,v 1.14 2005/11/16 21:23:55 miod Exp $ */
/* $NetBSD: mt.c,v 1.8 1997/03/31 07:37:29 scottr Exp $ */
/*
@@ -173,7 +173,8 @@ mtident(sc, ha)
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;
printf(": %s tape\n", mtinfo[i].desc);