[PATCH] x86: roll all the cpuid asm into one __cpuid call
It's a little neater, and also means only one place to patch for paravirtualization. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Родитель
027a8c7e60
Коммит
9f093394d7
|
@ -143,6 +143,18 @@ static inline void detect_ht(struct cpuinfo_x86 *c) {}
|
||||||
#define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
|
#define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
|
||||||
#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
|
#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
|
||||||
|
|
||||||
|
static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
|
||||||
|
unsigned int *ecx, unsigned int *edx)
|
||||||
|
{
|
||||||
|
/* ecx is often an input as well as an output. */
|
||||||
|
__asm__("cpuid"
|
||||||
|
: "=a" (*eax),
|
||||||
|
"=b" (*ebx),
|
||||||
|
"=c" (*ecx),
|
||||||
|
"=d" (*edx)
|
||||||
|
: "0" (*eax), "2" (*ecx));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic CPUID function
|
* Generic CPUID function
|
||||||
* clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
|
* 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) {}
|
||||||
*/
|
*/
|
||||||
static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx)
|
static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx)
|
||||||
{
|
{
|
||||||
__asm__("cpuid"
|
*eax = op;
|
||||||
: "=a" (*eax),
|
*ecx = 0;
|
||||||
"=b" (*ebx),
|
__cpuid(eax, ebx, ecx, edx);
|
||||||
"=c" (*ecx),
|
|
||||||
"=d" (*edx)
|
|
||||||
: "0" (op), "c"(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some CPUID calls want 'count' to be placed in ecx */
|
/* Some CPUID calls want 'count' to be placed in ecx */
|
||||||
static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
|
static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
|
||||||
int *edx)
|
int *edx)
|
||||||
{
|
{
|
||||||
__asm__("cpuid"
|
*eax = op;
|
||||||
: "=a" (*eax),
|
*ecx = count;
|
||||||
"=b" (*ebx),
|
__cpuid(eax, ebx, ecx, edx);
|
||||||
"=c" (*ecx),
|
|
||||||
"=d" (*edx)
|
|
||||||
: "0" (op), "c" (count));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -175,42 +181,30 @@ static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
|
||||||
*/
|
*/
|
||||||
static inline unsigned int cpuid_eax(unsigned int op)
|
static inline unsigned int cpuid_eax(unsigned int op)
|
||||||
{
|
{
|
||||||
unsigned int eax;
|
unsigned int eax, ebx, ecx, edx;
|
||||||
|
|
||||||
__asm__("cpuid"
|
cpuid(op, &eax, &ebx, &ecx, &edx);
|
||||||
: "=a" (eax)
|
|
||||||
: "0" (op)
|
|
||||||
: "bx", "cx", "dx");
|
|
||||||
return eax;
|
return eax;
|
||||||
}
|
}
|
||||||
static inline unsigned int cpuid_ebx(unsigned int op)
|
static inline unsigned int cpuid_ebx(unsigned int op)
|
||||||
{
|
{
|
||||||
unsigned int eax, ebx;
|
unsigned int eax, ebx, ecx, edx;
|
||||||
|
|
||||||
__asm__("cpuid"
|
cpuid(op, &eax, &ebx, &ecx, &edx);
|
||||||
: "=a" (eax), "=b" (ebx)
|
|
||||||
: "0" (op)
|
|
||||||
: "cx", "dx" );
|
|
||||||
return ebx;
|
return ebx;
|
||||||
}
|
}
|
||||||
static inline unsigned int cpuid_ecx(unsigned int op)
|
static inline unsigned int cpuid_ecx(unsigned int op)
|
||||||
{
|
{
|
||||||
unsigned int eax, ecx;
|
unsigned int eax, ebx, ecx, edx;
|
||||||
|
|
||||||
__asm__("cpuid"
|
cpuid(op, &eax, &ebx, &ecx, &edx);
|
||||||
: "=a" (eax), "=c" (ecx)
|
|
||||||
: "0" (op)
|
|
||||||
: "bx", "dx" );
|
|
||||||
return ecx;
|
return ecx;
|
||||||
}
|
}
|
||||||
static inline unsigned int cpuid_edx(unsigned int op)
|
static inline unsigned int cpuid_edx(unsigned int op)
|
||||||
{
|
{
|
||||||
unsigned int eax, edx;
|
unsigned int eax, ebx, ecx, edx;
|
||||||
|
|
||||||
__asm__("cpuid"
|
cpuid(op, &eax, &ebx, &ecx, &edx);
|
||||||
: "=a" (eax), "=d" (edx)
|
|
||||||
: "0" (op)
|
|
||||||
: "bx", "cx");
|
|
||||||
return edx;
|
return edx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче