summaryrefslogtreecommitdiffstats
path: root/memtestEDK/Memtest/SingleComponents/SmpTestFunctions/cpuid_test.c
blob: dfb364ef017138d9b62ca39f94c6098a05678cc3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

#include <Library/UefiLib.h>


#include "cpuid.h"
#include "smp.h"
#include "environment.h"
#include "cpuid_test.h"

static inline void
__GET_CPUID_MODIFIED(int ax, uint32_t *regs)
{
   __asm__ __volatile__("\t"
   	/* save ebx in case -fPIC is being used */
      "pushq %%rbx; cpuid; mov %%ebx, %%edi; popq %%rbx"
      : "=a" (regs[0]), "=D" (regs[1]), "=c" (regs[2]), "=d" (regs[3])
      : "a" (ax)
      : "memory"
   );
}

#define GET_CPUID_MODIFIED(_ax,_bx,_cx,_dx) { \
   uint32_t regs[4];                   \
   __GET_CPUID_MODIFIED(_ax,regs);            \
   _ax = regs[0];                    \
   _bx = regs[1];                    \
   _cx = regs[2];                    \
   _dx = regs[3];                    \
}

void get_cpuid_Fn0000_0000() {
  uint32_t ax = 0;
  uint32_t bx;
  uint32_t cx = 0;
  uint32_t dx;
  GET_CPUID_MODIFIED(ax, bx, cx, dx);

  uint32_t a[3];
  a[0] = bx; // The ASCII characters “h t u A”.
  a[2] = cx; // The ASCII characters “D M A c”.
  a[1] = dx; // The ASCII characters “i t n e”.

  Print(L"Value of register ax: %x\n", ax);
  Print(L"Value of a0: %x\n", a[0]);
  Print(L"Value of a1: %x\n", a[1]);
  Print(L"Value of a2: %x\n", a[2]);
  Print(L"Value of a %x\n", a);
  Print(L"Value of a0: %d\n", a[0]);
  Print(L"Value of a1: %d\n", a[1]);
  Print(L"Value of a2: %d\n", a[2]);
  Print(L"Value of a %d\n", a);
  Print(L"Value of a0: %s\n", a[0]);
  Print(L"Value of a1: %s\n", a[1]);
  Print(L"Value of a2: %s\n", a[2]);
  Print(L"Value of a %s\n", a);

}