int vx_handler(cell_t *argument_array) { char *name; struct vx_cmd *vp; void *old_tba; name = p1275_cell2ptr(*argument_array); for (vp = vx_cmd; vp < vx_cmd_end; vp++) { if (vp->service == (char *)0) continue; if (strcmp(vp->service, name) != 0) continue; if (vp->take_tba != 0) { reestablish_curthread(); if (tba_taken_over != 0) old_tba = set_tba((void *)&trap_table); } vp->func(argument_array); if ((vp->take_tba != 0) && (tba_taken_over != 0)) (void) set_tba(old_tba); return (0); /* Service name was known */ } return (-1); /* Service name unknown */ }
static void ieee_sym_to_value(cell_t *cif) { int error = -1; uintptr_t symvalue = 0; unsigned int nargs, nresults; char *symname; extern int name_to_value(char *name, uintptr_t *value); nargs = p1275_cell2uint(cif[1]); nresults = p1275_cell2uint(cif[2]); if (nresults == 0) return; /* No room for results. Just return. */ /* * If there are no arguments, fall through and return an error. * Otherwise, try to translate the symbol name arg to a value. */ if (nargs != 0) { symname = p1275_cell2ptr(cif[3]); /* argument 0 */ error = name_to_value(symname, &symvalue); } /* * Stuff the results in the argument array and set the * nresults element to the number of results actually returned * in the argument array. (It's a maximum of 2). * * cif[0]: service name ( Pointer to service name ) * cif[1]: nargs ( number of argument cells) * cif[2]: nresults ( number of result cells) * cif[3]: argument{0} ( First argument cell ) * ... * cif[3 + nargs]: result{0} ( First result cell ) * ... */ cif[3 + nargs] = p1275_int2cell(error); if (nresults > 1) { cif[3 + nargs + 1] = p1275_uintptr2cell(symvalue); cif[2] = p1275_int2cell(2); /* there are 2 results */ } else { cif[2] = p1275_int2cell(1); /* there is 1 result */ } }
void * prom_set_callback(void *handler) { cell_t ci[5]; ci[0] = p1275_ptr2cell("set-callback"); /* Service name */ ci[1] = (cell_t)1; /* #argument cells */ ci[2] = (cell_t)1; /* #return cells */ ci[3] = p1275_ptr2cell(handler); /* Arg1: New handler */ ci[4] = (cell_t)-1; /* Res1: Prime result */ promif_preprom(); (void) p1275_cif_handler(&ci); promif_postprom(); return (p1275_cell2ptr(ci[4])); /* Res1: Old handler */ }
char * prom_serengeti_set_console_input(char *new_value) { cell_t ci[5]; int rv; ci[0] = p1275_ptr2cell("SUNW,set-console-input"); ci[1] = (cell_t)1; /* #argument cells */ ci[2] = (cell_t)1; /* #return cells */ ci[3] = p1275_ptr2cell(new_value); promif_preprom(); rv = p1275_cif_handler(&ci); promif_postprom(); if (rv != 0) return (NULL); return (p1275_cell2ptr(ci[4])); }
/* * This is the generic client interface to "claim" memory. * These two routines belong in the common directory. */ caddr_t prom_malloc(caddr_t virt, size_t size, uint_t align) { cell_t ci[7]; int rv; ci[0] = p1275_ptr2cell("claim"); /* Service name */ ci[1] = (cell_t)3; /* #argument cells */ ci[2] = (cell_t)1; /* #result cells */ ci[3] = p1275_ptr2cell(virt); /* Arg1: virt */ ci[4] = p1275_uint2cell(size); /* Arg2: size */ ci[5] = p1275_uint2cell(align); /* Arg3: align */ promif_preprom(); rv = p1275_cif_handler(&ci); promif_postprom(); if (rv == 0) return ((caddr_t)p1275_cell2ptr(ci[6])); /* Res1: base */ return ((caddr_t)-1); }