mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-22 18:30:27 +01:00
make cpuid work on x86_64
not that it's used for anything, just for the logs
This commit is contained in:
parent
ff57a29e0f
commit
ce46bd1e99
|
@ -119,9 +119,15 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*));
|
||||||
#define __MSVC_INLINE__
|
#define __MSVC_INLINE__
|
||||||
#elif defined (__GNUC__) && defined(__i386)
|
#elif defined (__GNUC__) && defined(__i386)
|
||||||
#define __GNU_INLINE_X86_32__
|
#define __GNU_INLINE_X86_32__
|
||||||
|
#elif defined (__GNUC__) && defined(__x86_64__)
|
||||||
|
#define __GNU_INLINE_X86_64__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GNU_INLINE_X86_32__)
|
#if defined(__GNU_INLINE_X86_32__) || defined(__GNU_INLINE_X86_64__)
|
||||||
|
#define __GNU_INLINE_X86__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNU_INLINE_X86__)
|
||||||
#define FPU_REGS "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)"
|
#define FPU_REGS "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)"
|
||||||
#define MMX_REGS "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7"
|
#define MMX_REGS "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -144,38 +144,39 @@ static void DetectCPU(void)
|
||||||
mov dword ptr [ulFeatures], edx
|
mov dword ptr [ulFeatures], edx
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE_X86_32__)
|
#elif (defined __GNU_INLINE_X86__)
|
||||||
|
ULONG eax, ebx, ecx, edx;
|
||||||
// test MMX presence and update flag
|
// test MMX presence and update flag
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"pushl %%ebx \n\t"
|
#if (defined __GNU_INLINE_X86_64__)
|
||||||
"xorl %%eax,%%eax \n\t" // request for basic id
|
|
||||||
"cpuid \n\t"
|
"cpuid \n\t"
|
||||||
"movl %%ebx, (%%esi) \n\t"
|
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
|
||||||
"movl %%edx, 4(%%esi) \n\t"
|
#else
|
||||||
"movl %%ecx, 8(%%esi) \n\t"
|
"movl %%ebx, %%esi \n\t"
|
||||||
"popl %%ebx \n\t"
|
"cpuid \n\t"
|
||||||
: // no specific outputs.
|
"xchgl %%ebx, %%esi \n\t"
|
||||||
: "S" (strVendor)
|
: "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx)
|
||||||
: "eax", "ecx", "edx", "memory"
|
#endif
|
||||||
|
: "a" (0) // request for basic id
|
||||||
);
|
);
|
||||||
|
memcpy(strVendor + 0, &ebx, 4);
|
||||||
// need to break this into a separate asm block, since I'm clobbering
|
memcpy(strVendor + 4, &edx, 4);
|
||||||
// too many registers. There's something to be said for letting MSVC
|
memcpy(strVendor + 8, &ecx, 4);
|
||||||
// figure out where on the stack your locals are resting, but yeah,
|
|
||||||
// I know, that's x86-specific anyhow...
|
|
||||||
// !!! FIXME: can probably do this right with modern GCC.
|
|
||||||
|
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"pushl %%ebx \n\t"
|
#if (defined __GNU_INLINE_X86_64__)
|
||||||
"movl $1, %%eax \n\t" // request for TFMS feature flags
|
|
||||||
"cpuid \n\t"
|
"cpuid \n\t"
|
||||||
"mov %%eax, (%%esi) \n\t" // remember type, family, model and stepping
|
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
|
||||||
"mov %%edx, (%%edi) \n\t"
|
#else
|
||||||
"popl %%ebx \n\t"
|
"movl %%ebx, %%esi \n\t"
|
||||||
: // no specific outputs.
|
"cpuid \n\t"
|
||||||
: "S" (&ulTFMS), "D" (&ulFeatures)
|
"xchgl %%ebx, %%esi \n\t"
|
||||||
: "eax", "ecx", "edx", "memory"
|
: "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx)
|
||||||
|
#endif
|
||||||
|
: "a" (1) // request for TFMS feature flags
|
||||||
);
|
);
|
||||||
|
ulTFMS = eax;
|
||||||
|
ulFeatures = edx;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user