diff options
author | Dale S. Rahn <rahnds@cvs.openbsd.org> | 2000-09-07 03:30:11 +0000 |
---|---|---|
committer | Dale S. Rahn <rahnds@cvs.openbsd.org> | 2000-09-07 03:30:11 +0000 |
commit | 19e4235262146ff54dfc770cd84e8f85c7850aeb (patch) | |
tree | 30bfcca6ec6344cb83d7a0027122802a33ae0b7d | |
parent | 4d2c2a0851aac3d4e78bcd6660aa3128d4cb8473 (diff) |
add OF_interpret, to obtain output from openfirmware commands.
-rw-r--r-- | sys/arch/powerpc/powerpc/openfirm.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/sys/arch/powerpc/powerpc/openfirm.c b/sys/arch/powerpc/powerpc/openfirm.c index 156eb3c70b3..e4170bb4fca 100644 --- a/sys/arch/powerpc/powerpc/openfirm.c +++ b/sys/arch/powerpc/powerpc/openfirm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openfirm.c,v 1.6 1999/11/09 00:20:42 rahnds Exp $ */ +/* $OpenBSD: openfirm.c,v 1.7 2000/09/07 03:30:10 rahnds Exp $ */ /* $NetBSD: openfirm.c,v 1.1 1996/09/30 16:34:52 ws Exp $ */ /* @@ -147,6 +147,43 @@ OF_getprop(handle, prop, buf, buflen) } int +OF_interpret(char *cmd, int nreturns, ...) +{ + va_list ap; + int i; + static struct { + char *name; + int nargs; + int nreturns; + char *cmd; + int status; + int results[8]; + } args = { + "interpret", + 1, + 2, + }; + + ofw_stack(); + if (nreturns > 8) + return -1; + if ((i = strlen(cmd)) >= NBPG) + return -1; + ofbcopy(cmd, OF_buf, i + 1); + args.cmd = OF_buf; + args.nargs = 1; + args.nreturns = nreturns + 1; + if (openfirmware(&args) == -1) + return -1; + va_start(ap, nreturns); + for (i = 0; i < nreturns; i++) + *va_arg(ap, int *) = args.results[i]; + va_end(ap); + return args.status; +} + + +int OF_finddevice(name) char *name; { |