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