int prom_pathname(char *pathname) { char *from = buffer; char *to = pathname; cell_t ci[7]; if ((to == (char *)0) || (*to == (char)0)) return; (void) prom_strcpy(from, to); *to = (char)0; ci[0] = p1275_ptr2cell("canon"); /* Service name */ ci[1] = (cell_t)3; /* #argument cells */ ci[2] = (cell_t)1; /* #result cells */ ci[3] = p1275_ptr2cell(from); /* Arg1: device specifier */ ci[4] = p1275_ptr2cell(to); /* Arg2: buffer address */ ci[5] = p1275_uint2cell(OBP_MAXPATHLEN); /* Arg3: buffer length */ ci[6] = (cell_t)-1; (void) p1275_cif_handler(&ci); return (p1275_cell2int(ci[6])); /* Res1: length */ }
/* * Here we use the "screen-#columns" and "screen-#rows" settings of * PROM to help us decide the console size and cursor position. The * actual sizes of PROM's TEM and the console might be different with * those "screen-#.." settings, in cases that they are too big to * accommodate. */ void prom_get_tem_size(size_t *height, size_t *width) { char buf[MAXPATHLEN]; char name[16]; pnode_t node; int len; if ((node = prom_optionsnode()) == OBP_BADNODE) return; (void) prom_strcpy(name, "screen-#rows"); if ((len = prom_getproplen(node, (caddr_t)name)) > 0) { (void) prom_getprop(node, (caddr_t)name, (caddr_t)buf); *height = prom_atol(buf, len); } (void) prom_strcpy(name, "screen-#columns"); if ((len = prom_getproplen(node, (caddr_t)name)) > 0) { (void) prom_getprop(node, (caddr_t)name, (caddr_t)buf); *width = prom_atol(buf, len); } }
caddr_t prom_nextprop(pnode_t nodeid, caddr_t previous, caddr_t next) { cell_t ci[7]; (void) prom_strcpy(next, ""); /* Prime result, in case call fails */ ci[0] = p1275_ptr2cell("nextprop"); /* Service name */ ci[1] = (cell_t)3; /* #argument cells */ ci[2] = (cell_t)0; /* #result cells */ ci[3] = p1275_phandle2cell((phandle_t)nodeid); /* Arg1: phandle */ ci[4] = p1275_ptr2cell(previous); /* Arg2: addr of prev name */ ci[5] = p1275_ptr2cell(next); /* Arg3: addr of 32 byte buf */ promif_preprom(); (void) p1275_cif_handler(&ci); promif_postprom(); return (next); }
/* * Returns 0 on error. Otherwise returns a handle. */ int prom_open(char *path) { cell_t ci[5]; promif_owrap_t *ow; #ifdef PROM_32BIT_ADDRS char *opath = NULL; size_t len; if ((uintptr_t)path > (uint32_t)-1) { opath = path; len = prom_strlen(opath) + 1; /* include terminating NUL */ path = promplat_alloc(len); if (path == NULL) return (0); (void) prom_strcpy(path, opath); } #endif ow = promif_preout(); promif_preprom(); ci[0] = p1275_ptr2cell("open"); /* Service name */ ci[1] = (cell_t)1; /* #argument cells */ ci[2] = (cell_t)1; /* #result cells */ ci[3] = p1275_ptr2cell(path); /* Arg1: Pathname */ ci[4] = (cell_t)0; /* Res1: Prime result */ (void) p1275_cif_handler(&ci); promif_postprom(); promif_postout(ow); #ifdef PROM_32BIT_ADDRS if (opath != NULL) promplat_free(path, len); #endif return (p1275_cell2int(ci[4])); /* Res1: ihandle */ }
pnode_t prom_finddevice(char *path) { cell_t ci[5]; #ifdef PROM_32BIT_ADDRS char *opath = NULL; size_t len; if ((uintptr_t)path > (uint32_t)-1) { opath = path; len = prom_strlen(opath) + 1; /* include terminating NUL */ path = promplat_alloc(len); if (path == NULL) { return (OBP_BADNODE); } (void) prom_strcpy(path, opath); } #endif promif_preprom(); ci[0] = p1275_ptr2cell("finddevice"); /* Service name */ ci[1] = (cell_t)1; /* #argument cells */ ci[2] = (cell_t)1; /* #result cells */ ci[3] = p1275_ptr2cell(path); /* Arg1: pathname */ ci[4] = p1275_dnode2cell(OBP_BADNODE); /* Res1: Prime result */ (void) p1275_cif_handler(&ci); promif_postprom(); #ifdef PROM_32BIT_ADDRS if (opath != NULL) promplat_free(path, len); #endif return ((pnode_t)p1275_cell2dnode(ci[4])); /* Res1: phandle */ }