diff options
Diffstat (limited to 'memtestEDK/Memtest/Cpuid/cpuid_test.c')
-rw-r--r-- | memtestEDK/Memtest/Cpuid/cpuid_test.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/memtestEDK/Memtest/Cpuid/cpuid_test.c b/memtestEDK/Memtest/Cpuid/cpuid_test.c new file mode 100644 index 0000000..dfb364e --- /dev/null +++ b/memtestEDK/Memtest/Cpuid/cpuid_test.c @@ -0,0 +1,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); + +}
\ No newline at end of file |