int get_portid(pnode_t node, pnode_t *cmpp) { int portid; int i; char dev_type[OBP_MAXPROPNAME]; pnode_t cpu_parent; if (cmpp != NULL) *cmpp = OBP_NONODE; if (GETPROP(node, "portid", (caddr_t)&portid) != -1) return (portid); if (GETPROP(node, "upa-portid", (caddr_t)&portid) != -1) return (portid); if (GETPROP(node, "device_type", (caddr_t)&dev_type) == -1) return (-1); /* * For a virtual cpu node that is a CMP core, the "portid" * is in the parent node. * For a virtual cpu node that is a CMT strand, the "portid" is * in its grandparent node. * So we iterate up as far as 2 levels to get the "portid". */ if (strcmp(dev_type, "cpu") == 0) { cpu_parent = node = prom_parentnode(node); for (i = 0; i < 2; i++) { if (node == OBP_NONODE || node == OBP_BADNODE) break; if (GETPROP(node, "portid", (caddr_t)&portid) != -1) { if (cmpp != NULL) *cmpp = cpu_parent; return (portid); } node = prom_parentnode(node); } } return (-1); }
ihandle_t get_parent_ihandle(ihandle_t child_ihandle) { char parent_name[OBP_MAXPATHLEN]; phandle_t child_phandle, parent_phandle; child_phandle = prom_getphandle(child_ihandle); parent_phandle = prom_parentnode(child_phandle); prom_phandle_to_path(parent_phandle, parent_name, OBP_MAXPATHLEN); return (prom_open(parent_name)); }
pnode_t kmdb_prom_getcpu_propnode(pnode_t node) { int val; pnode_t pnode; char name[OBP_MAXPROPNAME]; /* * Check for the CMT case where cpu nodes are "strand" nodes * In this case, the "cpu node" properties are contained in * its parent "core" node. */ if (prom_getprop(node, "portid", (caddr_t)&val) == -1 && prom_getprop(node, "upa-portid", (caddr_t)&val) == -1 && prom_getprop((pnode = prom_parentnode(node)), "name", name) != -1 && strcmp(name, "core") == 0) return (pnode); return (node); }