diff options
author | Glauber de Oliveira Costa <gcosta@redhat.com> | 2008-01-30 07:31:03 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:31:03 -0500 |
commit | c758ecf62ad94ddfeb4e7d8a5498bdcb2e3c85db (patch) | |
tree | 6a7b8b629bbe935c78cf3933b0cfe25253c563a9 /include/asm-x86/processor.h | |
parent | 4e87173eacfd0d798aeeba14026893797826bc93 (diff) |
x86: unify cpuid functions
cpuid is not very different between i386 and x86_64.
We move away the x86_64 version from msr.h, and
unify them at processor.h, where they belong.
cpuid() paravirt then comes for free.
Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/asm-x86/processor.h')
-rw-r--r-- | include/asm-x86/processor.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/include/asm-x86/processor.h b/include/asm-x86/processor.h index 46e1c04e309c..dea81b70895d 100644 --- a/include/asm-x86/processor.h +++ b/include/asm-x86/processor.h | |||
@@ -1,5 +1,83 @@ | |||
1 | #ifndef __ASM_X86_PROCESSOR_H | ||
2 | #define __ASM_X86_PROCESSOR_H | ||
3 | |||
4 | static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, | ||
5 | unsigned int *ecx, unsigned int *edx) | ||
6 | { | ||
7 | /* ecx is often an input as well as an output. */ | ||
8 | __asm__("cpuid" | ||
9 | : "=a" (*eax), | ||
10 | "=b" (*ebx), | ||
11 | "=c" (*ecx), | ||
12 | "=d" (*edx) | ||
13 | : "0" (*eax), "2" (*ecx)); | ||
14 | } | ||
15 | |||
16 | |||
1 | #ifdef CONFIG_X86_32 | 17 | #ifdef CONFIG_X86_32 |
2 | # include "processor_32.h" | 18 | # include "processor_32.h" |
3 | #else | 19 | #else |
4 | # include "processor_64.h" | 20 | # include "processor_64.h" |
5 | #endif | 21 | #endif |
22 | |||
23 | #ifndef CONFIG_PARAVIRT | ||
24 | #define __cpuid native_cpuid | ||
25 | #endif | ||
26 | |||
27 | /* | ||
28 | * Generic CPUID function | ||
29 | * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx | ||
30 | * resulting in stale register contents being returned. | ||
31 | */ | ||
32 | static inline void cpuid(unsigned int op, | ||
33 | unsigned int *eax, unsigned int *ebx, | ||
34 | unsigned int *ecx, unsigned int *edx) | ||
35 | { | ||
36 | *eax = op; | ||
37 | *ecx = 0; | ||
38 | __cpuid(eax, ebx, ecx, edx); | ||
39 | } | ||
40 | |||
41 | /* Some CPUID calls want 'count' to be placed in ecx */ | ||
42 | static inline void cpuid_count(unsigned int op, int count, | ||
43 | unsigned int *eax, unsigned int *ebx, | ||
44 | unsigned int *ecx, unsigned int *edx) | ||
45 | { | ||
46 | *eax = op; | ||
47 | *ecx = count; | ||
48 | __cpuid(eax, ebx, ecx, edx); | ||
49 | } | ||
50 | |||
51 | /* | ||
52 | * CPUID functions returning a single datum | ||
53 | */ | ||
54 | static inline unsigned int cpuid_eax(unsigned int op) | ||
55 | { | ||
56 | unsigned int eax, ebx, ecx, edx; | ||
57 | |||
58 | cpuid(op, &eax, &ebx, &ecx, &edx); | ||
59 | return eax; | ||
60 | } | ||
61 | static inline unsigned int cpuid_ebx(unsigned int op) | ||
62 | { | ||
63 | unsigned int eax, ebx, ecx, edx; | ||
64 | |||
65 | cpuid(op, &eax, &ebx, &ecx, &edx); | ||
66 | return ebx; | ||
67 | } | ||
68 | static inline unsigned int cpuid_ecx(unsigned int op) | ||
69 | { | ||
70 | unsigned int eax, ebx, ecx, edx; | ||
71 | |||
72 | cpuid(op, &eax, &ebx, &ecx, &edx); | ||
73 | return ecx; | ||
74 | } | ||
75 | static inline unsigned int cpuid_edx(unsigned int op) | ||
76 | { | ||
77 | unsigned int eax, ebx, ecx, edx; | ||
78 | |||
79 | cpuid(op, &eax, &ebx, &ecx, &edx); | ||
80 | return edx; | ||
81 | } | ||
82 | |||
83 | #endif | ||