lsflib/tools/main.c
changeset 6 c3dc3eb3b541
child 77 49e0babccb23
equal deleted inserted replaced
5:d752cbe8208e 6:c3dc3eb3b541
       
     1 /*
       
     2  * cpuinfo
       
     3  */
       
     4 
       
     5 #include <stdio.h>
       
     6 #include <stdlib.h>
       
     7 #include <cpuid.h>
       
     8 
       
     9 int main (int argc, char **argv)
       
    10 {
       
    11     signed long i;
       
    12     ULONG ax = 0, bx = 0, cx = 0, dx = 0;
       
    13 
       
    14     printf ("Vendor     : %s\n", get_cpu_vendor ());
       
    15     printf ("Type       : %ld\n", (get_cpu_function (1, &ax, &bx, &cx, &dx) >> 12) & 0x1);
       
    16     printf ("Family     : %ld\n", (get_cpu_function (1, &ax, &bx, &cx, &dx) >> 8) & 0xF);
       
    17     printf ("Model      : %ld\n", (get_cpu_function (1, &ax, &bx, &cx, &dx) >> 4) & 0xF);
       
    18     printf ("Step       : %ld\n", (get_cpu_function (1, &ax, &bx, &cx, &dx) & 0xF));
       
    19 
       
    20     if (strcmp (get_cpu_vendor (), "AuthenticAMD")) {
       
    21         printf ("Cannot handle NON-AMD-CPUs\n");
       
    22         return EXIT_SUCCESS;
       
    23     }
       
    24 
       
    25     printf ("Extensions : %ld\n", (get_cpu_function (0x80000000, &ax, &bx, &cx, &dx)) & 0xFF);
       
    26     printf ("Generation : %ld\n", (get_cpu_function (0x80000001, &ax, &bx, &cx, &dx) >> 8) & 0xF);
       
    27     printf ("Model      : %ld\n", (get_cpu_function (0x80000001, &ax, &bx, &cx, &dx) >> 4) & 0xF);
       
    28     printf ("Step       : %ld\n", (get_cpu_function (0x80000001, &ax, &bx, &cx, &dx)) & 0xF);
       
    29 
       
    30     get_cpu_function (0x80000006, &ax, &bx, &cx, &dx);
       
    31     printf ("L2Cache    : %ld Kb\n", (cx >> 16) & 0xFFFF);
       
    32 
       
    33     printf ("Brand      : %s", get_cpu_brand (0x80000002));
       
    34     printf ("%s", get_cpu_brand (0x80000003));
       
    35     printf ("%s\n", get_cpu_brand (0x80000004));
       
    36 
       
    37     if ((get_cpu_function (0x80000000, &ax, &bx, &cx, &dx) & 0xFF) >= 8) {
       
    38         printf ("Hammer     : 0x%.8lx\n\n", (get_cpu_function (0x80000008, &ax, &bx, &cx, &dx)));
       
    39     }
       
    40 
       
    41     for (i = 0x0; i < 0x2; i++) {
       
    42         get_cpu_function (i, &ax, &bx, &cx, &dx);
       
    43         printf ("EAX:%.8lx: %.8lx EBX:%.8lx: %.8lx ECX:%.8lx: %.8lx EDX:%.8lx: %.8lx\n", i, ax, i, bx, i, cx, i, dx);
       
    44     }
       
    45 
       
    46     printf ("\n");
       
    47 
       
    48     for (i = 0x80000000; i <= 0x80000008; i++) {
       
    49         get_cpu_function (i, &ax, &bx, &cx, &dx);
       
    50         printf ("EAX:%.8lx: %.8lx EBX:%.8lx: %.8lx ECX:%.8lx: %.8lx EDX:%.8lx: %.8lx\n", i, ax, i, bx, i, cx, i, dx);
       
    51     }
       
    52 
       
    53     return 0;
       
    54 }