summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2008-03-08 16:30:36 +0000
committerkettenis <kettenis@openbsd.org>2008-03-08 16:30:36 +0000
commit5adfdce95df95c4848de76bc8247b48b9c0bef3f (patch)
tree60fecd3a643b6e89080f421ad5ca6ea00e39f11f
parentallows SMALL_KERNEL compiles (diff)
downloadwireguard-openbsd-5adfdce95df95c4848de76bc8247b48b9c0bef3f.tar.xz
wireguard-openbsd-5adfdce95df95c4848de76bc8247b48b9c0bef3f.zip
Introduce a function to check the "status" property of an OFW node, and use it
to avoid attaching disabled or failed devices. This should make it possible to manually deconfigure devices on mid-range and high-end servers like the V880 using the "asr-disable" PROM command, and make OpenBSD avoid using hardware that has been detected as faulty by the POST or OpenBoot Diagnostics.
-rw-r--r--sys/arch/sparc64/include/autoconf.h3
-rw-r--r--sys/arch/sparc64/sparc64/autoconf.c26
2 files changed, 26 insertions, 3 deletions
diff --git a/sys/arch/sparc64/include/autoconf.h b/sys/arch/sparc64/include/autoconf.h
index a716ccd1541..e2b6ebf5239 100644
--- a/sys/arch/sparc64/include/autoconf.h
+++ b/sys/arch/sparc64/include/autoconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.h,v 1.16 2008/03/01 15:56:09 kettenis Exp $ */
+/* $OpenBSD: autoconf.h,v 1.17 2008/03/08 16:30:36 kettenis Exp $ */
/* $NetBSD: autoconf.h,v 1.10 2001/07/24 19:32:11 eeh Exp $ */
/*-
@@ -165,5 +165,6 @@ void *findzs(int);
int romgetcursoraddr(int **, int **);
int findroot(void);
int findnode(int, const char *);
+int checkstatus(int);
int node_has_property(int, const char *);
void device_register(struct device *, void *);
diff --git a/sys/arch/sparc64/sparc64/autoconf.c b/sys/arch/sparc64/sparc64/autoconf.c
index 6189475d056..024b22179cd 100644
--- a/sys/arch/sparc64/sparc64/autoconf.c
+++ b/sys/arch/sparc64/sparc64/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.77 2008/03/01 15:56:09 kettenis Exp $ */
+/* $OpenBSD: autoconf.c,v 1.78 2008/03/08 16:30:36 kettenis Exp $ */
/* $NetBSD: autoconf.c,v 1.51 2001/07/24 19:32:11 eeh Exp $ */
/*
@@ -767,6 +767,9 @@ extern bus_space_tag_t mainbus_space_tag;
if (sp != NULL)
continue; /* an "early" device already configured */
+ if (!checkstatus(node))
+ continue;
+
bzero(&ma, sizeof ma);
ma.ma_bustag = mainbus_space_tag;
ma.ma_dmatag = &mainbus_dma_tag;
@@ -979,7 +982,26 @@ nextsibling(node)
return OF_peer(node);
}
-/* The following are used primarily in consinit() */
+int
+checkstatus(int node)
+{
+ char buf[32];
+
+ /* If there is no "status" property, assume everything is fine. */
+ if (OF_getprop(node, "status", buf, sizeof(buf)) <= 0)
+ return 1;
+
+ /*
+ * If OpenBoot Diagnostics discovers a problem with a device
+ * it will mark it with "fail" or "fail-xxx", where "xxx" is
+ * additional human-readable information about the particular
+ * fault-condition.
+ */
+ if (strcmp(buf, "disabled") == 0 || strncmp(buf, "fail", 4) == 0)
+ return 0;
+
+ return 1;
+}
int
node_has_property(node, prop) /* returns 1 if node has given property */