Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: fallen/milkymist-mmu
base: 0b65466c149b
...
head fork: fallen/milkymist-mmu
compare: 135ee33be77c
  • 4 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
4 software/mmu-bios/crt0.S
View
@@ -122,12 +122,12 @@ _dtlb_miss_exception_handler:
_itlb_miss_exception_handler:
sw (sp+0), ra
calli .save_all
- rcsr r1, itlbma /* get virtual address which caused the page fault */
- mv ea, r1 /* when returning from exception we branch back to that virtual address */
calli itlb_miss_handler
bi .restore_all_and_eret
nop
nop
+ nop
+ nop
macaddress:
.byte 0x10
9 software/mmu-bios/dtlb_exception_handling_tests.c
View
@@ -17,6 +17,15 @@ void dtlb_exception_handling_tests() {
printf("stack == 0x%08X\n", stack);
+ ret = mmu_map(0x44000000, 0x44000000, ITLB_MAPPING | MAPPING_CAN_READ);
+ check_for_error(ret);
+ ret = mmu_map(0x44001000, 0x44001000, ITLB_MAPPING | MAPPING_CAN_READ);
+ check_for_error(ret);
+ ret = mmu_map(0x44002000, 0x44002000, ITLB_MAPPING | MAPPING_CAN_READ);
+ check_for_error(ret);
+ ret = mmu_map(0x44003000, 0x44003000, ITLB_MAPPING | MAPPING_CAN_READ);
+ check_for_error(ret);
+
addr = 0x44004004;
printf("\n=> Mapping 0x%08X to 0x%08X\n", addr, addr);
12 software/mmu-bios/main.c
View
@@ -75,7 +75,8 @@ int printf(const char *fmt, ...)
}
void f(void) {
- CSR_UART_RXTX = '@';
+ char c = '@';
+ CSR_UART_RXTX = c;
// asm volatile("bi f" ::: ); // We intinitely loop to f()
asm volatile("xor r0, r0, r0\n\t"
"xor r0, r0, r0" ::: );
@@ -108,8 +109,13 @@ void itlbtest(void) {
*pdest = *p;
puts("Copy DONE");
- asm volatile("wcsr DCC, r0");
- asm volatile("wcsr ICC, r0");
+ asm volatile("wcsr DCC, r0\n\t"
+ "xor r0, r0, r0\n\t"
+ "xor r0, r0, r0\n\t"
+ "xor r0, r0, r0\n\t"
+ "xor r0, r0, r0");
+ asm volatile("wcsr ICC, r0\n\t"
+ "xor r0, r0, r0");
puts("Instruction and Data caches have been invalidated");
call_function_with_itlb_enabled(f_addr);
13 software/mmu-bios/mmu_test_gen.c
View
@@ -44,9 +44,10 @@ int main(void) {
"int success, failure;\n"
"unsigned int count;\n"
"asm volatile(\"mv %0, sp\" : \"=r\"(stack) :: );\n"
- "mmu_dtlb_map(0x44002000, 0x44001000);\n"
- "mmu_dtlb_map(stack, stack);\n"
- "mmu_dtlb_map(stack-0x1000, stack-0x1000);\n"
+ "mmu_map(0x44002000, 0x44001000, DTLB_MAPPING | MAPPING_CAN_READ | MAPPING_CAN_WRITE);\n"
+ "mmu_map(0x44000000, 0x44003000, DTLB_MAPPING | MAPPING_CAN_READ | MAPPING_CAN_WRITE);\n"
+ "mmu_map(stack, stack, DTLB_MAPPING | MAPPING_CAN_READ | MAPPING_CAN_WRITE);\n"
+ "mmu_map(stack-0x1000, stack-0x1000, DTLB_MAPPING | MAPPING_CAN_READ | MAPPING_CAN_WRITE);\n"
"printf(\"stack == 0x%08X\\n\", stack);"
"a = 0;\n"
"b = 1;\n"
@@ -81,11 +82,11 @@ int main(void) {
puts("disable_dtlb();");
puts("printf(\"[MMU ON] *(0x%08X) == 0x%08X\\n\", addr, data);");
puts("printf(\"[MMU OFF] *(0x%08X) == 0x%08X\\n\", addr-0x1000, *(volatile unsigned int *)(addr - 0x1000));");
- puts("addr2 = 0x44000120; // Mac address");
+ puts("addr2 = 0x44000140; // Mac address");
puts("*(unsigned int *)(addr2+0x3000) = 42;");
puts("enable_dtlb();");
-// puts("asm volatile(\"mvhi r11, 0x4400\\n\\t ori r11, r11, 0x0120\\n\\t lw %0, (r11+0)\" : \"=&r\"(data) :: \"r11\" );");
- puts("asm volatile(\"mvhi r11, 0x4400\\n\\t ori r11, r11, 0x0120\\n\\t lw %0, (r11+0)\" : \"=&r\"(data) :: \"r11\" );");
+// puts("asm volatile(\"mvhi r11, 0x4400\\n\\t ori r11, r11, 0x0140\\n\\t lw %0, (r11+0)\" : \"=&r\"(data) :: \"r11\" );");
+ puts("asm volatile(\"mvhi r11, 0x4400\\n\\t ori r11, r11, 0x0140\\n\\t lw %0, (r11+0)\" : \"=&r\"(data) :: \"r11\" );");
puts("disable_dtlb();");
puts("printf(\"[MMU ON] *(0x%08X) == 0x%08X (%d)\\n\", addr2, data, data);");
printf("printf(\"Test n° %02d : \");\n", test_num);
4 software/mmu-bios/tlb_miss_handler.c
View
@@ -27,8 +27,12 @@ void dtlb_miss_handler(void)
void itlb_miss_handler(void)
{
unsigned int vaddr, paddr;
+ unsigned int EA;
+ asm volatile("mv %0, ea": "=r"(EA) :: );
asm volatile("rcsr %0, itlbma" : "=r"(vaddr) :: );
+
+ printf("ea == 0x%08X\n", EA);
printf("Address 0x%08X caused an ITLB page fault\n", vaddr);
paddr = get_mmu_mapping_for(vaddr);

No commit comments for this range

Something went wrong with that request. Please try again.