Make OF_interpret() handle input and output arguments.
This commit is contained in:
parent
5a7a518e05
commit
2375794907
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: openfirm.h,v 1.8 2001/07/20 00:07:14 eeh Exp $ */
|
||||
/* $NetBSD: openfirm.h,v 1.9 2001/10/05 21:52:43 eeh Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
|
@ -56,7 +56,7 @@ void OF_set_symbol_lookup (void (*s2v)(void *), void (*v2s)(void *));
|
|||
void OF_poweroff (void) __attribute__((__noreturn__));
|
||||
void OF_sym2val (void *);
|
||||
void OF_val2sym (void *);
|
||||
void OF_interpret (char *);
|
||||
int OF_interpret (char *, int, int, ...);
|
||||
int OF_milliseconds (void);
|
||||
int OF_searchprop (int node, char *prop, void *buf, int buflen);
|
||||
int OF_mapintr(int node, int *interrupt, int validlen, int buflen);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: autoconf.c,v 1.53 2001/10/05 15:28:28 pooka Exp $ */
|
||||
/* $NetBSD: autoconf.c,v 1.54 2001/10/05 21:52:43 eeh Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
|
@ -72,7 +72,6 @@
|
|||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <machine/bsd_openprom.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/openfirm.h>
|
||||
|
@ -911,18 +910,6 @@ node_has_property(node, prop) /* returns 1 if node has given property */
|
|||
}
|
||||
|
||||
#ifdef RASTERCONSOLE
|
||||
/* Pass a string to the FORTH PROM to be interpreted */
|
||||
void
|
||||
rominterpret(s)
|
||||
register char *s;
|
||||
{
|
||||
|
||||
if (promvec->pv_romvec_vers < 2)
|
||||
promvec->pv_fortheval.v0_eval(strlen(s), s);
|
||||
else
|
||||
promvec->pv_fortheval.v2_eval(s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to figure out where the PROM stores the cursor row & column
|
||||
* variables. Returns nonzero on error.
|
||||
|
@ -931,24 +918,18 @@ int
|
|||
romgetcursoraddr(rowp, colp)
|
||||
register int **rowp, **colp;
|
||||
{
|
||||
char buf[100];
|
||||
cell_t row = NULL, col = NULL;
|
||||
|
||||
OF_interpret("stdout @ is my-self addr line# addr column# ", 0, 2,
|
||||
&col, &row);
|
||||
/*
|
||||
* line# and column# are global in older proms (rom vector < 2)
|
||||
* and in some newer proms. They are local in version 2.9. The
|
||||
* correct cutoff point is unknown, as yet; we use 2.9 here.
|
||||
* We are running on a 64-bit machine, so these things point to
|
||||
* 64-bit values. To convert them to pointers to integers, add
|
||||
* 4 to the address.
|
||||
*/
|
||||
if (promvec->pv_romvec_vers < 2 || promvec->pv_printrev < 0x00020009)
|
||||
sprintf(buf,
|
||||
"' line# >body >user %lx ! ' column# >body >user %lx !",
|
||||
(u_long)rowp, (u_long)colp);
|
||||
else
|
||||
sprintf(buf,
|
||||
"stdout @ is my-self addr line# %lx ! addr column# %lx !",
|
||||
(u_long)rowp, (u_long)colp);
|
||||
*rowp = *colp = NULL;
|
||||
rominterpret(buf);
|
||||
return (*rowp == NULL || *colp == NULL);
|
||||
*rowp = (int *)(row+4);
|
||||
*colp = (int *)(col+4);
|
||||
return (row == NULL || col == NULL);
|
||||
}
|
||||
#endif /* RASTERCONSOLE */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: openfirm.c,v 1.14 2001/09/24 13:22:34 wiz Exp $ */
|
||||
/* $NetBSD: openfirm.c,v 1.15 2001/10/05 21:52:43 eeh Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
|
@ -720,23 +720,42 @@ OF_set_symbol_lookup(s2v, v2s)
|
|||
(void)openfirmware(&args);
|
||||
}
|
||||
|
||||
void
|
||||
OF_interpret(s)
|
||||
char *s;
|
||||
int
|
||||
#ifdef __STDC__
|
||||
OF_interpret(char *cmd, int nargs, int nreturns, ...)
|
||||
#else
|
||||
OF_interpret(cmd, nargs, nreturns, va_alist)
|
||||
char *cmd;
|
||||
int nargs;
|
||||
int nreturns;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
struct {
|
||||
cell_t name;
|
||||
cell_t nargs;
|
||||
cell_t nreturns;
|
||||
cell_t verbs;
|
||||
cell_t status;
|
||||
cell_t slot[16];
|
||||
} args;
|
||||
cell_t status;
|
||||
int i = 0;
|
||||
|
||||
args.name = ADR2CELL(&"interpret");
|
||||
args.nargs = 1;
|
||||
args.nreturns = 1;
|
||||
args.verbs = ADR2CELL(s);
|
||||
openfirmware(&args);
|
||||
args.nargs = ++nargs;
|
||||
args.nreturns = ++nreturns;
|
||||
args.slot[i++] = ADR2CELL(cmd);
|
||||
va_start(ap, nreturns);
|
||||
while (i < nargs) {
|
||||
args.slot[i++] = va_arg(ap, cell_t);
|
||||
}
|
||||
if (openfirmware(&args) == -1)
|
||||
return (-1);
|
||||
status = args.slot[i++];
|
||||
while (i < nargs+nreturns) {
|
||||
*va_arg(ap, cell_t *) = args.slot[i++];
|
||||
}
|
||||
return (status);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in New Issue