Sridhar Siricilla has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/59357 )
Change subject: cpu/intel: Get cpu index based on LAPIC id ......................................................................
cpu/intel: Get cpu index based on LAPIC id
The patch adds a method to provide cpu index based on LAPCI Id. The function determines the cpu's LAPIC id and returns the position of the cpu's LAPIC id among the other cores' LAPIC ids. ` TEST=Verified on Brya
Signed-off-by: Sridhar Siricilla sridhar.siricilla@intel.com Change-Id: If18116472aaa78cfa88350f313c246a28f67303d --- M src/cpu/x86/mp_init.c M src/include/cpu/x86/mp.h 2 files changed, 19 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/57/59357/1
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c index c99732f..e8df692 100644 --- a/src/cpu/x86/mp_init.c +++ b/src/cpu/x86/mp_init.c @@ -207,6 +207,19 @@ park_this_cpu(NULL); }
+uint32_t get_cpu_index(void) +{ + int i; + uint32_t cpu_index = 0; + uint32_t my_apic_id = lapicid(); + + for (i = 0; i < global_num_aps + 1; i++) + if (my_apic_id >= cpus_dev[i]->path.apic.apic_id) + cpu_index++; + + return cpu_index; +} + static void setup_default_sipi_vector_params(struct sipi_params *sp) { sp->gdt = (uintptr_t)&gdt; diff --git a/src/include/cpu/x86/mp.h b/src/include/cpu/x86/mp.h index 7ed82dd..12241fc 100644 --- a/src/include/cpu/x86/mp.h +++ b/src/include/cpu/x86/mp.h @@ -146,4 +146,10 @@ /* Send SMI to self with single execution. */ void smm_initiate_relocation(void);
+/* + * Returns cpu's index based on the position of the cpu's lapic id among other cpus' + * lapic ids. + */ +uint32_t get_cpu_index(void); + #endif /* _X86_MP_H_ */