Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ofw/ofw_cpu.c
Show First 20 Lines • Show All 275 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
int | int | ||||
ofw_cpu_early_foreach(ofw_cpu_foreach_cb callback, boolean_t only_runnable) | ofw_cpu_early_foreach(ofw_cpu_foreach_cb callback, boolean_t only_runnable) | ||||
{ | { | ||||
phandle_t node, child; | phandle_t node, child; | ||||
pcell_t addr_cells, reg[2]; | pcell_t addr_cells, reg[2]; | ||||
char status[16]; | char status[16]; | ||||
char device_type[16]; | |||||
u_int id; | u_int id; | ||||
int count, rv; | int count, rv; | ||||
count = 0; | count = 0; | ||||
id = 0; | id = 0; | ||||
node = OF_finddevice("/cpus"); | node = OF_finddevice("/cpus"); | ||||
if (node == -1) | if (node == -1) | ||||
return (-1); | return (-1); | ||||
/* Find the number of cells in the cpu register */ | /* Find the number of cells in the cpu register */ | ||||
if (OF_getencprop(node, "#address-cells", &addr_cells, | if (OF_getencprop(node, "#address-cells", &addr_cells, | ||||
sizeof(addr_cells)) < 0) | sizeof(addr_cells)) < 0) | ||||
return (-1); | 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)) { | ||||
andrewUnsubmitted Not Done Inline Actionsandrew: u_int next_id;
...
next_id = 0;
...
for (child = OF_child(node); child != 0; 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; | |||||
andrewUnsubmitted Not Done Inline Actionsnext_id++; andrew: next_id++; | |||||
Not Done Inline ActionsThis line will need to be split as it was already at 80 characters. andrew: This line will need to be split as it was already at 80 characters. | |||||
/* | /* | ||||
* If we are filtering by runnable then limit to only | * If we are filtering by runnable then limit to only | ||||
* those that have been enabled. | * those that have been enabled. | ||||
*/ | */ | ||||
if (only_runnable) { | if (only_runnable) { | ||||
status[0] = '\0'; | status[0] = '\0'; | ||||
OF_getprop(child, "status", status, sizeof(status)); | OF_getprop(child, "status", status, sizeof(status)); | ||||
if (status[0] != '\0' && strcmp(status, "okay") != 0) | if (status[0] != '\0' && strcmp(status, "okay") != 0) { | ||||
continue; | goto next; | ||||
andrewUnsubmitted Not Done Inline ActionsThen revert this andrew: Then revert this | |||||
} | } | ||||
} | |||||
/* | /* | ||||
* Check we have a register to identify the cpu | * Check we have a register to identify the cpu | ||||
*/ | */ | ||||
rv = OF_getencprop(child, "reg", reg, | rv = OF_getencprop(child, "reg", reg, | ||||
addr_cells * sizeof(cell_t)); | addr_cells * sizeof(cell_t)); | ||||
if (rv != addr_cells * sizeof(cell_t)) | if (rv != addr_cells * sizeof(cell_t)) | ||||
continue; | goto next; | ||||
andrewUnsubmitted Not Done Inline ActionsAnd this andrew: And this | |||||
if (callback == NULL || callback(id, child, addr_cells, reg)) | if (callback == NULL || callback(id, child, addr_cells, reg)) | ||||
count++; | count++; | ||||
next: | |||||
andrewUnsubmitted Not Done Inline Actionsetc. andrew: etc. | |||||
/* We processed CPU entry, so increase CPU id number */ | |||||
id++; | |||||
} | } | ||||
return (only_runnable ? count : id); | return (only_runnable ? count : id); | ||||
} | } |