mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-24 15:43:11 +00:00
startup: Determine boot CPU by cpu[N].state ADT property
Signed-off-by: Janne Grunau <j@jannau.net>
This commit is contained in:
parent
4bde778779
commit
293e122845
1 changed files with 22 additions and 6 deletions
|
@ -143,11 +143,7 @@ extern void get_device_info(void);
|
||||||
void _start_c(void *boot_args, void *base)
|
void _start_c(void *boot_args, void *base)
|
||||||
{
|
{
|
||||||
UNUSED(base);
|
UNUSED(base);
|
||||||
|
u32 cpu_id = 0;
|
||||||
if (in_el2())
|
|
||||||
msr(TPIDR_EL2, 0);
|
|
||||||
else
|
|
||||||
msr(TPIDR_EL1, 0);
|
|
||||||
|
|
||||||
memset64(_bss_start, 0, _bss_end - _bss_start);
|
memset64(_bss_start, 0, _bss_end - _bss_start);
|
||||||
boot_args_addr = (u64)boot_args;
|
boot_args_addr = (u64)boot_args;
|
||||||
|
@ -156,6 +152,26 @@ void _start_c(void *boot_args, void *base)
|
||||||
adt =
|
adt =
|
||||||
(void *)(((u64)cur_boot_args.devtree) - cur_boot_args.virt_base + cur_boot_args.phys_base);
|
(void *)(((u64)cur_boot_args.devtree) - cur_boot_args.virt_base + cur_boot_args.phys_base);
|
||||||
|
|
||||||
|
#ifndef BRINGUP
|
||||||
|
int node = adt_path_offset(adt, "/cpus");
|
||||||
|
if (node >= 0) {
|
||||||
|
ADT_FOREACH_CHILD(adt, node)
|
||||||
|
{
|
||||||
|
const char *state = adt_getprop(adt, node, "state", NULL);
|
||||||
|
if (!state)
|
||||||
|
continue;
|
||||||
|
if (strcmp(state, "running") == 0)
|
||||||
|
if (ADT_GETPROP(adt, node, "cpu-id", &cpu_id) == sizeof(cpu_id))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (in_el2())
|
||||||
|
msr(TPIDR_EL2, cpu_id);
|
||||||
|
else
|
||||||
|
msr(TPIDR_EL1, cpu_id);
|
||||||
|
|
||||||
int ret = uart_init();
|
int ret = uart_init();
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
debug_putc('!');
|
debug_putc('!');
|
||||||
|
@ -164,7 +180,7 @@ void _start_c(void *boot_args, void *base)
|
||||||
uart_puts("Initializing");
|
uart_puts("Initializing");
|
||||||
get_device_info();
|
get_device_info();
|
||||||
|
|
||||||
printf("CPU init (MIDR: 0x%lx)...\n", mrs(MIDR_EL1));
|
printf("CPU init (MIDR: 0x%lx smp_id:0x%x)...\n", mrs(MIDR_EL1), smp_id());
|
||||||
const char *type = init_cpu();
|
const char *type = init_cpu();
|
||||||
printf(" CPU: %s\n\n", type);
|
printf(" CPU: %s\n\n", type);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue