diff options
-rw-r--r-- | include/asm-i386/processor.h | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h index b32346d62e10..2277127696d2 100644 --- a/include/asm-i386/processor.h +++ b/include/asm-i386/processor.h | |||
@@ -143,6 +143,18 @@ static inline void detect_ht(struct cpuinfo_x86 *c) {} | |||
143 | #define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */ | 143 | #define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */ |
144 | #define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */ | 144 | #define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */ |
145 | 145 | ||
146 | static inline void __cpuid(unsigned int *eax, unsigned int *ebx, | ||
147 | unsigned int *ecx, unsigned int *edx) | ||
148 | { | ||
149 | /* ecx is often an input as well as an output. */ | ||
150 | __asm__("cpuid" | ||
151 | : "=a" (*eax), | ||
152 | "=b" (*ebx), | ||
153 | "=c" (*ecx), | ||
154 | "=d" (*edx) | ||
155 | : "0" (*eax), "2" (*ecx)); | ||
156 | } | ||
157 | |||
146 | /* | 158 | /* |
147 | * Generic CPUID function | 159 | * Generic CPUID function |
148 | * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx | 160 | * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx |
@@ -150,24 +162,18 @@ static inline void detect_ht(struct cpuinfo_x86 *c) {} | |||
150 | */ | 162 | */ |
151 | static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) | 163 | static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) |
152 | { | 164 | { |
153 | __asm__("cpuid" | 165 | *eax = op; |
154 | : "=a" (*eax), | 166 | *ecx = 0; |
155 | "=b" (*ebx), | 167 | __cpuid(eax, ebx, ecx, edx); |
156 | "=c" (*ecx), | ||
157 | "=d" (*edx) | ||
158 | : "0" (op), "c"(0)); | ||
159 | } | 168 | } |
160 | 169 | ||
161 | /* Some CPUID calls want 'count' to be placed in ecx */ | 170 | /* Some CPUID calls want 'count' to be placed in ecx */ |
162 | static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx, | 171 | static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx, |
163 | int *edx) | 172 | int *edx) |
164 | { | 173 | { |
165 | __asm__("cpuid" | 174 | *eax = op; |
166 | : "=a" (*eax), | 175 | *ecx = count; |
167 | "=b" (*ebx), | 176 | __cpuid(eax, ebx, ecx, edx); |
168 | "=c" (*ecx), | ||
169 | "=d" (*edx) | ||
170 | : "0" (op), "c" (count)); | ||
171 | } | 177 | } |
172 | 178 | ||
173 | /* | 179 | /* |
@@ -175,42 +181,30 @@ static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx, | |||
175 | */ | 181 | */ |
176 | static inline unsigned int cpuid_eax(unsigned int op) | 182 | static inline unsigned int cpuid_eax(unsigned int op) |
177 | { | 183 | { |
178 | unsigned int eax; | 184 | unsigned int eax, ebx, ecx, edx; |
179 | 185 | ||
180 | __asm__("cpuid" | 186 | cpuid(op, &eax, &ebx, &ecx, &edx); |
181 | : "=a" (eax) | ||
182 | : "0" (op) | ||
183 | : "bx", "cx", "dx"); | ||
184 | return eax; | 187 | return eax; |
185 | } | 188 | } |
186 | static inline unsigned int cpuid_ebx(unsigned int op) | 189 | static inline unsigned int cpuid_ebx(unsigned int op) |
187 | { | 190 | { |
188 | unsigned int eax, ebx; | 191 | unsigned int eax, ebx, ecx, edx; |
189 | 192 | ||
190 | __asm__("cpuid" | 193 | cpuid(op, &eax, &ebx, &ecx, &edx); |
191 | : "=a" (eax), "=b" (ebx) | ||
192 | : "0" (op) | ||
193 | : "cx", "dx" ); | ||
194 | return ebx; | 194 | return ebx; |
195 | } | 195 | } |
196 | static inline unsigned int cpuid_ecx(unsigned int op) | 196 | static inline unsigned int cpuid_ecx(unsigned int op) |
197 | { | 197 | { |
198 | unsigned int eax, ecx; | 198 | unsigned int eax, ebx, ecx, edx; |
199 | 199 | ||
200 | __asm__("cpuid" | 200 | cpuid(op, &eax, &ebx, &ecx, &edx); |
201 | : "=a" (eax), "=c" (ecx) | ||
202 | : "0" (op) | ||
203 | : "bx", "dx" ); | ||
204 | return ecx; | 201 | return ecx; |
205 | } | 202 | } |
206 | static inline unsigned int cpuid_edx(unsigned int op) | 203 | static inline unsigned int cpuid_edx(unsigned int op) |
207 | { | 204 | { |
208 | unsigned int eax, edx; | 205 | unsigned int eax, ebx, ecx, edx; |
209 | 206 | ||
210 | __asm__("cpuid" | 207 | cpuid(op, &eax, &ebx, &ecx, &edx); |
211 | : "=a" (eax), "=d" (edx) | ||
212 | : "0" (op) | ||
213 | : "bx", "cx"); | ||
214 | return edx; | 208 | return edx; |
215 | } | 209 | } |
216 | 210 | ||