diff options
author | Visa Hankala <visa@cvs.openbsd.org> | 2019-07-12 03:03:49 +0000 |
---|---|---|
committer | Visa Hankala <visa@cvs.openbsd.org> | 2019-07-12 03:03:49 +0000 |
commit | e9450f8c4721ed7ca60d6940a8dc7f54f1e8deb6 (patch) | |
tree | d342b29e082b86b601e9346ee462bd803e1a4531 | |
parent | 52c0cba87623c7b036a584ff656fcb55c1866e4f (diff) |
Make rootdev parsing a little saner. The "rootdev=" prefix can be
removed already in process_bootargs(). Pass the value as a parameter
to parse_uboot_root(). Set uboot_rootdev only if parsing succeeds.
-rw-r--r-- | sys/arch/octeon/include/autoconf.h | 4 | ||||
-rw-r--r-- | sys/arch/octeon/octeon/autoconf.c | 29 | ||||
-rw-r--r-- | sys/arch/octeon/octeon/machdep.c | 13 |
3 files changed, 21 insertions, 25 deletions
diff --git a/sys/arch/octeon/include/autoconf.h b/sys/arch/octeon/include/autoconf.h index b934eae1943..1b51d5b690d 100644 --- a/sys/arch/octeon/include/autoconf.h +++ b/sys/arch/octeon/include/autoconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.h,v 1.3 2017/07/03 08:17:20 visa Exp $ */ +/* $OpenBSD: autoconf.h,v 1.4 2019/07/12 03:03:48 visa Exp $ */ /* * Copyright (c) 2001-2003 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -41,11 +41,13 @@ struct mainbus_attach_args { extern struct device *bootdv; extern char bootdev[]; +extern char uboot_rootdev[]; extern enum devclass bootdev_class; #include <mips64/autoconf.h> void com_fdt_init_cons(void); +void parse_uboot_root(const char *); extern unsigned int octeon_ver; #define OCTEON_1 0 diff --git a/sys/arch/octeon/octeon/autoconf.c b/sys/arch/octeon/octeon/autoconf.c index dd0981de275..d9f401f51c9 100644 --- a/sys/arch/octeon/octeon/autoconf.c +++ b/sys/arch/octeon/octeon/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.15 2019/07/05 15:23:35 visa Exp $ */ +/* $OpenBSD: autoconf.c,v 1.16 2019/07/12 03:03:48 visa Exp $ */ /* * Copyright (c) 2009 Miodrag Vallat. * @@ -27,13 +27,12 @@ extern void dumpconf(void); int parseduid(const char *, u_char *); -void parse_uboot_root(void); int cold = 1; struct device *bootdv = NULL; char bootdev[16]; +char uboot_rootdev[64]; enum devclass bootdev_class = DV_DULL; -extern char uboot_rootdev[]; void cpu_configure(void) @@ -78,23 +77,25 @@ findtype(void) } void -parse_uboot_root(void) +parse_uboot_root(const char *p) { - char *p; + const char *base; size_t len; /* - * Turn the U-Boot root device (rootdev=/dev/octcf0) into a boot device. + * Turn the U-Boot root device (/dev/octcf0) into a boot device. */ - p = strrchr(uboot_rootdev, '/'); - if (p == NULL) { - p = strchr(uboot_rootdev, '='); - if (p == NULL) - return; - } - p++; + + if (strlen(uboot_rootdev) != 0) + return; + + /* Get device basename. */ + base = strrchr(p, '/'); + if (base != NULL) + p = base + 1; if (parseduid(p, bootduid) == 0) { + strlcpy(uboot_rootdev, p, sizeof(uboot_rootdev)); bootdev_class = DV_DISK; return; } @@ -104,7 +105,7 @@ parse_uboot_root(void) return; strlcpy(bootdev, p, sizeof(bootdev)); - + strlcpy(uboot_rootdev, p, sizeof(uboot_rootdev)); bootdev_class = findtype(); } diff --git a/sys/arch/octeon/octeon/machdep.c b/sys/arch/octeon/octeon/machdep.c index a32bfaa5991..1db12f8ed8f 100644 --- a/sys/arch/octeon/octeon/machdep.c +++ b/sys/arch/octeon/octeon/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.112 2019/06/20 13:59:39 visa Exp $ */ +/* $OpenBSD: machdep.c,v 1.113 2019/07/12 03:03:48 visa Exp $ */ /* * Copyright (c) 2009, 2010 Miodrag Vallat. @@ -104,8 +104,6 @@ struct boot_info *octeon_boot_info; void *octeon_fdt; unsigned int octeon_ver; -char uboot_rootdev[OCTEON_ARGV_MAX]; - /* * safepri is a safe priority for sleep to set for a spin-wait * during autoconfiguration or after a panic. @@ -137,8 +135,6 @@ void octeon_tlb_init(void); static void process_bootargs(void); static uint64_t get_ncpusfound(void); -extern void parse_uboot_root(void); - cons_decl(cn30xxuart); struct consdev uartcons = cons_init(cn30xxuart); @@ -729,11 +725,8 @@ process_bootargs(void) * rootdev=ROOTDEV. */ if (strncmp(arg, "rootdev=", 8) == 0) { - if (*uboot_rootdev == '\0') { - strlcpy(uboot_rootdev, arg, - sizeof(uboot_rootdev)); - parse_uboot_root(); - } + parse_uboot_root(arg + 8); + continue; } if (*arg != '-') |