smp: Add smp_id() and use TPIDR_EL[12] to keep the SMP ID

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2021-09-15 22:00:47 +09:00
parent 571a19c9a3
commit 90b10ef9f7
3 changed files with 20 additions and 0 deletions

View file

@ -28,6 +28,12 @@ extern u8 _vectors_start[0];
void smp_secondary_entry(void)
{
struct spin_table *me = &spin_table[target_cpu];
if (in_el2())
msr(TPIDR_EL2, target_cpu);
else
msr(TPIDR_EL1, target_cpu);
printf(" Index: %d (table: %p)\n\n", target_cpu, me);
me->mpidr = mrs(MPIDR_EL1) & 0xFFFFFF;

View file

@ -28,4 +28,12 @@ bool smp_is_alive(int cpu);
int smp_get_mpidr(int cpu);
u64 smp_get_release_addr(int cpu);
static inline int smp_id(void)
{
if (in_el2())
return mrs(TPIDR_EL2);
else
return mrs(TPIDR_EL1);
}
#endif

View file

@ -72,6 +72,12 @@ void dump_boot_args(struct boot_args *ba)
void _start_c(void *boot_args, void *base)
{
UNUSED(base);
if (in_el2())
msr(TPIDR_EL2, 0);
else
msr(TPIDR_EL1, 0);
memset64(_bss_start, 0, _bss_end - _bss_start);
uart_putchar('s');
uart_init();