fix __cpuid() on x86
The previous version used memory operands that gcc (probably dependent on optimization flags and/or version) could address relative to the stack pointer, but pushing %ebx onto the stack changed it. Here, the address of the regs array is put into %esi and the individual members are written into directly.
This commit is contained in:
parent
d35e75554f
commit
5a41b86028
@ -48,32 +48,25 @@ FPU* FPU::_instance (0);
|
|||||||
static void
|
static void
|
||||||
__cpuid(int regs[4], int cpuid_leaf)
|
__cpuid(int regs[4], int cpuid_leaf)
|
||||||
{
|
{
|
||||||
int eax, ebx, ecx, edx;
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
#if defined(__i386__)
|
#if defined(__i386__)
|
||||||
"pushl %%ebx;\n\t"
|
"pushl %%ebx;\n\t"
|
||||||
#endif
|
#endif
|
||||||
"movl %4, %%eax;\n\t"
|
|
||||||
"cpuid;\n\t"
|
"cpuid;\n\t"
|
||||||
"movl %%eax, %0;\n\t"
|
"movl %%eax, (%1);\n\t"
|
||||||
"movl %%ebx, %1;\n\t"
|
"movl %%ebx, 4(%1);\n\t"
|
||||||
"movl %%ecx, %2;\n\t"
|
"movl %%ecx, 8(%1);\n\t"
|
||||||
"movl %%edx, %3;\n\t"
|
"movl %%edx, 12(%1);\n\t"
|
||||||
#if defined(__i386__)
|
#if defined(__i386__)
|
||||||
"popl %%ebx;\n\t"
|
"popl %%ebx;\n\t"
|
||||||
#endif
|
#endif
|
||||||
:"=m" (eax), "=m" (ebx), "=m" (ecx), "=m" (edx)
|
:"=a" (cpuid_leaf) /* %eax clobbered by CPUID */
|
||||||
:"r" (cpuid_leaf)
|
:"S" (regs), "a" (cpuid_leaf)
|
||||||
:"%eax",
|
:
|
||||||
#if !defined(__i386__)
|
#if !defined(__i386__)
|
||||||
"%ebx",
|
"%ebx",
|
||||||
#endif
|
#endif
|
||||||
"%ecx", "%edx");
|
"%ecx", "%edx", "memory");
|
||||||
|
|
||||||
regs[0] = eax;
|
|
||||||
regs[1] = ebx;
|
|
||||||
regs[2] = ecx;
|
|
||||||
regs[3] = edx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !PLATFORM_WINDOWS */
|
#endif /* !PLATFORM_WINDOWS */
|
||||||
|
Loading…
Reference in New Issue
Block a user