summaryrefslogtreecommitdiff
path: root/arch/x86/include/asm/cpu.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/include/asm/cpu.h')
-rw-r--r--arch/x86/include/asm/cpu.h91
1 files changed, 37 insertions, 54 deletions
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index fd389d4024c..5d24c17f8a3 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -58,6 +58,10 @@ enum {
X86_SYSCON_PUNIT, /* Power unit */
};
+#define CPUID_FEATURE_PAE BIT(6)
+#define CPUID_FEATURE_PSE36 BIT(17)
+#define CPUID_FEAURE_HTT BIT(28)
+
struct cpuid_result {
uint32_t eax;
uint32_t ebx;
@@ -105,68 +109,47 @@ static inline struct cpuid_result cpuid_ext(int op, unsigned ecx)
return result;
}
-/*
- * CPUID functions returning a single datum
- */
-static inline unsigned int cpuid_eax(unsigned int op)
+static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
{
- unsigned int eax;
-
- __asm__("mov %%ebx, %%edi;"
- "cpuid;"
- "mov %%edi, %%ebx;"
- : "=a" (eax)
- : "0" (op)
- : "ecx", "edx", "edi");
- return eax;
+ /* ecx is often an input as well as an output. */
+ asm volatile("cpuid"
+ : "=a" (*eax),
+ "=b" (*ebx),
+ "=c" (*ecx),
+ "=d" (*edx)
+ : "0" (*eax), "2" (*ecx)
+ : "memory");
}
-static inline unsigned int cpuid_ebx(unsigned int op)
-{
- unsigned int eax, ebx;
-
- __asm__("mov %%ebx, %%edi;"
- "cpuid;"
- "mov %%ebx, %%esi;"
- "mov %%edi, %%ebx;"
- : "=a" (eax), "=S" (ebx)
- : "0" (op)
- : "ecx", "edx", "edi");
- return ebx;
+#define native_cpuid_reg(reg) \
+static inline unsigned int cpuid_##reg(unsigned int op) \
+{ \
+ unsigned int eax = op, ebx, ecx = 0, edx; \
+ \
+ native_cpuid(&eax, &ebx, &ecx, &edx); \
+ \
+ return reg; \
}
-static inline unsigned int cpuid_ecx(unsigned int op)
-{
- unsigned int eax, ecx;
-
- __asm__("mov %%ebx, %%edi;"
- "cpuid;"
- "mov %%edi, %%ebx;"
- : "=a" (eax), "=c" (ecx)
- : "0" (op)
- : "edx", "edi");
- return ecx;
-}
+/*
+ * Native CPUID functions returning a single datum.
+ */
+native_cpuid_reg(eax)
+native_cpuid_reg(ebx)
+native_cpuid_reg(ecx)
+native_cpuid_reg(edx)
-static inline unsigned int cpuid_edx(unsigned int op)
+#if CONFIG_IS_ENABLED(X86_64)
+static inline int flag_is_changeable_p(u32 flag)
{
- unsigned int eax, edx;
-
- __asm__("mov %%ebx, %%edi;"
- "cpuid;"
- "mov %%edi, %%ebx;"
- : "=a" (eax), "=d" (edx)
- : "0" (op)
- : "ecx", "edi");
- return edx;
+ return 1;
}
-
-#if !CONFIG_IS_ENABLED(X86_64)
-
+#else
/* Standard macro to see if a specific flag is changeable */
-static inline int flag_is_changeable_p(uint32_t flag)
+static inline int flag_is_changeable_p(u32 flag)
{
- uint32_t f1, f2;
+ u32 f1, f2;
asm(
"pushfl\n\t"
@@ -181,9 +164,9 @@ static inline int flag_is_changeable_p(uint32_t flag)
"popfl\n\t"
: "=&r" (f1), "=&r" (f2)
: "ir" (flag));
- return ((f1^f2) & flag) != 0;
+ return ((f1 ^ f2) & flag) != 0;
}
-#endif
+#endif /* X86_64 */
/**
* cpu_enable_paging_pae() - Enable PAE-paging