akaros/tests/cpuid.c
<<
>>
Prefs
   1#include <stdint.h>
   2#include <stdio.h>
   3#include <stdlib.h>
   4#include <errno.h>
   5#include <parlib/arch/arch.h>
   6
   7int main(int argc, char *argv[])
   8{
   9        uint32_t eax, ebx, ecx, edx;
  10        uint32_t info1, info2 = 0;
  11
  12        if (argc < 2) {
  13                printf("%s: eax_leaf [ecx_leaf]\n", argv[0]);
  14                exit(-1);
  15        }
  16        errno = 0;
  17        info1 = strtoul(argv[1], 0, 16);
  18        if (errno) {
  19                perror("info1");
  20                exit(-1);
  21        }
  22        if (argc > 2) {
  23                errno = 0;
  24                info2 = strtoul(argv[2], 0, 16);
  25                if (errno) {
  26                        perror("info2");
  27                        exit(-1);
  28                }
  29        }
  30        eax = ebx = ecx = edx = 0xffffffff;
  31        parlib_cpuid(info1, info2, &eax, &ebx, &ecx, &edx);
  32        printf("CPUID for Leaf 0x%08x, Sublevel 0x%08x:\n", info1, info2);
  33        printf("\teax: %08x\n\tebx: %08x\n\tecx: %08x\n\tedx: %08x\n", eax, ebx,
  34               ecx, edx);
  35        return 0;
  36}
  37