Created
January 10, 2012 21:21
-
-
Save mikeb01/1591282 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
static void cpuid(int op1, int op2, int *data) { | |
asm("cpuid" | |
: "=a" (data[0]), "=b" (data[1]), "=c" (data[2]), "=d" (data[3]) | |
: "a"(op1), "c"(op2)); | |
} | |
int main (int argc, const char * argv[]) { | |
int values[4]; | |
int level_type = 0; | |
int i = 0; | |
while (1) { | |
cpuid(0xB, i++, values); | |
level_type = values[2] >> 8 & 0xFF; | |
if (level_type == 0) break; | |
printf("Shift: %d, Count: : %d, Level Id: %d, Level Type: %d, x2APIC: %d, Group: %d\n", | |
values[0] & 0xF, values[1] & 0xFFFF, | |
values[2] & 0xFF, level_type, | |
values[3], values[3] >> (values[0] & 0xF)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment