Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for writting to memory with MMU activated

  • Loading branch information...
commit 033c430bdddc828216297cf3fa810e73dc5f4a03 1 parent 795cb9d
@fallen authored
Showing with 16 additions and 1 deletion.
  1. +16 −1 software/mmu-bios/mmu.c
View
17 software/mmu-bios/mmu.c
@@ -162,7 +162,7 @@ unsigned int read_word_with_mmu_enabled(unsigned int vaddr)
"xor r0, r0, r0\n\t"
"xor r11, r11, r11\n\t"
"or r11, r11, %1\n\t"
- "lw %0, (r11+0)\n\t" // Reads from virtual address "addr"
+ "lw %0, (r11+0)\n\t" // Reads from virtual address "vaddr"
"xor r11, r11, r11\n\t"
"ori r11, r11, 0x9\n\t"
"wcsr tlbctrl, r11\n\t" // Disactivates the MMU
@@ -171,3 +171,18 @@ unsigned int read_word_with_mmu_enabled(unsigned int vaddr)
return data;
}
+
+unsigned int write_word_with_mmu_enabled(register unsigned int vaddr, register unsigned int data)
+{
+ asm volatile(
+ "xor r11, r11, r11\n\t"
+ "ori r11, r11, 0x11\n\t"
+ "wcsr tlbctrl, r11\n\t" // Activates the MMU
+ "xor r0, r0, r0\n\t"
+ "sw (%0 + 0), %1\n\t" // Writes "data" to virtual address "vaddr"
+ "xor r11, r11, r11\n\t"
+ "ori r11, r11, 0x9\n\t"
+ "wcsr tlbctrl, r11\n\t" // Disactivates the MMU
+ "xor r0, r0, r0\n\t" :: "r"(vaddr), "r"(data) : "r11"
+ );
+}
Please sign in to comment.
Something went wrong with that request. Please try again.