static struct device_node * __init prom_build_tree(struct device_node *parent, phandle node, struct device_node ***nextp) { struct device_node *ret = NULL, *prev_sibling = NULL; struct device_node *dp; while (1) { dp = prom_create_node(node, parent); if (!dp) break; if (prev_sibling) prev_sibling->sibling = dp; if (!ret) ret = dp; prev_sibling = dp; *(*nextp) = dp; *nextp = &dp->allnext; dp->path_component_name = build_path_component(dp); dp->full_name = build_full_name(dp); dp->child = prom_build_tree(dp, prom_getchild(node), nextp); if (prom_build_more) prom_build_more(dp, nextp); node = prom_getsibling(node); } return ret; }
void __init prom_build_devicetree(void) { struct device_node **nextp; allnodes = prom_create_node(prom_root_node, NULL); allnodes->path_component_name = ""; allnodes->full_name = "/"; nextp = &allnodes->allnext; allnodes->child = prom_build_tree(allnodes, prom_getchild(allnodes->phandle), &nextp); of_console_init(); printk("PROM: Built device tree with %u bytes of memory.\n", prom_early_allocated); }
static int osip_prom_path_iface( int sel, int *args ) { char *path = transl_mphys( args[1] ); int ret; if( !args[1] || !path ) return -1; switch( args[0] ) { case kPromCreateNode: ret = to_ph( prom_create_node(path) ); return (!ret)? -1 : ret; case kPromFindDevice: ret = to_ph( prom_find_dev_by_path(path) ); return (!ret)? -1 : ret; default: printm("bad selector\n"); } return -1; }