Skip to content
This repository
Browse code

Add support for writting to memory with MMU activated

  • Loading branch information...
commit 033c430bdddc828216297cf3fa810e73dc5f4a03 1 parent 795cb9d
Yann Sionneau authored June 06, 2012

Showing 1 changed file with 16 additions and 1 deletion. Show diff stats Hide diff stats

  1. 17  software/mmu-bios/mmu.c
17  software/mmu-bios/mmu.c
@@ -162,7 +162,7 @@ unsigned int read_word_with_mmu_enabled(unsigned int vaddr)
162 162
 		"xor r0, r0, r0\n\t"
163 163
 		"xor r11, r11, r11\n\t"
164 164
 		"or r11, r11, %1\n\t"
165  
-		"lw  %0, (r11+0)\n\t" // Reads from virtual address "addr"
  165
+		"lw  %0, (r11+0)\n\t" // Reads from virtual address "vaddr"
166 166
 		"xor r11, r11, r11\n\t"
167 167
 		"ori r11, r11, 0x9\n\t"
168 168
 		"wcsr tlbctrl, r11\n\t" // Disactivates the MMU
@@ -171,3 +171,18 @@ unsigned int read_word_with_mmu_enabled(unsigned int vaddr)
171 171
 
172 172
 	return data;
173 173
 }
  174
+
  175
+unsigned int write_word_with_mmu_enabled(register unsigned int vaddr, register unsigned int data)
  176
+{
  177
+	asm volatile(
  178
+		"xor r11, r11, r11\n\t"
  179
+		"ori r11, r11, 0x11\n\t"
  180
+		"wcsr tlbctrl, r11\n\t" // Activates the MMU
  181
+		"xor r0, r0, r0\n\t"
  182
+		"sw  (%0 + 0), %1\n\t" // Writes "data" to virtual address "vaddr"
  183
+		"xor r11, r11, r11\n\t"
  184
+		"ori r11, r11, 0x9\n\t"
  185
+		"wcsr tlbctrl, r11\n\t" // Disactivates the MMU
  186
+		"xor r0, r0, r0\n\t" :: "r"(vaddr), "r"(data) : "r11"
  187
+	);
  188
+}

0 notes on commit 033c430

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