soc/intel/common/block: fix storage size of HEST log address
[coreboot.git] / src / arch / x86 / cpu_common.c
blob07de1553b89ac4ab0f18da59fcc39a28777d9030
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <cpu/cpu.h>
5 #ifndef __x86_64__
6 /* Standard macro to see if a specific flag is changeable */
7 static inline int flag_is_changeable_p(uint32_t flag)
9 uint32_t f1, f2;
11 asm(
12 "pushfl\n\t"
13 "pushfl\n\t"
14 "popl %0\n\t"
15 "movl %0,%1\n\t"
16 "xorl %2,%0\n\t"
17 "pushl %0\n\t"
18 "popfl\n\t"
19 "pushfl\n\t"
20 "popl %0\n\t"
21 "popfl\n\t"
22 : "=&r" (f1), "=&r" (f2)
23 : "ir" (flag));
24 return ((f1^f2) & flag) != 0;
27 /* Probe for the CPUID instruction */
28 int cpu_have_cpuid(void)
30 return flag_is_changeable_p(X86_EFLAGS_ID);
33 #else
35 int cpu_have_cpuid(void)
37 return 1;
39 #endif
41 unsigned int cpu_cpuid_extended_level(void)
43 return cpuid_eax(0x80000000);
46 int cpu_phys_address_size(void)
48 if (!(cpu_have_cpuid()))
49 return 32;
51 if (cpu_cpuid_extended_level() >= 0x80000008)
52 return cpuid_eax(0x80000008) & 0xff;
54 if (cpuid_edx(1) & (CPUID_FEATURE_PAE | CPUID_FEATURE_PSE36))
55 return 36;
56 return 32;
60 * Get processor id using cpuid eax=1
61 * return value in EAX register
63 uint32_t cpu_get_cpuid(void)
65 return cpuid_eax(1);
69 * Get processor feature flag using cpuid eax=1
70 * return value in ECX register
72 uint32_t cpu_get_feature_flags_ecx(void)
74 return cpuid_ecx(1);
78 * Get processor feature flag using cpuid eax=1
79 * return value in EDX register
81 uint32_t cpu_get_feature_flags_edx(void)
83 return cpuid_edx(1);