Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/25627
Change subject: soc/intel/common/block/cpu/cpulib: Add function to get cpu_slot based on APIC ID ......................................................................
soc/intel/common/block/cpu/cpulib: Add function to get cpu_slot based on APIC ID
This function make use of mp_get_apic_id() function to return cpu_slot else retrun -1 on failure.
BRANCH=none BUG=b:74436746 TEST=Able to get cpu_slot based on running APs
Change-Id: Ib9172a4938f25998755593524122b787e9b00294 Signed-off-by: Subrata Banik subrata.banik@intel.com --- M src/soc/intel/common/block/cpu/cpulib.c M src/soc/intel/common/block/include/intelblocks/cpulib.h 2 files changed, 20 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/27/25627/1
diff --git a/src/soc/intel/common/block/cpu/cpulib.c b/src/soc/intel/common/block/cpu/cpulib.c index ed1ba0f..b435e73 100644 --- a/src/soc/intel/common/block/cpu/cpulib.c +++ b/src/soc/intel/common/block/cpu/cpulib.c @@ -18,6 +18,8 @@ #include <arch/io.h> #include <console/console.h> #include <cpu/intel/turbo.h> +#include <cpu/x86/lapic.h> +#include <cpu/x86/mp.h> #include <cpu/x86/msr.h> #include <cpu/x86/mtrr.h> #include <delay.h> @@ -334,3 +336,17 @@ msr.hi = pat >> 32; wrmsr(MSR_IA32_PAT, msr); } + +/* Get the working processor number by APIC ID */ +int cpu_get_processor_number(uint32_t *cpu_slot) +{ + int i; + + for (i = 0; i < CONFIG_MAX_CPUS; i++) { + if (mp_get_apic_id(i) == lapicid()) { + *cpu_slot = i; + return 0; + } + } + return -1; +} diff --git a/src/soc/intel/common/block/include/intelblocks/cpulib.h b/src/soc/intel/common/block/include/intelblocks/cpulib.h index 0c7f2c4..37bcb59 100644 --- a/src/soc/intel/common/block/include/intelblocks/cpulib.h +++ b/src/soc/intel/common/block/include/intelblocks/cpulib.h @@ -164,4 +164,8 @@
/* Set PAT MSR */ void set_pat(uint64_t pat); + +/* Get the working processor number by APIC ID */ +int cpu_get_processor_number(uint32_t *cpu_slot); + #endif /* SOC_INTEL_COMMON_BLOCK_CPULIB_H */