summaryrefslogtreecommitdiffstats
path: root/memtestEDK/Memtest/Test1/doTest1.c
blob: 8b555db786ceef010dcfc452063ac171115a24e7 (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

#include <stdint.h>

#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>

#include "test.h"

static inline void cache_off(void)
{
    asm(
        "push %rax\n\t"
        "movq %cr0,%eax\n\t"
        "orl $0x40000000,%eax\n\t"  /* Set CD */
        "movq %eax,%cr0\n\t"
        "wbinvd\n\t"
        "pop  %rax\n\t");
}

static inline void cache_on(void)
{
    asm(
        "push %rax\n\t"
        "movq %cr0,%eax\n\t"
        "andl $0x9fffffff,%eax\n\t" /* Clear CD and NW */ 
        "movq %eax,%cr0\n\t"
        "pop  %rax\n\t");
}


EFI_STATUS
EFIAPI
UefiMain (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
	cache_off();
	addr_tst1(0);
	cache_on();

	return EFI_SUCCESS;

}