diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2004-01-11 16:22:31 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2004-01-11 16:22:31 +0000 |
commit | b7e3701a995b5be8086b192557f42c47dfa09723 (patch) | |
tree | 2a2588e40ee33b62fb5ef3a1fa4637d91c4dfbb8 /sys/arch/macppc | |
parent | 61ab758bf63b495d25f93dd41e1d7e57f74d702c (diff) |
Add OF_getnodebyname interface to openfirmware, from netbsd.
Diffstat (limited to 'sys/arch/macppc')
-rw-r--r-- | sys/arch/macppc/macppc/openfirm.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/sys/arch/macppc/macppc/openfirm.c b/sys/arch/macppc/macppc/openfirm.c index 3126a6b82c2..6e57de3f794 100644 --- a/sys/arch/macppc/macppc/openfirm.c +++ b/sys/arch/macppc/macppc/openfirm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openfirm.c,v 1.6 2004/01/07 22:45:59 brad Exp $ */ +/* $OpenBSD: openfirm.c,v 1.7 2004/01/11 16:22:30 drahn Exp $ */ /* $NetBSD: openfirm.c,v 1.1 1996/09/30 16:34:52 ws Exp $ */ /* @@ -263,3 +263,30 @@ ofbcopy(const void *src, void *dst, size_t len) *dp++ = *sp++; } +int +OF_getnodebyname(int start, const char *name) +{ + char nname[32]; + int len; + int node = 0; + int next; + + if (node == 0) + node = OF_peer(0); + + for (node = start; node; node = next) { + len = OF_getprop(node, "name", nname, sizeof(nname)); + nname[len] = 0; + if (strcmp(nname, name) == 0) { + return node; + } + if ((next = OF_child(node)) != 0) + continue; + while (node) { + if ((next = OF_peer(node)) != 0) + break; + node = OF_parent(node); + } + } + return node; +} |