Source-Changes-HG archive

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

[src/netbsd-9]: src Pull up following revision(s) (requested by tsutsui in ti...



details:   https://anonhg.NetBSD.org/src/rev/ba9fa2ff54ce
branches:  netbsd-9
changeset: 984638:ba9fa2ff54ce
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Jul 14 18:04:04 2021 +0000

description:
Pull up following revision(s) (requested by tsutsui in ticket #1323):

        sys/arch/hp300/dev/rd.c: revision 1.109
        sys/arch/hp300/stand/Makefile.buildboot: revision 1.37
        sys/arch/hp300/stand/common/ct.c: revision 1.8
        sys/arch/hp300/dev/hpibvar.h: revision 1.22
        sys/arch/hp300/dev/ct.c: revision 1.62
        sys/arch/hp300/dev/hpibvar.h: revision 1.23
        sys/arch/hp300/dev/ct.c: revision 1.63
        sys/arch/hp300/dev/hpibvar.h: revision 1.24
        sys/arch/hp300/dev/mt.c: revision 1.55
        sys/arch/hp300/dev/rdreg.h: revision 1.14
        sys/arch/hp300/dev/hpib.c: revision 1.43 (via patch)
        sys/arch/hp300/dev/rdreg.h: revision 1.15
        sys/arch/hp300/dev/rdreg.h: revision 1.16
        sys/arch/hp300/dev/rdreg.h: revision 1.17
        etc/etc.hp300/MAKEDEV.conf: revision 1.15
        sys/arch/hp300/stand/common/hpibvar.h: revision 1.6
        sys/arch/hp300/stand/common/rd.c: revision 1.11
        sys/arch/hp300/dev/ctreg.h: revision 1.11
        sys/arch/hp300/dev/rdvar.h: revision 1.24
        sys/arch/hp300/dev/rdvar.h: revision 1.25
        sys/arch/hp300/dev/rdvar.h: revision 1.26
        sys/arch/hp300/dev/rd.c: revision 1.103
        sys/arch/hp300/dev/rd.c: revision 1.104
        sys/arch/hp300/dev/rd.c: revision 1.105
        sys/arch/hp300/dev/rd.c: revision 1.106
        sys/arch/hp300/dev/rd.c: revision 1.107
        sys/arch/hp300/dev/rd.c: revision 1.108

Consistently use #define<tab> here.

Consistently use #define<tab> as rdreg.h.

No need to bother to use aprint_debug(9) inside #ifdef DEBUG block.

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.

Move attach messages from common rdident() to explicit rdattach().

Cleanup duplicated CS/80 indentify structures.  From OpenBSD.
https://marc.info/?l=openbsd-cvs&m=113227249626888&w=2

Define the CS/80 identify structure only once and correctly, instead of
duplicating it in every CS/80 driver and using an hardcoded number for
its size.
No functional change.
https://marc.info/?l=openbsd-cvs&m=113273001020159&w=2

Pick HP-IB describe structures changes from main kernel code here as well.

Add support of multiple rd(4) disks on all punits for HPDisk.

Special thanks to Anders Gustafsson, the author of "HPDisk"
(GPIB disk emulator) http://www.dalton.ax/hpdisk/
for providing bare boards and improving firmwares for NetBSD/hp300.

Specify -fno-unwind-tables to shrink binaries.

Before:
   text    data     bss     dec     hex filename
  77902    4328  137120  219350   358d6 uboot

After:
   text    data     bss     dec     hex filename
  64186    4328  137120  205634   32342 uboot

Create rd3 device nodes, for HPDisk.

Add Device and drive info of 2202A, 7908A, 7911A, and 7941A.

Geometries and description info are taken from hpdrive.ini.sample
in HPDrive.  Briefly tested on HPDisk.

Print rd(4) capacity and geometry info as sd(4) and wd(4) do.

Before:
rd0 at hpibbus1 slave 0 punit 0: 7937H
rd0: 698 cylinders, 13 heads, 1116102 blocks, 512 bytes/block

After:
rd0 at hpibbus1 slave 0 punit 0: 7937H
rd0: 544 MB, 698 cyl, 13 head, 123 sec, 512 bytes/block x 1116102 blocks

diffstat:

 etc/etc.hp300/MAKEDEV.conf              |    6 +-
 sys/arch/hp300/dev/ct.c                 |   16 +-
 sys/arch/hp300/dev/ctreg.h              |   26 +--
 sys/arch/hp300/dev/hpib.c               |  133 +++-------
 sys/arch/hp300/dev/hpibvar.h            |   43 ++-
 sys/arch/hp300/dev/mt.c                 |    7 +-
 sys/arch/hp300/dev/rd.c                 |  390 ++++++++++++++++++++++++-------
 sys/arch/hp300/dev/rdreg.h              |  142 ++++++----
 sys/arch/hp300/dev/rdvar.h              |   22 +-
 sys/arch/hp300/stand/Makefile.buildboot |    4 +-
 sys/arch/hp300/stand/common/ct.c        |    6 +-
 sys/arch/hp300/stand/common/hpibvar.h   |   18 +-
 sys/arch/hp300/stand/common/rd.c        |    6 +-
 13 files changed, 491 insertions(+), 328 deletions(-)

diffs (truncated from 1358 to 300 lines):

diff -r 09457e4379b5 -r ba9fa2ff54ce etc/etc.hp300/MAKEDEV.conf
--- a/etc/etc.hp300/MAKEDEV.conf        Wed Jul 14 17:52:31 2021 +0000
+++ b/etc/etc.hp300/MAKEDEV.conf        Wed Jul 14 18:04:04 2021 +0000
@@ -1,7 +1,7 @@
-#      $NetBSD: MAKEDEV.conf,v 1.14 2013/04/28 08:08:04 tsutsui Exp $
+#      $NetBSD: MAKEDEV.conf,v 1.14.32.1 2021/07/14 18:04:04 martin Exp $
 
 all_md)
-       makedev ct0 ct1 rd0 rd1 rd2
+       makedev ct0 ct1 rd0 rd1 rd2 rd3
        makedev wscons
        makedev sd0 sd1 sd2 cd0 cd1 st0 st1 ch0
        makedev ttyC0 ttyC1 ttyC2 ttyC3
@@ -15,7 +15,7 @@
 ramdisk)
        makedev std
        makedev md0
-       makedev ct0 ct1 rd0 rd1 rd2
+       makedev ct0 ct1 rd0 rd1 rd2 rd3
        makedev sd0 sd1 sd2 cd0 cd1 st0 st1 ch0
        makedev scsibus0
        makedev ipty
diff -r 09457e4379b5 -r ba9fa2ff54ce sys/arch/hp300/dev/ct.c
--- a/sys/arch/hp300/dev/ct.c   Wed Jul 14 17:52:31 2021 +0000
+++ b/sys/arch/hp300/dev/ct.c   Wed Jul 14 18:04:04 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.61.32.1 2021/07/14 18:04:04 martin 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.61.32.1 2021/07/14 18:04:04 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -257,7 +257,7 @@
 static int
 ctident(device_t parent, struct ct_softc *sc, struct hpibbus_attach_args *ha)
 {
-       struct ct_describe desc;
+       struct cs80_describe desc;
        u_char stat, cmd[3];
        char name[7];
        int i, id, n, type, canstream;
@@ -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.
@@ -285,9 +284,10 @@
        cmd[1] = C_SVOL(0);
        cmd[2] = C_DESC;
        hpibsend(device_unit(parent), ha->ha_slave, C_CMD, cmd, sizeof(cmd));
-       hpibrecv(device_unit(parent), ha->ha_slave, C_EXEC, &desc, 37);
+       hpibrecv(device_unit(parent), ha->ha_slave, C_EXEC, &desc,
+           sizeof(desc));
        hpibrecv(device_unit(parent), ha->ha_slave, C_QSTAT, &stat,
-                sizeof(stat));
+           sizeof(stat));
 
        memset(name, 0, sizeof(name));
        if (stat == 0) {
diff -r 09457e4379b5 -r ba9fa2ff54ce sys/arch/hp300/dev/ctreg.h
--- a/sys/arch/hp300/dev/ctreg.h        Wed Jul 14 17:52:31 2021 +0000
+++ b/sys/arch/hp300/dev/ctreg.h        Wed Jul 14 18:04:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ctreg.h,v 1.10 2005/12/11 12:17:13 christos Exp $      */
+/*     $NetBSD: ctreg.h,v 1.10.170.1 2021/07/14 18:04:04 martin Exp $  */
 
 /*
  * Copyright (c) 1982, 1990, 1993
@@ -98,30 +98,6 @@
        char    cmd;
 };
 
-struct ct_describe {
-       u_int   d_iuw:16,       /* controller: installed unit word */
-               d_cmaxxfr:16,   /* controller: max transfer rate (Kb) */
-               d_ctype:8,      /* controller: controller type */
-               d_utype:8,      /* unit: unit type */
-               d_name:24,      /* unit: name (6 BCD digits) */
-               d_sectsize:16,  /* unit: # of bytes per block (sector) */
-               d_blkbuf:8,     /* unit: # of blocks which can be buffered */
-               d_burstsize:8,  /* unit: recommended burst size */
-               d_blocktime:16, /* unit: block time (u-sec) */
-               d_uavexfr:16,   /* unit: average transfer rate (Kb) */
-               d_retry:16,     /* unit: optimal retry time (1/100-sec) */
-               d_access:16,    /* unit: access time param (1/100-sec) */
-               d_maxint:8,     /* unit: maximum interleave */
-               d_fvbyte:8,     /* unit: fixed volume byte */
-               d_rvbyte:8,     /* unit: removable volume byte */
-               d_maxcyl:24,    /* volume: maximum cylinder */
-               d_maxhead:8,    /* volume: maximum head */
-               d_maxsect:16,   /* volume: maximum sector on track */
-               d_maxvsecth:16, /* volume: maximum sector on volume (MSW) */
-               d_maxvsectl:32, /* volume: maximum sector on volume (LSWs) */
-               d_interleave:8; /* volume: current interleave */
- };
-
 #define        CT7946ID        0x220
 #define CT9145ID       0x268
 #define        CT9144ID        0x260
diff -r 09457e4379b5 -r ba9fa2ff54ce sys/arch/hp300/dev/hpib.c
--- a/sys/arch/hp300/dev/hpib.c Wed Jul 14 17:52:31 2021 +0000
+++ b/sys/arch/hp300/dev/hpib.c Wed Jul 14 18:04:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hpib.c,v 1.39 2012/10/13 06:12:23 tsutsui Exp $        */
+/*     $NetBSD: hpib.c,v 1.39.42.1 2021/07/14 18:04:04 martin 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.39 2012/10/13 06:12:23 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpib.c,v 1.39.42.1 2021/07/14 18:04:04 martin 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
@@ -181,62 +168,50 @@
 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);
+               for (i = 0; i < 3; i++) {
+                       id = hpibid(device_unit(sc->sc_dev), slave);
+                       if ((id & 0x200) != 0)
+                               break;
+                       delay(10000);
+               }
 
-               ha.ha_slave = slave;    /* not to be modified by children */
-               ha.ha_punit = 0;        /* children modify this */
-
-               /*
-                * Search though all configured children for this bus.
-                */
-               config_search_ia(hpibbussearch, sc->sc_dev, "hpibbus", &ha);
+               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_loc(sc->sc_dev, "hpibbus", NULL,
+                           &ha, hpibbusprint, hpibbussubmatch);
+               }
        }
 }
 
 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_match(parent, cf, ha) > 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 != 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);
-       }
- out:
-       return 0;
+       return config_match(parent, cf, aux);
 }
 
 static int
@@ -244,6 +219,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;
 }
@@ -420,36 +400,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)



Home | Main Index | Thread Index | Old Index