Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ofw If we're enumerating the root bus, skip some wel...



details:   https://anonhg.NetBSD.org/src/rev/ce0b049b2086
branches:  trunk
changeset: 378930:ce0b049b2086
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Apr 30 02:34:12 2021 +0000

description:
If we're enumerating the root bus, skip some well-known nodes that
don't have any useful device child nodes:

        aliases
        options
        openprom
        chosen
        packages

...and also allow machdep additions to this list (XXX which are temporarily
declared here for arm32 until there's a consistent machine/ofw_machdep.h
header file).

diffstat:

 sys/dev/ofw/ofbus.c |  54 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 50 insertions(+), 4 deletions(-)

diffs (99 lines):

diff -r 46814e4a3f51 -r ce0b049b2086 sys/dev/ofw/ofbus.c
--- a/sys/dev/ofw/ofbus.c       Fri Apr 30 02:24:05 2021 +0000
+++ b/sys/dev/ofw/ofbus.c       Fri Apr 30 02:34:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ofbus.c,v 1.28 2021/04/27 20:31:01 thorpej Exp $       */
+/*     $NetBSD: ofbus.c,v 1.29 2021/04/30 02:34:12 thorpej Exp $       */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofbus.c,v 1.28 2021/04/27 20:31:01 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofbus.c,v 1.29 2021/04/30 02:34:12 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -71,6 +71,46 @@ ofbus_match(device_t parent, cfdata_t cf
        return (1);
 }
 
+#if defined(__arm32__)         /* XXX temporary */
+#define        _OFBUS_ROOT_MACHDEP_SKIPNAMES                                   \
+       "udp",                                                          \
+       "cpus",                                                         \
+       "mmu",                                                          \
+       "memory"
+#endif /* __arm32__ */
+
+/*
+ * Skip some well-known nodes in the root that contain no useful
+ * child devices.
+ */
+static bool
+ofbus_skip_node_in_root(int phandle, char *name, size_t namesize)
+{
+       static const char * const skip_names[] = {
+               "aliases",
+               "options",
+               "openprom",
+               "chosen",
+               "packages",
+#ifdef _OFBUS_ROOT_MACHDEP_SKIPNAMES
+               _OFBUS_ROOT_MACHDEP_SKIPNAMES
+#endif
+       };
+       u_int i;
+
+       name[0] = '\0';
+       if (OF_getprop(phandle, "name", name, namesize) <= 0) {
+               return false;
+       }
+
+       for (i = 0; i < __arraycount(skip_names); i++) {
+               if (strcmp(name, skip_names[i]) == 0) {
+                       return true;
+               }
+       }
+       return false;
+}
+
 void
 ofbus_attach(device_t parent, device_t dev, void *aux)
 {
@@ -78,12 +118,15 @@ ofbus_attach(device_t parent, device_t d
        struct ofbus_attach_args oba2;
        char name[64], type[64];
        int child, units;
+       bool rootbus;
+
+       rootbus = oba->oba_phandle == OF_finddevice("/");
 
        /*
         * If we are the OFW root, get the banner-name and model
         * properties and display them for informational purposes.
         */
-       if (oba->oba_phandle == OF_finddevice("/")) {
+       if (rootbus) {
                int model_len, banner_len;
 
                model_len = OF_getprop(oba->oba_phandle, "model",
@@ -152,6 +195,10 @@ ofbus_attach(device_t parent, device_t d
                        if (strncmp(type, "display", sizeof(type)) == 0)
                                continue;
                }
+               if (rootbus &&
+                   ofbus_skip_node_in_root(child, name, sizeof(name))) {
+                       continue;
+               }
                of_packagename(child, name, sizeof name);
                oba2.oba_phandle = child;
                for (oba2.oba_unit = 0; oba2.oba_unit < units;
@@ -169,5 +216,4 @@ ofbus_attach(device_t parent, device_t d
                            CFARG_EOL);
                }
        }
-
 }



Home | Main Index | Thread Index | Old Index