FreeBSD/sys/dev/ofw/ofw_standard.c
/*  Call the method in the scope of a given instance. */
Call the method in the scope of a given instance.
Call the method in the scope of a given instance .
static int
ofw_std_call_method(ofw_t ofw, ihandle_t instance, const char *method,
    int nargs, int nreturns, cell_t *args_and_returns)
{
	struct {
		cell_t name;
		cell_t nargs;
		cell_t nreturns;
		cell_t method;
		cell_t instance;
		cell_t args_n_results[12];
	} args = {
		(cell_t)"call-method",
		2,
		1,
	};
	cell_t *ap, *cp;
	int n;
	if (nargs > 6)
		return (-1);
	args.nargs = nargs + 2;
	args.nreturns = nreturns + 1;
	args.method = (cell_t)method;
	args.instance = instance;
	ap = args_and_returns;
	for (cp = args.args_n_results + (n = nargs); --n >= 0;)
		*--cp = *(ap++);
	if (openfirmware(&args) == -1)
		return (-1);
	if (args.args_n_results[nargs])
		return (args.args_n_results[nargs]);
	for (cp = args.args_n_results + nargs + (n = args.nreturns); --n > 0;)
		*(ap++) = *--cp;
	return (0);
}
static int ofw_std_call_method ( ofw_t ofw , ihandle_t instance , const char * method , int nargs , int nreturns , cell_t * args_and_returns ) { struct { cell_t name ; cell_t nargs ; cell_t nreturns ; cell_t method ; cell_t instance ; cell_t args_n_results [ 12 ] ; } args = { ( cell_t ) " " , 2 , 1 , } ; cell_t * ap , * cp ; int n ; if ( nargs > 6 ) return ( -1 ) ; args . nargs = nargs + 2 ; args . nreturns = nreturns + 1 ; args . method = ( cell_t ) method ; args . instance = instance ; ap = args_and_returns ; for ( cp = args . args_n_results + ( n = nargs ) ; -- n >= 0 ; ) * -- cp = * ( ap ++ ) ; if ( openfirmware ( & args ) == -1 ) return ( -1 ) ; if ( args . args_n_results [ nargs ] ) return ( args . args_n_results [ nargs ] ) ; for ( cp = args . args_n_results + nargs + ( n = args . nreturns ) ; -- n > 0 ; ) * ( ap ++ ) = * -- cp ; return ( 0 ) ; }
Call the method in the scope of a given instance.
Call the method in the scope of a given instance .