CPUID: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m Added a note |
s/dword/uint32_t/g |
||
Line 143: | Line 143: | ||
<source lang="c"> |
<source lang="c"> |
||
/* TODO: You should use the <cpuid.h> header that comes with GCC instead. */ |
|||
enum cpuid_requests { |
enum cpuid_requests { |
||
CPUID_GETVENDORSTRING, |
CPUID_GETVENDORSTRING, |
||
Line 160: | Line 162: | ||
* will be modified by the operation, so we need to tell the compiler about it. |
* will be modified by the operation, so we need to tell the compiler about it. |
||
*/ |
*/ |
||
static inline void cpuid(int code, |
static inline void cpuid(int code, uint32_t *a, uint32_t *d) { |
||
asm volatile("cpuid":"=a"(*a),"=d"(*d):"a"(code):"ecx","ebx"); |
asm volatile("cpuid":"=a"(*a),"=d"(*d):"a"(code):"ecx","ebx"); |
||
} |
} |
||
Line 166: | Line 168: | ||
/** issue a complete request, storing general registers output as a string |
/** issue a complete request, storing general registers output as a string |
||
*/ |
*/ |
||
static inline int cpuid_string(int code, |
static inline int cpuid_string(int code, uint32_t where[4]) { |
||
asm volatile("cpuid":"=a"(*where),"=b"(*(where+1)), |
asm volatile("cpuid":"=a"(*where),"=b"(*(where+1)), |
||
"=c"(*(where+2)),"=d"(*(where+3)):"a"(code)); |
"=c"(*(where+2)),"=d"(*(where+3)):"a"(code)); |