Skip to content
This repository
Browse code

Clearing data before reading it back from memory

  • Loading branch information...
commit 2bcd496cc443c739148aa129b8ffe326160ed703 1 parent 790d654
Yann Sionneau authored June 03, 2012
5  software/bios/dtlb_exception_handling_tests.c
@@ -22,7 +22,7 @@
22 22
 void dtlb_exception_handling_tests() {
23 23
 
24 24
 	register unsigned int stack, addr;
25  
-	unsigned int data;
  25
+	volatile unsigned int data;
26 26
 	int ret;
27 27
 
28 28
 	asm volatile("mv %0, sp" : "=r"(stack) :: );
@@ -45,6 +45,7 @@ void dtlb_exception_handling_tests() {
45 45
 	printf("=> Writing %d to physical address 0x%08X\n", data, addr);
46 46
 	*(unsigned int *)addr = data;
47 47
 
  48
+	data = 0; // clears data to make sure we are not reading back previous value cached in a register or so
48 49
 	printf("=> Activating the MMU and reading form virtual address 0x%08X\n", addr);
49 50
 	data = read_word_with_mmu_enabled(addr);
50 51
 	printf("\n<= Reading %d from virtual address 0x%08X\n\n", data, addr);
@@ -56,6 +57,7 @@ void dtlb_exception_handling_tests() {
56 57
 	printf("=> Writing %d to physical address 0x%08X\n", data, addr);
57 58
 	*(unsigned int *)addr = data;
58 59
 
  60
+	data = 0; // clears data to make sure we are not reading back previous value cached in a register or so
59 61
 	printf("=> Activating the MMU and reading form virtual address 0x%08X\n", addr);
60 62
 	data = read_word_with_mmu_enabled(addr);
61 63
 	printf("\n<= Reading %d from virtual address 0x%08X\n\n", data, addr);
@@ -71,6 +73,7 @@ void dtlb_exception_handling_tests() {
71 73
 	printf("=> Writting %d to physical address 0x%08X\n", data, addr+0x1000);
72 74
 	*(unsigned int *)(addr + 0x1000) = data;
73 75
 
  76
+	data = 0; // clears data to make sure we are not reading back previous value cached in a register or so
74 77
 	printf("=> Activating the MMU and reading form virtual address 0x%08X\n", addr);
75 78
 	data = read_word_with_mmu_enabled(addr);
76 79
 	printf("\n<= Reading %d from virtual address 0x%08X\n\n", data, addr);

0 notes on commit 2bcd496

Please sign in to comment.
Something went wrong with that request. Please try again.