58,6 → 58,16 |
return flag != -1; |
} |
|
/** |
* Starts all CPUs represented by following siblings of the given node, |
* except for the current CPU. |
* |
* @param child the first child of the OFW tree node whose children represent |
* CPUs to be woken up |
* @param current_mid MID of the current CPU, the current CPU will |
* (of course) not be woken up |
* @return number of CPUs which have the same parent node as "child" |
*/ |
static int wake_cpus_in_node(phandle child, uint64_t current_mid) |
{ |
int cpus; |
87,7 → 97,6 |
/* |
* Start secondary processor. |
*/ |
printf("Starting CPU: %d.\n", mid); |
(void) ofw_call("SUNW,start-cpu", 3, 1, |
NULL, child, KERNEL_VIRTUAL_ADDRESS, |
bootinfo.physmem_start | |
100,12 → 109,15 |
return cpus; |
} |
|
/** |
* Finds out the current CPU's MID and wakes up all AP processors. |
*/ |
int ofw_cpu(void) |
{ |
int cpus; |
phandle node; |
phandle subnode; |
phandle ssm; |
phandle cpus_parent; |
phandle cmp; |
char name[BUF_SIZE]; |
|
127,25 → 139,24 |
} |
|
/* wake up CPUs */ |
ssm = ofw_find_device("/ssm@0,0"); |
if (ssm == -1) { |
node = ofw_get_child_node(ofw_root); |
cpus = wake_cpus_in_node(node, current_mid); |
} else { |
node = ofw_get_child_node(ssm); |
cpus = wake_cpus_in_node(node, current_mid); |
while (node != 0 && node != -1) { |
if (ofw_get_property(node, "name", name, |
sizeof(name)) > 0) { |
if (strcmp(name, "cmp") == 0) { |
printf("nasel jsem dalsi CPU"); |
subnode = ofw_get_child_node(node); |
cpus += wake_cpus_in_node(subnode, |
current_mid); |
} |
|
cpus_parent = ofw_find_device("/ssm@0,0"); |
if (cpus_parent == 0 || cpus_parent == -1) { |
cpus_parent = ofw_find_device("/"); |
} |
|
node = ofw_get_child_node(cpus_parent); |
cpus = wake_cpus_in_node(node, current_mid); |
while (node != 0 && node != -1) { |
if (ofw_get_property(node, "name", name, |
sizeof(name)) > 0) { |
if (strcmp(name, "cmp") == 0) { |
subnode = ofw_get_child_node(node); |
cpus += wake_cpus_in_node(subnode, |
current_mid); |
} |
node = ofw_get_peer_node(node); |
} |
} |
node = ofw_get_peer_node(node); |
} |
|
return cpus; |