Skip to content
This repository
  • 4 commits
  • 5 files changed
  • 0 comments
  • 1 contributor
4  software/mmu-bios/crt0.S
@@ -122,12 +122,12 @@ _dtlb_miss_exception_handler:
122 122
 _itlb_miss_exception_handler:
123 123
 	sw	(sp+0), ra
124 124
 	calli	.save_all
125  
-	rcsr	r1, itlbma /* get virtual address which caused the page fault */
126  
-	mv 	ea, r1 /* when returning from exception we branch back to that virtual address */
127 125
 	calli	itlb_miss_handler
128 126
 	bi	.restore_all_and_eret
129 127
 	nop
130 128
 	nop
  129
+	nop
  130
+	nop
131 131
 
132 132
 macaddress:
133 133
 	.byte 0x10
9  software/mmu-bios/dtlb_exception_handling_tests.c
@@ -17,6 +17,15 @@ void dtlb_exception_handling_tests() {
17 17
 
18 18
 	printf("stack == 0x%08X\n", stack);
19 19
 
  20
+	ret = mmu_map(0x44000000, 0x44000000, ITLB_MAPPING | MAPPING_CAN_READ);
  21
+	check_for_error(ret);
  22
+	ret = mmu_map(0x44001000, 0x44001000, ITLB_MAPPING | MAPPING_CAN_READ);
  23
+	check_for_error(ret);
  24
+	ret = mmu_map(0x44002000, 0x44002000, ITLB_MAPPING | MAPPING_CAN_READ);
  25
+	check_for_error(ret);
  26
+	ret = mmu_map(0x44003000, 0x44003000, ITLB_MAPPING | MAPPING_CAN_READ);
  27
+	check_for_error(ret);
  28
+
20 29
 	addr = 0x44004004;
21 30
 
22 31
 	printf("\n=> Mapping 0x%08X to 0x%08X\n", addr, addr);
12  software/mmu-bios/main.c
@@ -75,7 +75,8 @@ int printf(const char *fmt, ...)
75 75
 }
76 76
 
77 77
 void f(void) {
78  
-	CSR_UART_RXTX = '@';
  78
+	char c = '@';
  79
+	CSR_UART_RXTX = c;
79 80
 //	asm volatile("bi f" ::: ); // We intinitely loop to f()
80 81
 	asm volatile("xor r0, r0, r0\n\t"
81 82
 		     "xor r0, r0, r0" ::: );
@@ -108,8 +109,13 @@ void itlbtest(void) {
108 109
 		*pdest = *p;
109 110
 	puts("Copy DONE");
110 111
 
111  
-	asm volatile("wcsr DCC, r0");
112  
-	asm volatile("wcsr ICC, r0");
  112
+	asm volatile("wcsr DCC, r0\n\t"
  113
+		     "xor r0, r0, r0\n\t"
  114
+		     "xor r0, r0, r0\n\t"
  115
+		     "xor r0, r0, r0\n\t"
  116
+		     "xor r0, r0, r0");
  117
+	asm volatile("wcsr ICC, r0\n\t"
  118
+		     "xor r0, r0, r0");
113 119
 	puts("Instruction and Data caches have been invalidated");
114 120
 
115 121
 	call_function_with_itlb_enabled(f_addr);
13  software/mmu-bios/mmu_test_gen.c
@@ -44,9 +44,10 @@ int main(void) {
44 44
 		"int success, failure;\n"
45 45
 		"unsigned int count;\n"
46 46
 		"asm volatile(\"mv %0, sp\" : \"=r\"(stack) :: );\n"
47  
-		"mmu_dtlb_map(0x44002000, 0x44001000);\n"
48  
-		"mmu_dtlb_map(stack, stack);\n"
49  
-		"mmu_dtlb_map(stack-0x1000, stack-0x1000);\n"
  47
+		"mmu_map(0x44002000, 0x44001000, DTLB_MAPPING | MAPPING_CAN_READ | MAPPING_CAN_WRITE);\n"
  48
+		"mmu_map(0x44000000, 0x44003000, DTLB_MAPPING | MAPPING_CAN_READ | MAPPING_CAN_WRITE);\n"
  49
+		"mmu_map(stack, stack, DTLB_MAPPING | MAPPING_CAN_READ | MAPPING_CAN_WRITE);\n"
  50
+		"mmu_map(stack-0x1000, stack-0x1000, DTLB_MAPPING | MAPPING_CAN_READ | MAPPING_CAN_WRITE);\n"
50 51
 		"printf(\"stack == 0x%08X\\n\", stack);"
51 52
 		"a = 0;\n"
52 53
 		"b = 1;\n"
@@ -81,11 +82,11 @@ int main(void) {
81 82
 			puts("disable_dtlb();");
82 83
 			puts("printf(\"[MMU ON] *(0x%08X) == 0x%08X\\n\", addr, data);");
83 84
 			puts("printf(\"[MMU OFF] *(0x%08X) == 0x%08X\\n\", addr-0x1000, *(volatile unsigned int *)(addr - 0x1000));");
84  
-			puts("addr2 = 0x44000120; // Mac address");
  85
+			puts("addr2 = 0x44000140; // Mac address");
85 86
 			puts("*(unsigned int *)(addr2+0x3000) = 42;");
86 87
 			puts("enable_dtlb();");
87  
-//			puts("asm volatile(\"mvhi r11, 0x4400\\n\\t ori r11, r11, 0x0120\\n\\t lw %0, (r11+0)\" : \"=&r\"(data) :: \"r11\" );");
88  
-			puts("asm volatile(\"mvhi r11, 0x4400\\n\\t ori r11, r11, 0x0120\\n\\t lw %0, (r11+0)\" : \"=&r\"(data) :: \"r11\" );");
  88
+//			puts("asm volatile(\"mvhi r11, 0x4400\\n\\t ori r11, r11, 0x0140\\n\\t lw %0, (r11+0)\" : \"=&r\"(data) :: \"r11\" );");
  89
+			puts("asm volatile(\"mvhi r11, 0x4400\\n\\t ori r11, r11, 0x0140\\n\\t lw %0, (r11+0)\" : \"=&r\"(data) :: \"r11\" );");
89 90
 			puts("disable_dtlb();");
90 91
 			puts("printf(\"[MMU ON] *(0x%08X) == 0x%08X (%d)\\n\", addr2, data, data);");
91 92
 			printf("printf(\"Test n° %02d : \");\n", test_num);
4  software/mmu-bios/tlb_miss_handler.c
@@ -27,8 +27,12 @@ void dtlb_miss_handler(void)
27 27
 void itlb_miss_handler(void)
28 28
 {
29 29
 	unsigned int vaddr, paddr;
  30
+	unsigned int EA;
30 31
 
  32
+	asm volatile("mv %0, ea": "=r"(EA) :: );
31 33
 	asm volatile("rcsr %0, itlbma" : "=r"(vaddr) :: );
  34
+
  35
+	printf("ea == 0x%08X\n", EA);
32 36
 	printf("Address 0x%08X caused an ITLB page fault\n", vaddr);
33 37
 
34 38
 	paddr = get_mmu_mapping_for(vaddr);

No commit comments for this range

Something went wrong with that request. Please try again.