[arch][[arm64] add a function to translate cpu number to the cpu's ID
Will be used in GICv3 to send IPIs.
This commit is contained in:
@@ -42,4 +42,7 @@ static inline uint arch_curr_cpu_num(void) {
|
|||||||
return pc->cpu_num;
|
return pc->cpu_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Translate a CPU number back to the MPIDR of the CPU.
|
||||||
|
uint64_t arm64_cpu_num_to_mpidr(uint cpu_num);
|
||||||
|
|
||||||
__END_CDECLS
|
__END_CDECLS
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
#include <arch/mp.h>
|
#include <arch/mp.h>
|
||||||
#include <arch/ops.h>
|
#include <arch/ops.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <lk/err.h>
|
#include <lk/err.h>
|
||||||
#include <lk/init.h>
|
#include <lk/init.h>
|
||||||
#include <lk/main.h>
|
#include <lk/main.h>
|
||||||
#include <lk/trace.h>
|
#include <lk/trace.h>
|
||||||
#include <platform/interrupts.h>
|
#include <platform/interrupts.h>
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -143,6 +143,20 @@ void arm64_secondary_entry(ulong asm_cpu_num) {
|
|||||||
}
|
}
|
||||||
#endif // WITH_SMP
|
#endif // WITH_SMP
|
||||||
|
|
||||||
|
uint64_t arm64_cpu_num_to_mpidr(uint cpu_num) {
|
||||||
|
#if WITH_SMP
|
||||||
|
if (cpu_num == 0) {
|
||||||
|
return boot_percpu.mpidr;
|
||||||
|
} else if (unlikely(cpu_num > secondaries_to_init)) {
|
||||||
|
return UINT64_MAX;
|
||||||
|
} else {
|
||||||
|
return secondary_percpu[cpu_num - 1].mpidr;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
return boot_percpu.mpidr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void arm64_mp_init(void) {
|
void arm64_mp_init(void) {
|
||||||
#if WITH_SMP
|
#if WITH_SMP
|
||||||
arm64_mp_init_percpu();
|
arm64_mp_init_percpu();
|
||||||
|
|||||||
Reference in New Issue
Block a user