Thu Feb 14 12:14:14 2013 UTC ()
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?


(martin)
diff -r1.248 -r1.249 src/sys/arch/sparc/sparc/autoconf.c

cvs diff -r1.248 -r1.249 src/sys/arch/sparc/sparc/autoconf.c (expand / switch to unified diff)

--- src/sys/arch/sparc/sparc/autoconf.c 2013/02/05 22:03:16 1.248
+++ src/sys/arch/sparc/sparc/autoconf.c 2013/02/14 12:14:13 1.249
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: autoconf.c,v 1.248 2013/02/05 22:03:16 macallan Exp $ */ 1/* $NetBSD: autoconf.c,v 1.249 2013/02/14 12:14:13 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 4 * Copyright (c) 1996
5 * The President and Fellows of Harvard College. All rights reserved. 5 * The President and Fellows of Harvard College. All rights reserved.
6 * Copyright (c) 1992, 1993 6 * Copyright (c) 1992, 1993
7 * The Regents of the University of California. All rights reserved. 7 * The Regents of the University of California. All rights reserved.
8 * 8 *
9 * This software was developed by the Computer Systems Engineering group 9 * This software was developed by the Computer Systems Engineering group
10 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 10 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
11 * contributed to Berkeley. 11 * contributed to Berkeley.
12 * 12 *
13 * All advertising materials mentioning features or use of this software 13 * All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement: 14 * must display the following acknowledgement:
@@ -38,27 +38,27 @@ @@ -38,27 +38,27 @@
38 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 38 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
39 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 40 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 41 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 42 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 43 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 * SUCH DAMAGE. 45 * SUCH DAMAGE.
46 * 46 *
47 * @(#)autoconf.c 8.4 (Berkeley) 10/1/93 47 * @(#)autoconf.c 8.4 (Berkeley) 10/1/93
48 */ 48 */
49 49
50#include <sys/cdefs.h> 50#include <sys/cdefs.h>
51__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.248 2013/02/05 22:03:16 macallan Exp $"); 51__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.249 2013/02/14 12:14:13 martin Exp $");
52 52
53#include "opt_ddb.h" 53#include "opt_ddb.h"
54#include "opt_kgdb.h" 54#include "opt_kgdb.h"
55#include "opt_modular.h" 55#include "opt_modular.h"
56#include "opt_multiprocessor.h" 56#include "opt_multiprocessor.h"
57#include "opt_sparc_arch.h" 57#include "opt_sparc_arch.h"
58 58
59#include "scsibus.h" 59#include "scsibus.h"
60 60
61#include <sys/param.h> 61#include <sys/param.h>
62#include <sys/kernel.h> 62#include <sys/kernel.h>
63#include <sys/systm.h> 63#include <sys/systm.h>
64#include <sys/endian.h> 64#include <sys/endian.h>
@@ -1081,104 +1081,110 @@ static int prom_getprop_address1(int, vo @@ -1081,104 +1081,110 @@ static int prom_getprop_address1(int, vo
1081/* 1081/*
1082 * Attach the mainbus. 1082 * Attach the mainbus.
1083 * 1083 *
1084 * Our main job is to attach the CPU (the root node we got in configure()) 1084 * Our main job is to attach the CPU (the root node we got in configure())
1085 * and iterate down the list of `mainbus devices' (children of that node). 1085 * and iterate down the list of `mainbus devices' (children of that node).
1086 * We also record the `node id' of the default frame buffer, if any. 1086 * We also record the `node id' of the default frame buffer, if any.
1087 */ 1087 */
1088static void 1088static void
1089mainbus_attach(device_t parent, device_t dev, void *aux) 1089mainbus_attach(device_t parent, device_t dev, void *aux)
1090{ 1090{
1091extern struct sparc_bus_dma_tag mainbus_dma_tag; 1091extern struct sparc_bus_dma_tag mainbus_dma_tag;
1092extern struct sparc_bus_space_tag mainbus_space_tag; 1092extern struct sparc_bus_space_tag mainbus_space_tag;
1093 1093
 1094 struct boot_special {
 1095 const char *const dev;
 1096#define BS_EARLY 1 /* attach device early */
 1097#define BS_IGNORE 2 /* ignore root device */
 1098#define BS_OPTIONAL 4 /* device not alwas present */
 1099 unsigned int flags;
 1100 };
 1101
1094 struct mainbus_attach_args ma; 1102 struct mainbus_attach_args ma;
1095 char namebuf[32]; 1103 char namebuf[32];
1096#if defined(SUN4C) || defined(SUN4M) || defined(SUN4D) 1104#if defined(SUN4C) || defined(SUN4M) || defined(SUN4D)
1097 const char *const *ssp, *sp = NULL; 1105 const char *sp = NULL;
1098 int node0, node; 1106 int node0, node;
1099 const char *const *openboot_special; 1107 const struct boot_special *openboot_special, *ssp;
1100#endif 1108#endif
1101 1109
1102#if defined(SUN4C) 1110#if defined(SUN4C)
1103 static const char *const openboot_special4c[] = { 1111 static const struct boot_special openboot_special4c[] = {
1104 /* find these first (end with empty string) */ 1112 /* find these first */
1105 "memory-error", /* as early as convenient, in case of error */ 1113 { "memory-error", BS_EARLY },
1106 "eeprom", 1114 /* as early as convenient, in case of error */
1107 "counter-timer", 1115 { "eeprom", BS_EARLY },
1108 "auxiliary-io", 1116 { "counter-timer", BS_EARLY },
1109 "", 1117 { "auxiliary-io", BS_EARLY },
1110 1118
1111 /* ignore these (end with NULL) */ 1119 /* ignore these */
1112 "aliases", 1120 { "aliases", BS_IGNORE },
1113 "interrupt-enable", 1121 { "interrupt-enable", BS_IGNORE },
1114 "memory", 1122 { "memory", BS_IGNORE },
1115 "openprom", 1123 { "openprom", BS_IGNORE },
1116 "options", 1124 { "options", BS_IGNORE },
1117 "packages", 1125 { "packages", BS_IGNORE },
1118 "virtual-memory", 1126 { "virtual-memory", BS_IGNORE },
1119 NULL 1127
 1128 /* sentinel */
 1129 { NULL, 0 }
1120 }; 1130 };
1121#else 1131#else
1122#define openboot_special4c ((void *)0) 1132#define openboot_special4c ((void *)0)
1123#endif 1133#endif
1124#if defined(SUN4M) 1134#if defined(SUN4M)
1125 static const char *const openboot_special4m[] = { 1135 static const struct boot_special openboot_special4m[] = {
1126 /* find these first */ 1136 /* find these first */
1127#if !defined(MSIIEP) 1137 { "SUNW,sx", BS_EARLY|BS_OPTIONAL },
1128 "SUNW,sx", 1138 { "obio", BS_EARLY|BS_OPTIONAL },
1129 "obio", /* smart enough to get eeprom/etc mapped */ 1139 /* smart enough to get eeprom/etc mapped */
1130#else 1140 { "pci", BS_EARLY|BS_OPTIONAL }, /* ms-IIep */
1131 "pci", /* ms-IIep */ 
1132#endif 
1133 "", 
1134 1141
1135 /* ignore these (end with NULL) */ 
1136 /* 1142 /*
1137 * These are _root_ devices to ignore. Others must be handled 1143 * These are _root_ devices to ignore. Others must be handled
1138 * elsewhere. 1144 * elsewhere.
1139 */ 1145 */
1140 "virtual-memory", 1146 { "virtual-memory", BS_IGNORE },
1141 "aliases", 1147 { "aliases", BS_IGNORE },
1142 "chosen", /* OpenFirmware */ 1148 { "chosen", BS_IGNORE }, /* OpenFirmware */
1143 "memory", 1149 { "memory", BS_IGNORE },
1144 "openprom", 1150 { "openprom", BS_IGNORE },
1145 "options", 1151 { "options", BS_IGNORE },
1146 "packages", 1152 { "packages", BS_IGNORE },
1147 "udp", /* OFW in Krups */ 1153 { "udp", BS_IGNORE }, /* OFW in Krups */
1148 /* we also skip any nodes with device_type == "cpu" */ 1154 /* we also skip any nodes with device_type == "cpu" */
1149 NULL 1155
 1156 { NULL, 0 }
1150 }; 1157 };
1151#else 1158#else
1152#define openboot_special4m ((void *)0) 1159#define openboot_special4m ((void *)0)
1153#endif 1160#endif
1154#if defined(SUN4D) 1161#if defined(SUN4D)
1155 static const char *const openboot_special4d[] = { 1162 static const struct boot_special openboot_special4d[] = {
1156 "", 
1157 
1158 /* ignore these (end with NULL) */ 
1159 /* 1163 /*
1160 * These are _root_ devices to ignore. Others must be handled 1164 * These are _root_ devices to ignore. Others must be handled
1161 * elsewhere. 1165 * elsewhere.
1162 */ 1166 */
1163 "mem-unit", /* XXX might need this for memory errors */ 1167 { "mem-unit", BS_IGNORE },
1164 "boards", 1168 /* XXX might need this for memory errors */
1165 "openprom", 1169 { "boards", BS_IGNORE },
1166 "virtual-memory", 1170 { "openprom", BS_IGNORE },
1167 "memory", 1171 { "virtual-memory", BS_IGNORE },
1168 "aliases", 1172 { "memory", BS_IGNORE },
1169 "options", 1173 { "aliases", BS_IGNORE },
1170 "packages", 1174 { "options", BS_IGNORE },
1171 NULL 1175 { "packages", BS_IGNORE },
 1176
 1177 { NULL, 0 }
1172 }; 1178 };
1173#else 1179#else
1174#define openboot_special4d ((void *)0) 1180#define openboot_special4d ((void *)0)
1175#endif 1181#endif
1176 1182
1177 1183
1178 if (CPU_ISSUN4) 1184 if (CPU_ISSUN4)
1179 snprintf(machine_model, sizeof machine_model, "SUN-4/%d series", 1185 snprintf(machine_model, sizeof machine_model, "SUN-4/%d series",
1180 cpuinfo.classlvl); 1186 cpuinfo.classlvl);
1181 else 1187 else
1182 snprintf(machine_model, sizeof machine_model, "%s", 1188 snprintf(machine_model, sizeof machine_model, "%s",
1183 prom_getpropstringA(findroot(), "name", namebuf, 1189 prom_getpropstringA(findroot(), "name", namebuf,
1184 sizeof(namebuf))); 1190 sizeof(namebuf)));
@@ -1272,30 +1278,32 @@ extern struct sparc_bus_space_tag mainbu @@ -1272,30 +1278,32 @@ extern struct sparc_bus_space_tag mainbu
1272 /* Re-enter loop to find all remaining CPUs */ 1278 /* Re-enter loop to find all remaining CPUs */
1273 goto rescan; 1279 goto rescan;
1274 } 1280 }
1275 } 1281 }
1276 } else if (CPU_ISSUN4C) { 1282 } else if (CPU_ISSUN4C) {
1277 memset(&ma, 0, sizeof(ma)); 1283 memset(&ma, 0, sizeof(ma));
1278 ma.ma_bustag = &mainbus_space_tag; 1284 ma.ma_bustag = &mainbus_space_tag;
1279 ma.ma_dmatag = &mainbus_dma_tag; 1285 ma.ma_dmatag = &mainbus_dma_tag;
1280 ma.ma_node = findroot(); 1286 ma.ma_node = findroot();
1281 ma.ma_name = "cpu"; 1287 ma.ma_name = "cpu";
1282 config_found(dev, (void *)&ma, mbprint); 1288 config_found(dev, (void *)&ma, mbprint);
1283 } 1289 }
1284 1290
1285 for (ssp = openboot_special; *(sp = *ssp) != 0; ssp++) { 1291 for (ssp = openboot_special; (sp = ssp->dev) != NULL; ssp++) {
1286 struct openprom_addr romreg; 1292 struct openprom_addr romreg;
1287 1293
 1294 if (!(ssp->flags & BS_EARLY)) continue;
1288 if ((node = findnode(node0, sp)) == 0) { 1295 if ((node = findnode(node0, sp)) == 0) {
 1296 if (ssp->flags & BS_OPTIONAL) continue;
1289 printf("could not find %s in OPENPROM\n", sp); 1297 printf("could not find %s in OPENPROM\n", sp);
1290 panic(sp); 1298 panic(sp);
1291 } 1299 }
1292 1300
1293 memset(&ma, 0, sizeof ma); 1301 memset(&ma, 0, sizeof ma);
1294 ma.ma_bustag = &mainbus_space_tag; 1302 ma.ma_bustag = &mainbus_space_tag;
1295 ma.ma_dmatag = &mainbus_dma_tag; 1303 ma.ma_dmatag = &mainbus_dma_tag;
1296 ma.ma_name = prom_getpropstringA(node, "name", 1304 ma.ma_name = prom_getpropstringA(node, "name",
1297 namebuf, sizeof namebuf); 1305 namebuf, sizeof namebuf);
1298 ma.ma_node = node; 1306 ma.ma_node = node;
1299 if (prom_getprop_reg1(node, &romreg) != 0) 1307 if (prom_getprop_reg1(node, &romreg) != 0)
1300 continue; 1308 continue;
1301 1309
@@ -1321,29 +1329,31 @@ extern struct sparc_bus_space_tag mainbu @@ -1321,29 +1329,31 @@ extern struct sparc_bus_space_tag mainbu
1321 struct openprom_addr romreg; 1329 struct openprom_addr romreg;
1322 1330
1323 DPRINTF(ACDB_PROBE, ("Node: %x", node)); 1331 DPRINTF(ACDB_PROBE, ("Node: %x", node));
1324#if defined(SUN4M) 1332#if defined(SUN4M)
1325 if (CPU_ISSUN4M) { /* skip the CPUs */ 1333 if (CPU_ISSUN4M) { /* skip the CPUs */
1326 if (strcmp(prom_getpropstringA(node, "device_type", 1334 if (strcmp(prom_getpropstringA(node, "device_type",
1327 namebuf, sizeof namebuf), 1335 namebuf, sizeof namebuf),
1328 "cpu") == 0) 1336 "cpu") == 0)
1329 continue; 1337 continue;
1330 } 1338 }
1331#endif 1339#endif
1332 cp = prom_getpropstringA(node, "name", namebuf, sizeof namebuf); 1340 cp = prom_getpropstringA(node, "name", namebuf, sizeof namebuf);
1333 DPRINTF(ACDB_PROBE, (" name %s\n", namebuf)); 1341 DPRINTF(ACDB_PROBE, (" name %s\n", namebuf));
1334 for (ssp = openboot_special; (sp = *ssp) != NULL; ssp++) 1342 for (ssp = openboot_special; (sp = ssp->dev) != NULL; ssp++) {
 1343 if (!(ssp->flags & BS_EARLY)) continue;
1335 if (strcmp(cp, sp) == 0) 1344 if (strcmp(cp, sp) == 0)
1336 break; 1345 break;
 1346 }
1337 if (sp != NULL) 1347 if (sp != NULL)
1338 continue; /* an "early" device already configured */ 1348 continue; /* an "early" device already configured */
1339 1349
1340 memset(&ma, 0, sizeof ma); 1350 memset(&ma, 0, sizeof ma);
1341 ma.ma_bustag = &mainbus_space_tag; 1351 ma.ma_bustag = &mainbus_space_tag;
1342 ma.ma_dmatag = &mainbus_dma_tag; 1352 ma.ma_dmatag = &mainbus_dma_tag;
1343 ma.ma_name = prom_getpropstringA(node, "name", 1353 ma.ma_name = prom_getpropstringA(node, "name",
1344 namebuf, sizeof namebuf); 1354 namebuf, sizeof namebuf);
1345 ma.ma_node = node; 1355 ma.ma_node = node;
1346 1356
1347#if defined(SUN4M) 1357#if defined(SUN4M)
1348 /* 1358 /*
1349 * JS1/OF does not have iommu node in the device tree, 1359 * JS1/OF does not have iommu node in the device tree,