Module Name:    src
Committed By:   martin
Date:           Thu Feb 14 12:14:14 UTC 2013

Modified Files:
        src/sys/arch/sparc/sparc: autoconf.c

Log Message:
Rearrange the special mainbus device list to allow for optional entries.
Fixes a panic on all SUN4M machines w/o an sx graphics adapter.
XXX the "ignore devices at mainbus" list seems to be ignored - or am I
missing something?


To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.248 src/sys/arch/sparc/sparc/autoconf.c:1.249
--- src/sys/arch/sparc/sparc/autoconf.c:1.248	Tue Feb  5 22:03:16 2013
+++ src/sys/arch/sparc/sparc/autoconf.c	Thu Feb 14 12:14:13 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.248 2013/02/05 22:03:16 macallan Exp $ */
+/*	$NetBSD: autoconf.c,v 1.249 2013/02/14 12:14:13 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.248 2013/02/05 22:03:16 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.249 2013/02/14 12:14:13 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1091,84 +1091,90 @@ mainbus_attach(device_t parent, device_t
 extern struct sparc_bus_dma_tag mainbus_dma_tag;
 extern struct sparc_bus_space_tag mainbus_space_tag;
 
+	struct boot_special {
+		const char *const dev;
+#define BS_EARLY	1	/* attach device early */
+#define	BS_IGNORE	2	/* ignore root device */
+#define	BS_OPTIONAL	4	/* device not alwas present */
+		unsigned int flags;
+	};
+
 	struct mainbus_attach_args ma;
 	char namebuf[32];
 #if defined(SUN4C) || defined(SUN4M) || defined(SUN4D)
-	const char *const *ssp, *sp = NULL;
+	const char *sp = NULL;
 	int node0, node;
-	const char *const *openboot_special;
+	const struct boot_special *openboot_special, *ssp;
 #endif
 
 #if defined(SUN4C)
-	static const char *const openboot_special4c[] = {
-		/* find these first (end with empty string) */
-		"memory-error",	/* as early as convenient, in case of error */
-		"eeprom",
-		"counter-timer",
-		"auxiliary-io",
-		"",
-
-		/* ignore these (end with NULL) */
-		"aliases",
-		"interrupt-enable",
-		"memory",
-		"openprom",
-		"options",
-		"packages",
-		"virtual-memory",
-		NULL
+	static const struct boot_special openboot_special4c[] = {
+		/* find these first */
+		{ "memory-error", BS_EARLY },
+			/* as early as convenient, in case of error */
+		{ "eeprom", BS_EARLY },
+		{ "counter-timer", BS_EARLY },
+		{ "auxiliary-io", BS_EARLY },
+
+		/* ignore these */
+		{ "aliases", BS_IGNORE },
+		{ "interrupt-enable", BS_IGNORE },
+		{ "memory", BS_IGNORE },
+		{ "openprom", BS_IGNORE },
+		{ "options", BS_IGNORE },
+		{ "packages", BS_IGNORE },
+		{ "virtual-memory", BS_IGNORE },
+
+		/* sentinel */
+		{ NULL, 0 }
 	};
 #else
 #define openboot_special4c	((void *)0)
 #endif
 #if defined(SUN4M)
-	static const char *const openboot_special4m[] = {
+	static const struct boot_special openboot_special4m[] = {
 		/* find these first */
-#if !defined(MSIIEP)
-		"SUNW,sx",
-		"obio",		/* smart enough to get eeprom/etc mapped */
-#else
-		"pci",		/* ms-IIep */
-#endif
-		"",
+		{ "SUNW,sx", BS_EARLY|BS_OPTIONAL },
+		{ "obio", BS_EARLY|BS_OPTIONAL },
+				/* smart enough to get eeprom/etc mapped */
+		{ "pci", BS_EARLY|BS_OPTIONAL },	/* ms-IIep */
 
-		/* ignore these (end with NULL) */
 		/*
 		 * These are _root_ devices to ignore. Others must be handled
 		 * elsewhere.
 		 */
-		"virtual-memory",
-		"aliases",
-		"chosen",		/* OpenFirmware */
-		"memory",
-		"openprom",
-		"options",
-		"packages",
-		"udp",			/* OFW in Krups */
+		{ "virtual-memory", BS_IGNORE },
+		{ "aliases", BS_IGNORE },
+		{ "chosen", BS_IGNORE },	/* OpenFirmware */
+		{ "memory", BS_IGNORE },
+		{ "openprom", BS_IGNORE },
+		{ "options", BS_IGNORE },
+		{ "packages", BS_IGNORE },
+		{ "udp", BS_IGNORE },		/* OFW in Krups */
 		/* we also skip any nodes with device_type == "cpu" */
-		NULL
+
+		{ NULL, 0 }
 	};
 #else
 #define openboot_special4m	((void *)0)
 #endif
 #if defined(SUN4D)
-	static const char *const openboot_special4d[] = {
-		"",
-
-		/* ignore these (end with NULL) */
+	static const struct boot_special openboot_special4d[] = {
 		/*
 		 * These are _root_ devices to ignore. Others must be handled
 		 * elsewhere.
 		 */
-		"mem-unit",	/* XXX might need this for memory errors */
-		"boards",
-		"openprom",
-		"virtual-memory",
-		"memory",
-		"aliases",
-		"options",
-		"packages",
-		NULL
+		{ "mem-unit", BS_IGNORE },
+			/* XXX might need this for memory errors */
+		{ "boards", BS_IGNORE },
+		{ "openprom", BS_IGNORE },
+		{ "virtual-memory", BS_IGNORE },
+		{ "memory", BS_IGNORE },
+		{ "aliases", BS_IGNORE },
+		{ "options", BS_IGNORE },
+		{ "packages", BS_IGNORE },
+
+		{ NULL, 0 }
 	};
 #else
 #define	openboot_special4d	((void *)0)
@@ -1282,10 +1288,12 @@ extern struct sparc_bus_space_tag mainbu
 		config_found(dev, (void *)&ma, mbprint);
 	}
 
-	for (ssp = openboot_special; *(sp = *ssp) != 0; ssp++) {
+	for (ssp = openboot_special; (sp = ssp->dev) != NULL; ssp++) {
 		struct openprom_addr romreg;
 
+		if (!(ssp->flags & BS_EARLY)) continue;
 		if ((node = findnode(node0, sp)) == 0) {
+			if (ssp->flags & BS_OPTIONAL) continue;
 			printf("could not find %s in OPENPROM\n", sp);
 			panic(sp);
 		}
@@ -1331,9 +1339,11 @@ extern struct sparc_bus_space_tag mainbu
 #endif
 		cp = prom_getpropstringA(node, "name", namebuf, sizeof namebuf);
 		DPRINTF(ACDB_PROBE, (" name %s\n", namebuf));
-		for (ssp = openboot_special; (sp = *ssp) != NULL; ssp++)
+		for (ssp = openboot_special; (sp = ssp->dev) != NULL; ssp++) {
+			if (!(ssp->flags & BS_EARLY)) continue;
 			if (strcmp(cp, sp) == 0)
 				break;
+		}
 		if (sp != NULL)
 			continue; /* an "early" device already configured */
 

Reply via email to