Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/arch/cobalt/cobalt Pullup from -current



details:   https://anonhg.NetBSD.org/src/rev/ebf57dec23fa
branches:  netbsd-1-5
changeset: 491912:ebf57dec23fa
user:      cyber <cyber%NetBSD.org@localhost>
date:      Sun Jun 17 00:26:29 2001 +0000

description:
Pullup from -current
autoconf.c 1.7 -> 1.8
machdep.c 1.32 -> 1.33
reviewed by soren

diffstat:

 sys/arch/cobalt/cobalt/autoconf.c |   57 +++++++--------
 sys/arch/cobalt/cobalt/machdep.c  |  137 +++++++++++++++++++++++++++++--------
 2 files changed, 131 insertions(+), 63 deletions(-)

diffs (280 lines):

diff -r d20706347e34 -r ebf57dec23fa sys/arch/cobalt/cobalt/autoconf.c
--- a/sys/arch/cobalt/cobalt/autoconf.c Sat Jun 16 21:44:11 2001 +0000
+++ b/sys/arch/cobalt/cobalt/autoconf.c Sun Jun 17 00:26:29 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.7 2000/06/06 18:00:13 soren Exp $       */
+/*     $NetBSD: autoconf.c,v 1.7.2.1 2001/06/17 00:26:29 cyber Exp $   */
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang.  All rights reserved.
@@ -33,10 +33,13 @@
 
 #include <machine/cpu.h>
 
+extern char    bootstring[];
+extern int     netboot;
+extern int     bootunit;
+extern int     bootpart;
+
 struct device *booted_device;
-int booted_partition;
-
-static void    findroot(void);
+int booted_partition = 0;
 
 int            cpuspeed = 100;         /* Until we know more precisely. */
 
@@ -54,46 +57,38 @@
 void
 cpu_rootconf()
 {
-       findroot();
-
        printf("boot device: %s\n",
                booted_device ? booted_device->dv_xname : "<unknown>");
 
        setroot(booted_device, booted_partition);
 }
 
-extern char    bootstring[];
-extern int     netboot;
-
-static void
-findroot(void)
-{
-       struct device *dv;
-
-       if (booted_device)
-               return;
-
-       if ((booted_device == NULL) && netboot == 0)
-               for (dv = alldevs.tqh_first; dv != NULL;
-                    dv = dv->dv_list.tqe_next)
-                       if (dv->dv_class == DV_DISK &&
-                           !strcmp(dv->dv_cfdata->cf_driver->cd_name, "wd"))
-                                   booted_device = dv;
-
-       /*
-        * XXX Match up MBR boot specification with BSD disklabel for root?
-        */
-       booted_partition = 0;
-
-       return;
-}
+static int hd_iterate = -1;
 
 void
 device_register(dev, aux)
        struct device *dev;
        void *aux;
 {
+       if (booted_device)
+               return;
+
        if ((booted_device == NULL) && (netboot == 1))
                if (dev->dv_class == DV_IFNET)
                        booted_device = dev;
+
+       if ((booted_device == NULL) && (netboot == 0)) {
+               if (dev->dv_class == DV_DISK &&
+                   !strcmp(dev->dv_cfdata->cf_driver->cd_name, "wd")) {
+                       hd_iterate++;
+                       if (hd_iterate == bootunit) {
+                               booted_device = dev;
+                       }
+               }
+               /*
+                * XXX Match up MBR boot specification with BSD disklabel for root?
+                */
+               booted_partition = 0;
+       }
 }
+
diff -r d20706347e34 -r ebf57dec23fa sys/arch/cobalt/cobalt/machdep.c
--- a/sys/arch/cobalt/cobalt/machdep.c  Sat Jun 16 21:44:11 2001 +0000
+++ b/sys/arch/cobalt/cobalt/machdep.c  Sun Jun 17 00:26:29 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.17.2.1 2000/07/19 00:25:26 jeffs Exp $   */
+/*     $NetBSD: machdep.c,v 1.17.2.2 2001/06/17 00:26:29 cyber Exp $   */
 
 /*
  * Copyright (c) 2000 Soren S. Jorvang.  All rights reserved.
@@ -77,6 +77,7 @@
 
 #include <dev/cons.h>
 
+
 /* For sysctl. */
 char machine[] = MACHINE;
 char machine_arch[] = MACHINE_ARCH;
@@ -95,11 +96,19 @@
 char   bootstring[512];        /* Boot command */
 int    netboot;                /* Are we netbooting? */
 
+char * nfsroot_bstr = NULL;
+char * root_bstr = NULL;
+int    bootunit = -1;
+int    bootpart = -1;
+
+
 phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
 int mem_cluster_cnt;
 
 void   configure(void);
 void   mach_init(unsigned int);
+void   decode_bootstring(void);
+static char *  strtok_light(char *, const char);
 
 /*
  * safepri is a safe priority for sleep to set for a spin-wait during
@@ -110,6 +119,8 @@
 extern caddr_t esym;
 extern struct user *proc0paddr;
 
+
+
 /*
  * Do all the stuff that locore normally does before calling main().
  */
@@ -121,7 +132,6 @@
         u_long first, last;
        vsize_t size;
        extern char edata[], end[];
-       int i;
 
        /*
         * Clear the BSS segment.
@@ -165,36 +175,7 @@
        memset((char *)(memsize - 512), 0, 512);
        bootstring[511] = '\0';
 
-       for (i = 0; i < 512; i++) {
-               switch (bootstring[i]) {
-               case '\0':
-                       break;
-               case ' ':
-                       continue;
-               case '-':
-                       while (bootstring[i] != ' ' && bootstring[i] != '\0') {
-                               switch (bootstring[i]) {
-                               case 'a':
-                                       boothowto |= RB_ASKNAME;
-                                       break;
-                               case 'd':
-                                       boothowto |= RB_KDB;
-                                       break;
-                               case 's':
-                                       boothowto |= RB_SINGLE;
-                                       break;
-                               }
-                               i++;
-                       }
-               }
-               if (memcmp("single", bootstring + i, 5) == 0)
-                       boothowto |= RB_SINGLE;
-               if (memcmp("nfsroot=", bootstring + i, 8) == 0)
-                       netboot = 1;
-               /*
-                * XXX Select root device from 'root=/dev/hd[abcd][1234]' too.
-                */
-       }
+       decode_bootstring();
 
 #ifdef DDB
        /*
@@ -540,3 +521,95 @@
                softclock();
        }
 }
+
+
+void
+decode_bootstring(void)
+{
+       char * work;
+       char * equ;
+       int i;
+
+       /* break apart bootstring on ' ' boundries  and itterate*/
+       work = strtok_light(bootstring, ' ');
+       while (work != '\0') {
+               /* if starts with '-', we got options, walk its decode */
+               if (work[0] == '-') {
+                       i = 1;
+                       while (work[i] != ' ' && work[i] != '\0') {
+                               switch (work[i]) {
+                               case 'a':
+                                       boothowto |= RB_ASKNAME;
+                                       break;
+                               case 'd':
+                                       boothowto |= RB_KDB;
+                                       break;
+                               case 's':
+                                       boothowto |= RB_SINGLE;
+                                       break;
+                               }
+                               i++;
+                       }
+               } else
+
+               /* if it has a '=' its an assignment, switch and set */
+               if ((equ = strchr(work,'=')) != '\0') {
+                       if(0 == memcmp("nfsroot=", work, 8)) {
+                               nfsroot_bstr = (equ +1);
+                       } else
+                       if(0 == memcmp("root=", work, 5)) {
+                               root_bstr = (equ +1);
+                       } 
+               } else
+
+               /* else it a single value, switch and process */
+               if (memcmp("single", work, 5) == 0) {
+                       boothowto |= RB_SINGLE;
+               } else
+               if (memcmp("ro", work, 2) == 0) {
+                       /* this is also inserted by the firmware */
+               }
+
+               /* grab next token */
+               work = strtok_light(NULL, ' ');
+       }
+
+       if (root_bstr != NULL) {
+               /* this should be of the form "/dev/hda1" */
+               /* [abcd][1234]    drive partition  linux probe order */
+               if ((memcmp("/dev/hd",root_bstr,7) == 0) &&
+                   (strlen(root_bstr) == 9) ){
+                       bootunit = root_bstr[7] - 'a';
+                       bootpart = root_bstr[8] - '1';
+               }
+       }
+}
+
+
+static char *
+strtok_light(str, sep)
+       char * str;
+       const char sep;
+{
+       static char * proc;
+       char * head;
+       char * work;
+
+       if (str != NULL)
+               proc = str;
+       if (proc == NULL)  /* end of string return NULL */
+               return proc;
+
+       head = proc;
+
+       work = strchr (proc, sep);
+       if (work == NULL) {  /* we hit the end */
+               proc = work;
+       } else {
+               proc = (work +1 );
+               *work = '\0';
+       }
+
+       return head;
+}
+



Home | Main Index | Thread Index | Old Index