1 #ifndef __ASM_X86_PROCESSOR_H
2 #define __ASM_X86_PROCESSOR_H
4 #include <asm/processor-flags.h>
7 #include <asm/system.h>
9 static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
10 unsigned int *ecx, unsigned int *edx)
12 /* ecx is often an input as well as an output. */
18 : "0" (*eax), "2" (*ecx));
21 static inline void load_cr3(pgd_t *pgdir)
23 write_cr3(__pa(pgdir));
27 # include "processor_32.h"
29 # include "processor_64.h"
32 static inline unsigned long native_get_debugreg(int regno)
34 unsigned long val = 0; /* Damn you, gcc! */
38 asm("mov %%db0, %0" :"=r" (val)); break;
40 asm("mov %%db1, %0" :"=r" (val)); break;
42 asm("mov %%db2, %0" :"=r" (val)); break;
44 asm("mov %%db3, %0" :"=r" (val)); break;
46 asm("mov %%db6, %0" :"=r" (val)); break;
48 asm("mov %%db7, %0" :"=r" (val)); break;
55 static inline void native_set_debugreg(int regno, unsigned long value)
59 asm("mov %0,%%db0" : /* no output */ :"r" (value));
62 asm("mov %0,%%db1" : /* no output */ :"r" (value));
65 asm("mov %0,%%db2" : /* no output */ :"r" (value));
68 asm("mov %0,%%db3" : /* no output */ :"r" (value));
71 asm("mov %0,%%db6" : /* no output */ :"r" (value));
74 asm("mov %0,%%db7" : /* no output */ :"r" (value));
82 * Set IOPL bits in EFLAGS from given mask
84 static inline void native_set_iopl_mask(unsigned mask)
88 __asm__ __volatile__ ("pushfl;"
95 : "i" (~X86_EFLAGS_IOPL), "r" (mask));
100 #ifndef CONFIG_PARAVIRT
101 #define __cpuid native_cpuid
102 #define paravirt_enabled() 0
105 * These special macros can be used to get or set a debugging register
107 #define get_debugreg(var, register) \
108 (var) = native_get_debugreg(register)
109 #define set_debugreg(value, register) \
110 native_set_debugreg(register, value)
112 #define set_iopl_mask native_set_iopl_mask
113 #endif /* CONFIG_PARAVIRT */
116 * Save the cr4 feature set we're using (ie
117 * Pentium 4MB enable and PPro Global page
118 * enable), so that any CPU's that boot up
119 * after us can get the correct flags.
121 extern unsigned long mmu_cr4_features;
123 static inline void set_in_cr4(unsigned long mask)
126 mmu_cr4_features |= mask;
132 static inline void clear_in_cr4(unsigned long mask)
135 mmu_cr4_features &= ~mask;
144 * Generic CPUID function
145 * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
146 * resulting in stale register contents being returned.
148 static inline void cpuid(unsigned int op,
149 unsigned int *eax, unsigned int *ebx,
150 unsigned int *ecx, unsigned int *edx)
154 __cpuid(eax, ebx, ecx, edx);
157 /* Some CPUID calls want 'count' to be placed in ecx */
158 static inline void cpuid_count(unsigned int op, int count,
159 unsigned int *eax, unsigned int *ebx,
160 unsigned int *ecx, unsigned int *edx)
164 __cpuid(eax, ebx, ecx, edx);
168 * CPUID functions returning a single datum
170 static inline unsigned int cpuid_eax(unsigned int op)
172 unsigned int eax, ebx, ecx, edx;
174 cpuid(op, &eax, &ebx, &ecx, &edx);
177 static inline unsigned int cpuid_ebx(unsigned int op)
179 unsigned int eax, ebx, ecx, edx;
181 cpuid(op, &eax, &ebx, &ecx, &edx);
184 static inline unsigned int cpuid_ecx(unsigned int op)
186 unsigned int eax, ebx, ecx, edx;
188 cpuid(op, &eax, &ebx, &ecx, &edx);
191 static inline unsigned int cpuid_edx(unsigned int op)
193 unsigned int eax, ebx, ecx, edx;
195 cpuid(op, &eax, &ebx, &ecx, &edx);