Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64/sparc64 Remove old-style boot device recogn...



details:   https://anonhg.NetBSD.org/src/rev/4d81619098f1
branches:  trunk
changeset: 480519:4d81619098f1
user:      pk <pk%NetBSD.org@localhost>
date:      Fri Jan 14 14:57:27 2000 +0000

description:
Remove old-style boot device recognition.
Sync device_register() et. al. with sparc/sparc/autoconf.c

diffstat:

 sys/arch/sparc64/sparc64/autoconf.c |  215 +++++++++++++++++------------------
 1 files changed, 104 insertions(+), 111 deletions(-)

diffs (truncated from 379 to 300 lines):

diff -r b60efed2b2ff -r 4d81619098f1 sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c       Fri Jan 14 14:39:13 2000 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c       Fri Jan 14 14:57:27 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.24 1999/11/21 11:47:51 pk Exp $ */
+/*     $NetBSD: autoconf.c,v 1.25 2000/01/14 14:57:27 pk Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -392,23 +392,6 @@
        return (retval);
 }
 
-/* TEMP: */
-struct bootpath *altbootpath_store(int, struct bootpath *);
-struct bootpath *
-altbootpath_store(storep, bp)
-       int storep;
-       struct bootpath *bp;
-{
-       static struct bootpath *save;
-       struct bootpath *retval;
-
-       retval = save;
-       if (storep)
-               save = bp;
-       return (retval);
-}
-/* END TEMP */
-
 /*
  * Set up the sd target mappings for non SUN4 PROMs.
  * Find out about the real SCSI target, given the PROM's idea of the
@@ -503,7 +486,6 @@
        (void)spl0();
 }
 
-struct device *altbootdev;
 
 void
 cpu_rootconf()
@@ -514,28 +496,7 @@
 
        bp = nbootpath == 0 ? NULL : &bootpath[nbootpath-1];
        bootdv = bp == NULL ? NULL : bp->dev;
-       bootpartition = bp == NULL ? 0 : bp->val[2];
-#if 1
-       /*
-        * Old bootpath code no longer works now that SCSI autoconfiguration
-        * can be delayed.  device_register() is the One True Way.
-        */
-       bootdv = altbootdev;
-#else
-       if (bootdv != altbootdev) {
-               int c;
-               printf("device_register boot device mismatch\n");
-               printf("\tbootdv=%s\n",
-                       bootdv==NULL?"NOT FOUND":bootdv->dv_xname);
-               printf("\taltbootdev=%s\n",
-                       altbootdev==NULL?"NOT FOUND":altbootdev->dv_xname);
-               printf("RETURN to continue ");
-               cnpollc(1);
-               while ((c = cngetc()) != '\r' && c != '\n');
-               printf("\n");
-               cnpollc(0);
-       }
-#endif
+       bootpartition = bootdv == NULL ? 0 : bp->val[2];
 
        setroot(bootdv, bootpartition);
 }
@@ -681,7 +642,7 @@
        node = findroot();
 
        /* Establish the first component of the boot path */
-       altbootpath_store(1, bootpath);
+       bootpath_store(1, bootpath);
 
        /* the first early device to be configured is the cpu */
        {
@@ -754,8 +715,6 @@
                        free(ma.ma_interrupts, M_DEVBUF);
                        continue;
                }
-               /* Start at the beginning of the bootpath */
-               ma.ma_bp = bootpath;
 
                if (config_found(dev, (void *)&ma, mbprint) == NULL)
                        panic(sp);
@@ -1036,15 +995,19 @@
 #include <dev/scsipi/scsipi_all.h>
 #include <dev/scsipi/scsiconf.h>
 
-#define BUSCLASS_GENERIC       0
+#define BUSCLASS_NONE          0
 #define BUSCLASS_MAINBUS       1
 #define BUSCLASS_IOMMU         2
 #define BUSCLASS_OBIO          3
 #define BUSCLASS_SBUS          4
 #define BUSCLASS_VME           5
 #define BUSCLASS_PCI           6
+#define BUSCLASS_XDC           7
+#define BUSCLASS_XYC           8
+#define BUSCLASS_FDC           9
 
 static int bus_class __P((struct device *));
+static char *bus_compatible __P((char *));
 static int instance_match __P((struct device *, void *, struct bootpath *));
 static void nail_bootdev __P((struct device *, struct bootpath *));
 
@@ -1065,18 +1028,54 @@
        { "psycho",     BUSCLASS_PCI },
        { "simba",      BUSCLASS_PCI },
        { "pciide",     BUSCLASS_PCI },
-       { "vme",        BUSCLASS_VME }
+       { "pci",        BUSCLASS_PCI },
+       { "vme",        BUSCLASS_VME },
+       { "xdc",        BUSCLASS_XDC },
+       { "xyc",        BUSCLASS_XYC },
+       { "fdc",        BUSCLASS_FDC },
 };
 
+/*
+ * A list of PROM device names that differ from our NetBSD
+ * device names.
+ */
+static struct {
+       char    *bpname;
+       char    *cfname;
+} dev_compat_tab[] = {
+       { "espdma",     "dma" },
+       { "QLGC,isp",   "isp" },
+       { "PTI,isp",    "isp" },
+       { "ptisp",      "isp" },
+       { "SUNW,fdtwo", "fdc" },
+};
+
+static char *
+bus_compatible(bpname)
+       char *bpname;
+{
+       int i;
+
+       for (i = sizeof(dev_compat_tab)/sizeof(dev_compat_tab[0]); i-- > 0;) {
+               if (strcmp(bpname, dev_compat_tab[i].bpname) == 0)
+                       return (dev_compat_tab[i].cfname);
+       }
+
+       return (bpname);
+}
+
 static int
 bus_class(dev)
        struct device *dev;
 {
-       struct device *parent = dev->dv_parent;
-       char *name = parent->dv_cfdata->cf_driver->cd_name;
+       char *name;
        int i, class;
 
-       class = BUSCLASS_GENERIC;
+       class = BUSCLASS_NONE;
+       if (dev == NULL)
+               return (class);
+
+       name = dev->dv_cfdata->cf_driver->cd_name;
        for (i = sizeof(bus_class_tab)/sizeof(bus_class_tab[0]); i-- > 0;) {
                if (strcmp(name, bus_class_tab[i].name) == 0) {
                        class = bus_class_tab[i].class;
@@ -1084,10 +1083,6 @@
                }
        }
 
-       /* sun4m obio special case */
-       if (CPU_ISSUN4M && class == BUSCLASS_OBIO)
-               class = BUSCLASS_SBUS;
-
        return (class);
 }
 
@@ -1102,19 +1097,22 @@
        struct pci_attach_args *pa;
 
        /*
-        * Several Sbus devices are represented on bootpaths in one of
-        * two formats:
+        * Several devices are represented on bootpaths in one of
+        * two formats, e.g.:
         *      (1) ../sbus@.../esp@<offset>,<slot>/sd@..  (PROM v3 style)
         *      (2) /sbus0/esp0/sd@..                      (PROM v2 style)
         *
-        * hence we fall back on a `unit number' check if the Sbus-specific
+        * hence we fall back on a `unit number' check if the bus-specific
         * instance parameter check does not produce a match.
         *
         * For PCI devices, we get:
         *      ../pci@../xxx@<dev>,<fn>/...
         */
 
-       switch (bus_class(dev)) {
+       /*
+        * Rank parent bus so we know which locators to check.
+        */
+       switch (bus_class(dev->dv_parent)) {
        case BUSCLASS_MAINBUS:
                ma = aux;
                if (bp->val[0] == ma->ma_upaid)
@@ -1131,6 +1129,20 @@
                    bp->val[1] == pa->pa_function)
                        return (1);
                break;
+       case BUSCLASS_XDC:
+       case BUSCLASS_XYC:
+               {
+               /*
+                * XXX - x[dy]c attach args are not exported right now..
+                * XXX   we happen to know they look like this:
+                */
+               struct xxxx_attach_args { int driveno; } *aap = aux;
+
+               if (aap->driveno == bp->val[0])
+                       return (1);
+
+               }
+               break;
        default:
                break;
        }
@@ -1146,18 +1158,23 @@
        struct device *dev;
        struct bootpath *bp;
 {
-       /*bp->dev = dev;        -* got it! */
-       if (altbootdev != NULL)
+
+       if (bp->dev != NULL)
                panic("device_register: already got a boot device: %s",
-                       altbootdev->dv_xname);
-       altbootdev = dev;
+                       bp->dev->dv_xname);
 
        /*
-        * Clear current bootpath component, so we don't spuriously
+        * Mark this bootpath component by linking it to the matched
+        * device. We pick up the device pointer in cpu_rootconf().
+        */
+       bp->dev = dev;
+
+       /*
+        * Then clear the current bootpath component, so we don't spuriously
         * match similar instances on other busses, e.g. a disk on
         * another SCSI bus with the same target.
         */
-       altbootpath_store(1, NULL);
+       bootpath_store(1, NULL);
 }
 
 void
@@ -1165,8 +1182,8 @@
        struct device *dev;
        void *aux;
 {
-       struct bootpath *bp = altbootpath_store(0, NULL);
-       char *dvname = dev->dv_cfdata->cf_driver->cd_name;
+       struct bootpath *bp = bootpath_store(0, NULL);
+       char *dvname, *bpname;
 
        /*
         * If device name does not match current bootpath component
@@ -1175,34 +1192,23 @@
        if (bp == NULL)
                return;
 
-       if (strcmp(bp->name, "espdma") == 0) {
-               /* espdma special case */
-               if (strcmp(dvname, "dma") != 0)
-                       return;
-       } else if (strcmp(dvname, bp->name) != 0)
+       /*
+        * Translate PROM name in case our drivers are named differently
+        */
+       bpname = bus_compatible(bp->name);
+
+       /* First, match by name */
+       dvname = dev->dv_cfdata->cf_driver->cd_name;
+       if (strcmp(dvname, bpname) != 0)
                return;
 
-       if (strcmp(dvname, "obio") == 0 ||
-           strcmp(dvname, "vme") == 0 ||
-           strcmp(dvname, "iommu") == 0 ||
-           strcmp(dvname, "sbus") == 0 ||
-           strcmp(dvname, "xbox") == 0 ||
-           strcmp(dvname, "dma") == 0 ||
-           strcmp(dvname, "ledma") == 0 ||
-           strcmp(dvname, "espdma") == 0 ||
-           strcmp(dvname, "esp") == 0 ||
-           strcmp(dvname, "pci") == 0 ||
-           strcmp(dvname, "pciide") == 0 ||
-           strcmp(dvname, "psycho") == 0 ||



Home | Main Index | Thread Index | Old Index