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).
This commit is contained in:
thorpej 2021-04-30 02:34:12 +00:00
parent cdc98f9a4e
commit 786ff44585
1 changed files with 50 additions and 4 deletions

View File

@ -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, void *aux)
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 dev, void *aux)
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 dev, void *aux)
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 dev, void *aux)
CFARG_EOL);
}
}
}