Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clearing data before reading it back from memory

  • Loading branch information...
commit 2bcd496cc443c739148aa129b8ffe326160ed703 1 parent 790d654
Yann Sionneau authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 software/bios/dtlb_exception_handling_tests.c
5 software/bios/dtlb_exception_handling_tests.c
View
@@ -22,7 +22,7 @@
void dtlb_exception_handling_tests() {
register unsigned int stack, addr;
- unsigned int data;
+ volatile unsigned int data;
int ret;
asm volatile("mv %0, sp" : "=r"(stack) :: );
@@ -45,6 +45,7 @@ void dtlb_exception_handling_tests() {
printf("=> Writing %d to physical address 0x%08X\n", data, addr);
*(unsigned int *)addr = data;
+ data = 0; // clears data to make sure we are not reading back previous value cached in a register or so
printf("=> Activating the MMU and reading form virtual address 0x%08X\n", addr);
data = read_word_with_mmu_enabled(addr);
printf("\n<= Reading %d from virtual address 0x%08X\n\n", data, addr);
@@ -56,6 +57,7 @@ void dtlb_exception_handling_tests() {
printf("=> Writing %d to physical address 0x%08X\n", data, addr);
*(unsigned int *)addr = data;
+ data = 0; // clears data to make sure we are not reading back previous value cached in a register or so
printf("=> Activating the MMU and reading form virtual address 0x%08X\n", addr);
data = read_word_with_mmu_enabled(addr);
printf("\n<= Reading %d from virtual address 0x%08X\n\n", data, addr);
@@ -71,6 +73,7 @@ void dtlb_exception_handling_tests() {
printf("=> Writting %d to physical address 0x%08X\n", data, addr+0x1000);
*(unsigned int *)(addr + 0x1000) = data;
+ data = 0; // clears data to make sure we are not reading back previous value cached in a register or so
printf("=> Activating the MMU and reading form virtual address 0x%08X\n", addr);
data = read_word_with_mmu_enabled(addr);
printf("\n<= Reading %d from virtual address 0x%08X\n\n", data, addr);
Please sign in to comment.
Something went wrong with that request. Please try again.