Source-Changes-HG archive

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

[src/trunk]: src/sys Make detection of root on wedges (dk(4)) machine indepen...



details:   https://anonhg.NetBSD.org/src/rev/2e991408bd7a
branches:  trunk
changeset: 779683:2e991408bd7a
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Jun 10 17:05:18 2012 +0000

description:
Make detection of root on wedges (dk(4)) machine independent. Remove
MD code for x86, xen, sparc64.

diffstat:

 sys/arch/sparc64/sparc64/autoconf.c |    9 +-
 sys/arch/x86/x86/x86_autoconf.c     |   42 ++++------
 sys/arch/xen/x86/autoconf.c         |   29 +------
 sys/dev/dkwedge/dk.c                |  129 ++++++++---------------------------
 sys/kern/init_main.c                |   75 ++++++++++++++++++++-
 sys/kern/kern_subr.c                |   10 +-
 sys/sys/device.h                    |    8 +-
 sys/sys/disk.h                      |    4 +-
 8 files changed, 141 insertions(+), 165 deletions(-)

diffs (truncated from 553 to 300 lines):

diff -r 75a4b1e68db9 -r 2e991408bd7a sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c       Sun Jun 10 15:04:47 2012 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c       Sun Jun 10 17:05:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.186 2012/05/28 19:24:30 martin Exp $ */
+/*     $NetBSD: autoconf.c,v 1.187 2012/06/10 17:05:18 mlelstv Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.186 2012/05/28 19:24:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.187 2012/06/10 17:05:18 mlelstv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -508,10 +508,7 @@
                return;
        }
 
-       if (config_handle_wedges(booted_device, booted_partition) == 0)
-               setroot(booted_wedge, 0);
-       else
-               setroot(booted_device, booted_partition);
+       setroot(booted_device, booted_partition);
 }
 
 char *
diff -r 75a4b1e68db9 -r 2e991408bd7a sys/arch/x86/x86/x86_autoconf.c
--- a/sys/arch/x86/x86/x86_autoconf.c   Sun Jun 10 15:04:47 2012 +0000
+++ b/sys/arch/x86/x86/x86_autoconf.c   Sun Jun 10 17:05:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_autoconf.c,v 1.62 2011/10/18 23:43:36 dyoung Exp $ */
+/*     $NetBSD: x86_autoconf.c,v 1.63 2012/06/10 17:05:18 mlelstv Exp $        */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.62 2011/10/18 23:43:36 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.63 2012/06/10 17:05:18 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -64,15 +64,6 @@
 struct disklist *x86_alldisks;
 int x86_ndisks;
 
-static void
-handle_wedges(device_t dv, int par)
-{
-       if (config_handle_wedges(dv, par) == 0)
-               return;
-       booted_device = dv;
-       booted_partition = par;
-}
-
 static int
 is_valid_disk(device_t dv)
 {
@@ -344,7 +335,9 @@
 
                        if (strncmp(cd->cf_name, biv->devname, len) == 0 &&
                            biv->devname[len] - '0' == device_unit(dv)) {
-                               handle_wedges(dv, biv->devname[len + 1] - 'a');
+                               booted_device = dv;
+                               booted_partition = biv->devname[len + 1] - 'a';
+                               booted_nblks = 0;
                                break;
                        }
                }
@@ -388,11 +381,14 @@
                                    device_xname(dv));
                                continue;
                        }
-                       dkwedge_set_bootwedge(dv, biw->startblk, biw->nblks);
+                       booted_device = dv;
+                       booted_partition = 0;
+                       booted_nblks = biw->nblks;
+                       booted_startblk = biw->startblk;
                }
                deviter_release(&di);
 
-               if (booted_wedge)
+               if (booted_nblks)
                        return;
        }
 
@@ -445,7 +441,9 @@
                                    device_xname(dv));
                                continue;
                        }
-                       handle_wedges(dv, bid->partition);
+                       booted_device = dv;
+                       booted_partition = bid->partition;
+                       booted_nblks = 0;
                }
                deviter_release(&di);
 
@@ -477,6 +475,7 @@
                                    device_is_a(dv, "cd")) {
                                        booted_device = dv;
                                        booted_partition = 0;
+                                       booted_nblks = 0;
                                        break;
                                }
                        }
@@ -492,16 +491,9 @@
        findroot();
        matchbiosdisks();
 
-       if (booted_wedge) {
-               KASSERT(booted_device != NULL);
-               aprint_normal("boot device: %s (%s)\n",
-                   device_xname(booted_wedge), device_xname(booted_device));
-               setroot(booted_wedge, 0);
-       } else {
-               aprint_normal("boot device: %s\n",
-                   booted_device ? device_xname(booted_device) : "<unknown>");
-               setroot(booted_device, booted_partition);
-       }
+       aprint_normal("boot device: %s\n",
+           booted_device ? device_xname(booted_device) : "<unknown>");
+       setroot(booted_device, booted_partition);
 }
 
 void
diff -r 75a4b1e68db9 -r 2e991408bd7a sys/arch/xen/x86/autoconf.c
--- a/sys/arch/xen/x86/autoconf.c       Sun Jun 10 15:04:47 2012 +0000
+++ b/sys/arch/xen/x86/autoconf.c       Sun Jun 10 17:05:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.13 2009/11/27 03:23:15 rmind Exp $      */
+/*     $NetBSD: autoconf.c,v 1.14 2012/06/10 17:05:19 mlelstv Exp $    */
 /*     NetBSD: autoconf.c,v 1.75 2003/12/30 12:33:22 pk Exp    */
 
 /*-
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.13 2009/11/27 03:23:15 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.14 2012/06/10 17:05:19 mlelstv Exp $");
 
 #include "opt_xen.h"
 #include "opt_compat_oldboot.h"
@@ -88,7 +88,6 @@
 
 static void findroot(void);
 static int is_valid_disk(device_t);
-static void handle_wedges(device_t, int);
 
 struct disklist *x86_alldisks;
 int x86_ndisks;
@@ -155,16 +154,9 @@
 {
        findroot();
 
-       if (booted_wedge) {
-               KASSERT(booted_device != NULL);
-               printf("boot device: %s (%s)\n",
-                   device_xname(booted_wedge), device_xname(booted_device));
-               setroot(booted_wedge, 0);
-       } else {
-               printf("boot device: %s\n",
-                   booted_device ? device_xname(booted_device) : "<unknown>");
-               setroot(booted_device, booted_partition);
-       }
+       printf("boot device: %s\n",
+           booted_device ? device_xname(booted_device) : "<unknown>");
+       setroot(booted_device, booted_partition);
 }
 
 
@@ -199,7 +191,7 @@
                        continue;
 
                if (is_disk && xcp.xcp_bootdev[0] == 0) {
-                       handle_wedges(dv, 0);
+                       booted_device = dv;
                        break;
                }
 
@@ -354,15 +346,6 @@
        booted_device = dev;
 }
 
-static void
-handle_wedges(device_t dv, int par)
-{
-       if (config_handle_wedges(dv, par) == 0)
-               return;
-       booted_device = dv;
-       booted_partition = par;
-}
-
 static int
 is_valid_disk(device_t dv)
 {
diff -r 75a4b1e68db9 -r 2e991408bd7a sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Sun Jun 10 15:04:47 2012 +0000
+++ b/sys/dev/dkwedge/dk.c      Sun Jun 10 17:05:18 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.63 2012/04/27 18:15:55 drochner Exp $ */
+/*     $NetBSD: dk.c,v 1.64 2012/06/10 17:05:19 mlelstv Exp $  */
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.63 2012/04/27 18:15:55 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.64 2012/06/10 17:05:19 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -748,44 +748,6 @@
 }
 
 /*
- * dkwedge_set_bootwedge
- *
- *     Set the booted_wedge global based on the specified parent name
- *     and offset/length.
- */
-void
-dkwedge_set_bootwedge(device_t parent, daddr_t startblk, uint64_t nblks)
-{
-       struct dkwedge_softc *sc;
-       int i;
-
-       rw_enter(&dkwedges_lock, RW_WRITER);
-       for (i = 0; i < ndkwedges; i++) {
-               if ((sc = dkwedges[i]) == NULL)
-                       continue;
-               if (strcmp(sc->sc_parent->dk_name, device_xname(parent)) == 0 &&
-                   sc->sc_offset == startblk &&
-                   sc->sc_size == nblks) {
-                       if (booted_wedge) {
-                               printf("WARNING: double match for boot wedge "
-                                   "(%s, %s)\n",
-                                   device_xname(booted_wedge),
-                                   device_xname(sc->sc_dev));
-                               continue;
-                       }
-                       booted_device = parent;
-                       booted_wedge = sc->sc_dev;
-                       booted_partition = 0;
-               }
-       }
-       /*
-        * XXX What if we don't find one?  Should we create a special
-        * XXX root wedge?
-        */
-       rw_exit(&dkwedges_lock);
-}
-
-/*
  * We need a dummy object to stuff into the dkwedge discovery method link
  * set to ensure that there is always at least one object in the set.
  */
@@ -1466,65 +1428,38 @@
  * config glue
  */
 
-int
-config_handle_wedges(struct device *dv, int par)
+/*
+ * dkwedge_find_partition
+ *
+ *     Find wedge corresponding to the specified parent name
+ *     and offset/length.
+ */
+device_t
+dkwedge_find_partition(device_t parent, daddr_t startblk, uint64_t nblks)
 {
-       struct dkwedge_list wl;
-       struct dkwedge_info *wi;
-       struct vnode *vn;
-       char diskname[16];
-       int i, error;
-
-       if ((vn = opendisk(dv)) == NULL)
-               return -1;
-
-       wl.dkwl_bufsize = sizeof(*wi) * 16;
-       wl.dkwl_buf = wi = malloc(wl.dkwl_bufsize, M_TEMP, M_WAITOK);
-
-       error = VOP_IOCTL(vn, DIOCLWEDGES, &wl, FREAD, NOCRED);
-       VOP_CLOSE(vn, FREAD, NOCRED);
-       vput(vn);
-       if (error) {
-#ifdef DEBUG_WEDGE
-               printf("%s: List wedges returned %d\n",
-                   device_xname(dv), error);
-#endif



Home | Main Index | Thread Index | Old Index