Glauber de Oliveira Costa | c758ecf | 2008-01-30 13:31:03 +0100 | [diff] [blame] | 1 | #ifndef __ASM_X86_PROCESSOR_H |
| 2 | #define __ASM_X86_PROCESSOR_H |
| 3 | |
Glauber de Oliveira Costa | 053de04 | 2008-01-30 13:31:27 +0100 | [diff] [blame^] | 4 | #include <asm/processor-flags.h> |
| 5 | |
Glauber de Oliveira Costa | c758ecf | 2008-01-30 13:31:03 +0100 | [diff] [blame] | 6 | static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, |
| 7 | unsigned int *ecx, unsigned int *edx) |
| 8 | { |
| 9 | /* ecx is often an input as well as an output. */ |
| 10 | __asm__("cpuid" |
| 11 | : "=a" (*eax), |
| 12 | "=b" (*ebx), |
| 13 | "=c" (*ecx), |
| 14 | "=d" (*edx) |
| 15 | : "0" (*eax), "2" (*ecx)); |
| 16 | } |
| 17 | |
| 18 | |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 19 | #ifdef CONFIG_X86_32 |
| 20 | # include "processor_32.h" |
| 21 | #else |
| 22 | # include "processor_64.h" |
| 23 | #endif |
Glauber de Oliveira Costa | c758ecf | 2008-01-30 13:31:03 +0100 | [diff] [blame] | 24 | |
| 25 | #ifndef CONFIG_PARAVIRT |
| 26 | #define __cpuid native_cpuid |
| 27 | #endif |
| 28 | |
| 29 | /* |
| 30 | * Generic CPUID function |
| 31 | * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx |
| 32 | * resulting in stale register contents being returned. |
| 33 | */ |
| 34 | static inline void cpuid(unsigned int op, |
| 35 | unsigned int *eax, unsigned int *ebx, |
| 36 | unsigned int *ecx, unsigned int *edx) |
| 37 | { |
| 38 | *eax = op; |
| 39 | *ecx = 0; |
| 40 | __cpuid(eax, ebx, ecx, edx); |
| 41 | } |
| 42 | |
| 43 | /* Some CPUID calls want 'count' to be placed in ecx */ |
| 44 | static inline void cpuid_count(unsigned int op, int count, |
| 45 | unsigned int *eax, unsigned int *ebx, |
| 46 | unsigned int *ecx, unsigned int *edx) |
| 47 | { |
| 48 | *eax = op; |
| 49 | *ecx = count; |
| 50 | __cpuid(eax, ebx, ecx, edx); |
| 51 | } |
| 52 | |
| 53 | /* |
| 54 | * CPUID functions returning a single datum |
| 55 | */ |
| 56 | static inline unsigned int cpuid_eax(unsigned int op) |
| 57 | { |
| 58 | unsigned int eax, ebx, ecx, edx; |
| 59 | |
| 60 | cpuid(op, &eax, &ebx, &ecx, &edx); |
| 61 | return eax; |
| 62 | } |
| 63 | static inline unsigned int cpuid_ebx(unsigned int op) |
| 64 | { |
| 65 | unsigned int eax, ebx, ecx, edx; |
| 66 | |
| 67 | cpuid(op, &eax, &ebx, &ecx, &edx); |
| 68 | return ebx; |
| 69 | } |
| 70 | static inline unsigned int cpuid_ecx(unsigned int op) |
| 71 | { |
| 72 | unsigned int eax, ebx, ecx, edx; |
| 73 | |
| 74 | cpuid(op, &eax, &ebx, &ecx, &edx); |
| 75 | return ecx; |
| 76 | } |
| 77 | static inline unsigned int cpuid_edx(unsigned int op) |
| 78 | { |
| 79 | unsigned int eax, ebx, ecx, edx; |
| 80 | |
| 81 | cpuid(op, &eax, &ebx, &ecx, &edx); |
| 82 | return edx; |
| 83 | } |
| 84 | |
| 85 | #endif |