Index: sys/dev/ofw/ofw_cpu.c =================================================================== --- sys/dev/ofw/ofw_cpu.c +++ sys/dev/ofw/ofw_cpu.c @@ -281,6 +281,7 @@ phandle_t node, child; pcell_t addr_cells, reg[2]; char status[16]; + char device_type[16]; u_int id; int count, rv; @@ -296,7 +297,17 @@ sizeof(addr_cells)) < 0) return (-1); - for (child = OF_child(node); child != 0; child = OF_peer(child), id++) { + for (child = OF_child(node); child != 0; child = OF_peer(child)) { + + /* Check if child is a CPU */ + memset(device_type, 0, sizeof(device_type)); + rv = OF_getprop(child, "device_type", device_type, + sizeof(device_type) - 1); + if (rv < 0) + continue; + if (strcmp(device_type, "cpu") != 0) + continue; + /* * If we are filtering by runnable then limit to only * those that have been enabled. @@ -304,8 +315,9 @@ if (only_runnable) { status[0] = '\0'; OF_getprop(child, "status", status, sizeof(status)); - if (status[0] != '\0' && strcmp(status, "okay") != 0) - continue; + if (status[0] != '\0' && strcmp(status, "okay") != 0) { + goto next; + } } /* @@ -314,10 +326,13 @@ rv = OF_getencprop(child, "reg", reg, addr_cells * sizeof(cell_t)); if (rv != addr_cells * sizeof(cell_t)) - continue; + goto next; if (callback == NULL || callback(id, child, addr_cells, reg)) count++; +next: + /* We processed CPU entry, so increase CPU id number */ + id++; } return (only_runnable ? count : id);