40,6 → 40,8 |
#include "main.h" |
#include "asm.h" |
|
extern uint8_t subarchitecture; |
|
void write(const char *str, const int len) |
{ |
int i; |
56,46 → 58,28 |
return flag != -1; |
} |
|
int ofw_cpu(void) |
static int wake_cpus_in_node(phandle child, uint64_t current_mid) |
{ |
int cpus; |
char type_name[BUF_SIZE]; |
phandle node; |
phandle ssm; |
|
ssm = ofw_find_device("/ssm@0,0"); |
if (ssm == -1) { |
node = ofw_get_child_node(ofw_root); |
} else { |
node = ofw_get_child_node(ssm); |
} |
|
if (node == 0 || node == -1) { |
printf("Could not find any child nodes of the root node.\n"); |
return 0; |
} |
|
uint64_t current_mid; |
|
asm volatile ("ldxa [%1] %2, %0\n" |
: "=r" (current_mid) |
: "r" (0), "i" (ASI_ICBUS_CONFIG)); |
current_mid >>= ICBUS_CONFIG_MID_SHIFT; |
current_mid &= ICBUS_CONFIG_MID_MASK; |
|
int cpus; |
|
for (cpus = 0; node != 0 && node != -1; node = ofw_get_peer_node(node), |
cpus++) { |
if (ofw_get_property(node, "device_type", type_name, |
for (cpus = 0; child != 0 && child != -1; |
child = ofw_get_peer_node(child), cpus++) { |
if (ofw_get_property(child, "device_type", type_name, |
sizeof(type_name)) > 0) { |
if (strcmp(type_name, "cpu") == 0) { |
uint32_t mid; |
|
/* "upa-portid" for US, "portid" for US-III */ |
/* |
* "upa-portid" for US, "portid" for US-III, |
* "cpuid" for US-IV* |
*/ |
if (ofw_get_property( |
node, "upa-portid", |
child, "upa-portid", |
&mid, sizeof(mid)) <= 0 |
&& ofw_get_property(node, "portid", |
&& ofw_get_property(child, "portid", |
&mid, sizeof(mid)) <= 0 |
&& ofw_get_property(child, "cpuid", |
&mid, sizeof(mid)) <= 0) |
continue; |
|
103,8 → 87,9 |
/* |
* Start secondary processor. |
*/ |
printf("Starting CPU: %d.\n", mid); |
(void) ofw_call("SUNW,start-cpu", 3, 1, |
NULL, node, KERNEL_VIRTUAL_ADDRESS, |
NULL, child, KERNEL_VIRTUAL_ADDRESS, |
bootinfo.physmem_start | |
AP_PROCESSOR); |
} |
115,6 → 100,58 |
return cpus; |
} |
|
int ofw_cpu(void) |
{ |
int cpus; |
phandle node; |
phandle subnode; |
phandle ssm; |
phandle cmp; |
char name[BUF_SIZE]; |
|
/* get the current CPU MID */ |
uint64_t current_mid; |
|
asm volatile ("ldxa [%1] %2, %0\n" |
: "=r" (current_mid) |
: "r" (0), "i" (ASI_ICBUS_CONFIG)); |
current_mid >>= ICBUS_CONFIG_MID_SHIFT; |
|
if (subarchitecture == SUBARCH_US) { |
current_mid &= ICBUS_CONFIG_MID_MASK_US; |
} else if (subarchitecture == SUBARCH_US3) { |
current_mid &= ICBUS_CONFIG_MID_MASK_US3; |
} else { |
printf("MID format unknown for this subarchitecture."); |
return 0; |
} |
|
/* 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); |
} |
} |
node = ofw_get_peer_node(node); |
} |
} |
|
return cpus; |
|
} |
|
/** Get physical memory starting address. |
* |
* @param start Pointer to variable where the physical memory starting |