Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fallen/milkymist-mmu
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0b65466c149b
Choose a base ref
...
head repository: fallen/milkymist-mmu
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 135ee33be77c
Choose a head ref
  • 4 commits
  • 5 files changed
  • 1 contributor

Commits on Jun 22, 2012

  1. Copy the full SHA
    601df58 View commit details
  2. Copy the full SHA
    6d3daba View commit details
  3. Copy the full SHA
    3f9c9a7 View commit details
  4. Copy the full SHA
    135ee33 View commit details
Showing with 31 additions and 11 deletions.
  1. +2 −2 software/mmu-bios/crt0.S
  2. +9 −0 software/mmu-bios/dtlb_exception_handling_tests.c
  3. +9 −3 software/mmu-bios/main.c
  4. +7 −6 software/mmu-bios/mmu_test_gen.c
  5. +4 −0 software/mmu-bios/tlb_miss_handler.c
4 changes: 2 additions & 2 deletions software/mmu-bios/crt0.S
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 0 deletions software/mmu-bios/dtlb_exception_handling_tests.c
Original file line number Diff line number Diff line change
@@ -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 changes: 9 additions & 3 deletions software/mmu-bios/main.c
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 6 deletions software/mmu-bios/mmu_test_gen.c
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions software/mmu-bios/tlb_miss_handler.c
Original file line number Diff line number Diff line change
@@ -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);