Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/evbmips/cavium Add some rudimentary boot args parsi...



details:   https://anonhg.NetBSD.org/src/rev/543e5595b630
branches:  trunk
changeset: 934805:543e5595b630
user:      simonb <simonb%NetBSD.org@localhost>
date:      Sat Jun 20 02:27:55 2020 +0000

description:
Add some rudimentary boot args parsing.  Can handle "root=" as well
normal -1adsqvxz flags.  "root=" is limited to cnmacN devices so far;
should be extended to allow arbitary SD devices (and other devices?).

diffstat:

 sys/arch/evbmips/cavium/autoconf.c |  29 ++++++++++++--
 sys/arch/evbmips/cavium/machdep.c  |  75 ++++++++++++++++++++++++++++++++-----
 2 files changed, 89 insertions(+), 15 deletions(-)

diffs (202 lines):

diff -r 87a2c5b3ff31 -r 543e5595b630 sys/arch/evbmips/cavium/autoconf.c
--- a/sys/arch/evbmips/cavium/autoconf.c        Sat Jun 20 02:01:56 2020 +0000
+++ b/sys/arch/evbmips/cavium/autoconf.c        Sat Jun 20 02:27:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.6 2020/06/10 07:34:19 simonb Exp $      */
+/*     $NetBSD: autoconf.c,v 1.7 2020/06/20 02:27:55 simonb Exp $      */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.6 2020/06/10 07:34:19 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.7 2020/06/20 02:27:55 simonb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -72,15 +72,17 @@
 void
 cpu_rootconf(void)
 {
+
+#ifndef MEMORY_DISK_IS_ROOT
        findroot();
+#endif
 
        printf("boot device: %s\n",
-               booted_device ? booted_device->dv_xname : "<unknown>");
+               booted_device ? device_xname(booted_device) : "<unknown>");
 
        rootconf();
 }
 
-extern char    bootstring[];
 extern int     netboot;
 
 static void
@@ -92,7 +94,23 @@
        if (booted_device)
                return;
 
-       if ((booted_device == NULL) && netboot == 0) {
+       if (rootspec && *rootspec) {
+               /* XXX hard coded "cnmac" for network boot */
+               if (strncmp(rootspec, "cnmac", 5) == 0) {
+                       rootfstype = "nfs";
+                       netboot = 1;
+                       return;
+               }
+               /*
+                * XXX
+                * Assume that if the root spec is not a cnmac, it'll
+                * be a sd. handled below.  Should be fixed to handle
+                * multiple sd devices.
+                */
+       }
+
+       if (netboot == 0) {
+               /* if no root device specified, default to a "sd" device */
                for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); dv != NULL;
                     dv = deviter_next(&di)) {
                        if (device_class(dv) == DV_DISK &&
@@ -174,6 +192,7 @@
 void
 device_register(device_t dev, void *aux)
 {
+
        if ((booted_device == NULL) && (netboot == 1))
                if (device_class(dev) == DV_IFNET)
                        booted_device = dev;
diff -r 87a2c5b3ff31 -r 543e5595b630 sys/arch/evbmips/cavium/machdep.c
--- a/sys/arch/evbmips/cavium/machdep.c Sat Jun 20 02:01:56 2020 +0000
+++ b/sys/arch/evbmips/cavium/machdep.c Sat Jun 20 02:27:55 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.15 2020/06/19 12:38:53 simonb Exp $      */
+/*     $NetBSD: machdep.c,v 1.16 2020/06/20 02:27:55 simonb Exp $      */
 
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -114,7 +114,7 @@
 #include "opt_multiprocessor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.15 2020/06/19 12:38:53 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.16 2020/06/20 02:27:55 simonb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -157,6 +157,7 @@
 static void    mach_init_bus_space(void);
 static void    mach_init_console(void);
 static void    mach_init_memory(void);
+static void    parse_boot_args(void);
 
 #include "com.h"
 #if NCOM > 0
@@ -179,6 +180,7 @@
 void   mach_init(uint64_t, uint64_t, uint64_t, uint64_t);
 
 struct octeon_config octeon_configuration;
+struct octeon_btdesc octeon_btdesc;
 struct octeon_btinfo octeon_btinfo;
 
 char octeon_nmi_stack[PAGE_SIZE] __section(".data1") __aligned(PAGE_SIZE);
@@ -197,11 +199,18 @@
        KASSERT(MIPS_XKPHYS_P(arg3));
        btinfo_paddr = mips3_ld(arg3 + OCTEON_BTINFO_PADDR_OFFSET);
 
-       /* Should be in first 256MB segment */
-       KASSERT(btinfo_paddr < 256 * 1024 * 1024);
-       memcpy(&octeon_btinfo,
-           (struct octeon_btinfo *)MIPS_PHYS_TO_KSEG0(btinfo_paddr),
-           sizeof(octeon_btinfo));
+       /* XXX KASSERT these addresses? */
+       memcpy(&octeon_btdesc, (void *)arg3, sizeof(octeon_btdesc));
+       if ((octeon_btdesc.obt_desc_ver == OCTEON_SUPPORTED_DESCRIPTOR_VERSION) &&
+           (octeon_btdesc.obt_desc_size == sizeof(octeon_btdesc))) {
+               btinfo_paddr = MIPS_PHYS_TO_XKPHYS(CCA_CACHEABLE,
+                   octeon_btdesc.obt_boot_info_addr);
+       } else {
+               panic("unknown boot descriptor size %u",
+                   octeon_btdesc.obt_desc_size);
+       }
+       memcpy(&octeon_btinfo, (void *)btinfo_paddr, sizeof(octeon_btinfo));
+       parse_boot_args();
 
        octeon_cal_timer(octeon_btinfo.obt_eclock_hz);
 
@@ -216,6 +225,12 @@
 
        mach_init_console();
 
+#ifdef DEBUG
+       /* Show a couple of boot desc/info params for positive feedback */
+       printf(">> boot desc eclock = %d\n", octeon_btdesc.obt_eclock);
+       printf(">> boot info board  = %d\n", octeon_btinfo.obt_board_type);
+#endif /* DEBUG */
+
        mach_init_memory();
 
        /*
@@ -223,9 +238,6 @@
         */
        mips_init_lwp0_uarea();
 
-       boothowto = RB_AUTOBOOT;
-       boothowto |= AB_VERBOSE;
-
 #if 0
        curcpu()->ci_nmi_stack = octeon_nmi_stack + sizeof(octeon_nmi_stack) - sizeof(struct kernframe);
        *(uint64_t *)MIPS_PHYS_TO_KSEG0(0x800) = (intptr_t)octeon_reset_vector;
@@ -364,6 +376,49 @@
        pmap_bootstrap();
 }
 
+void
+parse_boot_args(void)
+{
+       int i;
+       char *arg, *p;
+
+       for (i = 0; i < octeon_btdesc.obt_argc; i++) {
+               arg = (char *)MIPS_PHYS_TO_KSEG0(octeon_btdesc.obt_argv[i]);
+               if (*arg == '-') {
+                       for (p = arg + 1; *p; p++) {
+                               switch (*p) {
+                               case '1':
+                                       boothowto |= RB_MD1;
+                                       break;
+                               case 's':
+                                       boothowto |= RB_SINGLE;
+                                       break;
+                               case 'd':
+                                       boothowto |= RB_KDB;
+                                       break;
+                               case 'a':
+                                       boothowto |= RB_ASKNAME;
+                                       break;
+                               case 'q':
+                                       boothowto |= AB_QUIET;
+                                       break;
+                               case 'v':
+                                       boothowto |= AB_VERBOSE;
+                                       break;
+                               case 'x':
+                                       boothowto |= AB_DEBUG;
+                                       break;
+                               case 'z':
+                                       boothowto |= AB_SILENT;
+                                       break;
+                               }
+                       }
+               }
+               if (strncmp(arg, "root=", 5) == 0)
+                       rootspec = strchr(arg, '=') + 1;
+       }
+}
+
 /*
  * cpu_startup
  * cpu_reboot



Home | Main Index | Thread Index | Old Index