Commit 55e30e09 authored by Dmitry Fedin's avatar Dmitry Fedin

use __get_cpuid instead of some weird asm pieces

parent e009d51a
......@@ -19,8 +19,11 @@
*/
#include <assert.h>
#include <cpuid.h>
#include "cpuid.h"
#define CPUID_MAGIC 0x280147b8
kdb_cpuid_t *kdb_cpuid (void) {
......@@ -30,17 +33,7 @@ kdb_cpuid_t *kdb_cpuid (void) {
return &cached;
}
int a;
#if ( __GNUC__ < 5 ) && defined( __i386__ ) && defined( __PIC__ )
asm volatile ("xchgl\t%%ebx, %1\n\tcpuid\n\txchgl\t%%ebx, %1\n\t"
: "=a" (a), "=r" (cached.ebx), "=c" (cached.ecx), "=d" (cached.edx)
: "0" (1)
);
#else
asm volatile ("cpuid\n\t"
: "=a" (a), "=b" (cached.ebx) , "=c" (cached.ecx), "=d" (cached.edx)
: "0" (1)
);
#endif
assert(__get_cpuid(1, &a, &cached.ebx, &cached.ecx, &cached.edx) != 0);
cached.magic = CPUID_MAGIC;
return &cached;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment