Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/32130
Change subject: arch/x86/cpu: Add functions to determine CPU vendor ......................................................................
arch/x86/cpu: Add functions to determine CPU vendor
Add two functions to determine if CPU is made by a specific vendor. Use Kconfig symbols and CPUID to determine the CPU vendor.
Change-Id: I1bd6c3b59cfd992f7ba507bc9f9269669920b24f Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/arch/x86/cpu.c M src/arch/x86/include/arch/cpu.h 2 files changed, 34 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/30/32130/1
diff --git a/src/arch/x86/cpu.c b/src/arch/x86/cpu.c index 80d4d0d..e82df00 100644 --- a/src/arch/x86/cpu.c +++ b/src/arch/x86/cpu.c @@ -196,6 +196,36 @@ } }
+bool cpu_is_amd(void) +{ + if (CONFIG(CPU_AMD_AGESA) || CONFIG(CPU_AMD_PI)) + return true; + else if (CONFIG(CPU_INTEL_COMMON) || CONFIG(SOC_INTEL_COMMON)) + return false; + else if (cpu_have_cpuid()) { + struct device cpu; + identify_cpu(&cpu); + return cpu.vendor == X86_VENDOR_AMD; + } + + return false; +} + +bool cpu_is_intel(void) +{ + if (CONFIG(CPU_INTEL_COMMON) || CONFIG(SOC_INTEL_COMMON)) + return true; + else if (CONFIG(CPU_AMD_AGESA) || CONFIG(CPU_AMD_PI)) + return false; + else if (cpu_have_cpuid()) { + struct device cpu; + identify_cpu(&cpu); + return cpu.vendor == X86_VENDOR_INTEL; + } + + return false; +} + struct cpu_driver *find_cpu_driver(struct device *cpu) { struct cpu_driver *driver; diff --git a/src/arch/x86/include/arch/cpu.h b/src/arch/x86/include/arch/cpu.h index b40dd1b..ce4ae11 100644 --- a/src/arch/x86/include/arch/cpu.h +++ b/src/arch/x86/include/arch/cpu.h @@ -217,6 +217,10 @@ ci = cpu_info(); return ci->index; } + +bool cpu_is_amd(void); +bool cpu_is_intel(void); + #endif
#ifndef __ROMCC__ // romcc is segfaulting in some cases