Module Name:    src
Committed By:   thorpej
Date:           Mon Jan  8 05:10:51 UTC 2024

Modified Files:
        src/sys/arch/virt68k/virt68k: autoconf.c machdep.c

Log Message:
Accept "root=xxx" for the root device and "flags=xxx" as the boothowto
flags from the kernel command line arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/virt68k/virt68k/autoconf.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/virt68k/virt68k/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/virt68k/virt68k/autoconf.c
diff -u src/sys/arch/virt68k/virt68k/autoconf.c:1.4 src/sys/arch/virt68k/virt68k/autoconf.c:1.5
--- src/sys/arch/virt68k/virt68k/autoconf.c:1.4	Sun Jan  7 16:41:24 2024
+++ src/sys/arch/virt68k/virt68k/autoconf.c	Mon Jan  8 05:10:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.4 2024/01/07 16:41:24 thorpej Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.5 2024/01/08 05:10:51 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.4 2024/01/07 16:41:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.5 2024/01/08 05:10:51 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -96,6 +96,26 @@ void
 device_register(device_t dev, void *aux)
 {
 	device_t parent = device_parent(dev);
+	char rootname[DEVICE_XNAME_SIZE];
+	bool rootname_valid = false;
+
+	if (booted_device == NULL) {
+		rootname_valid = bootinfo_getarg("root",
+		    rootname, sizeof(rootname));
+		if (rootname_valid) {
+			size_t len = strlen(rootname);
+			while (len) {
+				len--;
+				if (isdigit(rootname[len])) {
+					break;
+				}
+				rootname[len] = '\0';
+			}
+			if (strcmp(device_xname(dev), rootname) == 0) {
+				booted_device = dev;
+			}
+		}
+	}
 
 	if (device_is_a(parent, "mainbus")) {
 		struct mainbus_attach_args *ma = aux;

Index: src/sys/arch/virt68k/virt68k/machdep.c
diff -u src/sys/arch/virt68k/virt68k/machdep.c:1.5 src/sys/arch/virt68k/virt68k/machdep.c:1.6
--- src/sys/arch/virt68k/virt68k/machdep.c:1.5	Sat Jan  6 21:43:37 2024
+++ src/sys/arch/virt68k/virt68k/machdep.c	Mon Jan  8 05:10:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.5 2024/01/06 21:43:37 thorpej Exp $	*/
+/*	$NetBSD: machdep.c,v 1.6 2024/01/08 05:10:51 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 2024/01/06 21:43:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.6 2024/01/08 05:10:51 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_m060sp.h"
@@ -70,6 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include <sys/module.h>
 #include <sys/device.h>
 #include <sys/cpu.h>
+#include <sys/boot_flag.h>
 
 #include "ksyms.h"
 
@@ -100,8 +101,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include <ddb/db_output.h>
 #endif
 
-#define	MAXMEM	64*1024	/* XXX - from cmap.h */
-
 /* the following is used externally (sysctl_hw) */
 char	machine[] = MACHINE;	/* from <machine/param.h> */
 
@@ -207,6 +206,17 @@ virt68k_init(void)
 
 	/* Check for RND seed from the loader. */
 	bootinfo_setup_rndseed();
+
+	char flags[32];
+	if (bootinfo_getarg("flags", flags, sizeof(flags))) {
+		for (const char *cp = flags; *cp != '\0'; cp++) {
+			/* Consume 'm' in favor of BI_RAMDISK. */
+			if (*cp == 'm') {
+				continue;
+			}
+			BOOT_FLAG(*cp, boothowto);
+		}
+	}
 }
 
 /*

Reply via email to