Skip to content

Instantly share code, notes, and snippets.

@mikeb01
Created January 10, 2012 21:21
Show Gist options
  • Save mikeb01/1591282 to your computer and use it in GitHub Desktop.
Save mikeb01/1591282 to your computer and use it in GitHub Desktop.
#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