237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
#if defined(OF_X86_64) || defined(OF_X86)
static OF_INLINE struct x86_regs OF_CONST_FUNC
x86_cpuid(uint32_t eax, uint32_t ecx)
{
struct x86_regs regs;
# if defined(OF_X86_64_ASM)
__asm__(
"cpuid"
: "=a"(regs.eax), "=b"(regs.ebx), "=c"(regs.ecx), "=d"(regs.edx)
: "a"(eax), "c"(ecx)
);
# elif defined(OF_X86_ASM)
/*
* This workaround is required by GCC when using -fPIC, as ebx is a
* special register in PIC code. Yes, GCC is indeed not able to just
* push a register onto the stack before the __asm__ block and to pop
* it afterwards.
*/
__asm__(
"pushl %%ebx\n\t"
"cpuid\n\t"
"movl %%ebx, %1\n\t"
"popl %%ebx"
: "=a"(regs.eax), "=r"(regs.ebx), "=c"(regs.ecx), "=d"(regs.edx)
: "a"(eax), "c"(ecx)
);
|
|
|
|
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
#if defined(OF_X86_64) || defined(OF_X86)
static OF_INLINE struct x86_regs OF_CONST_FUNC
x86_cpuid(uint32_t eax, uint32_t ecx)
{
struct x86_regs regs;
# if defined(OF_X86_64_ASM)
__asm__ (
"cpuid"
: "=a"(regs.eax), "=b"(regs.ebx), "=c"(regs.ecx), "=d"(regs.edx)
: "a"(eax), "c"(ecx)
);
# elif defined(OF_X86_ASM)
/*
* This workaround is required by GCC when using -fPIC, as ebx is a
* special register in PIC code. Yes, GCC is indeed not able to just
* push a register onto the stack before the __asm__ block and to pop
* it afterwards.
*/
__asm__ (
"pushl %%ebx\n\t"
"cpuid\n\t"
"movl %%ebx, %1\n\t"
"popl %%ebx"
: "=a"(regs.eax), "=r"(regs.ebx), "=c"(regs.ecx), "=d"(regs.edx)
: "a"(eax), "c"(ecx)
);
|