Skip to content

Commit 2bcd496

Browse files
committedJun 3, 2012
Clearing data before reading it back from memory
1 parent 790d654 commit 2bcd496

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎software/bios/dtlb_exception_handling_tests.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
void dtlb_exception_handling_tests() {
2323

2424
register unsigned int stack, addr;
25-
unsigned int data;
25+
volatile unsigned int data;
2626
int ret;
2727

2828
asm volatile("mv %0, sp" : "=r"(stack) :: );
@@ -45,6 +45,7 @@ void dtlb_exception_handling_tests() {
4545
printf("=> Writing %d to physical address 0x%08X\n", data, addr);
4646
*(unsigned int *)addr = data;
4747

48+
data = 0; // clears data to make sure we are not reading back previous value cached in a register or so
4849
printf("=> Activating the MMU and reading form virtual address 0x%08X\n", addr);
4950
data = read_word_with_mmu_enabled(addr);
5051
printf("\n<= Reading %d from virtual address 0x%08X\n\n", data, addr);
@@ -56,6 +57,7 @@ void dtlb_exception_handling_tests() {
5657
printf("=> Writing %d to physical address 0x%08X\n", data, addr);
5758
*(unsigned int *)addr = data;
5859

60+
data = 0; // clears data to make sure we are not reading back previous value cached in a register or so
5961
printf("=> Activating the MMU and reading form virtual address 0x%08X\n", addr);
6062
data = read_word_with_mmu_enabled(addr);
6163
printf("\n<= Reading %d from virtual address 0x%08X\n\n", data, addr);
@@ -71,6 +73,7 @@ void dtlb_exception_handling_tests() {
7173
printf("=> Writting %d to physical address 0x%08X\n", data, addr+0x1000);
7274
*(unsigned int *)(addr + 0x1000) = data;
7375

76+
data = 0; // clears data to make sure we are not reading back previous value cached in a register or so
7477
printf("=> Activating the MMU and reading form virtual address 0x%08X\n", addr);
7578
data = read_word_with_mmu_enabled(addr);
7679
printf("\n<= Reading %d from virtual address 0x%08X\n\n", data, addr);

0 commit comments

Comments
 (0)
Please sign in to comment.