[520] | 1 | /* |
---|
| 2 | * itlb inval: a write to a PTE2 should invalidate the corresponding |
---|
| 3 | * itlb entry. |
---|
| 4 | */ |
---|
| 5 | #include <registers.h> |
---|
| 6 | #include <misc.h> |
---|
| 7 | #include <vcache.h> |
---|
| 8 | |
---|
| 9 | .text |
---|
| 10 | .globl _start |
---|
| 11 | _start: |
---|
| 12 | .set noreorder |
---|
| 13 | la k0, TTY_BASE |
---|
| 14 | la k1, EXIT_BASE |
---|
| 15 | |
---|
| 16 | PRINT(startstr) |
---|
| 17 | |
---|
| 18 | /* reset cop0 status (keep BEV) */ |
---|
| 19 | lui a0, 0x0040; |
---|
| 20 | mtc0 a0, COP0_STATUS |
---|
| 21 | |
---|
| 22 | la a0, pte1_a |
---|
| 23 | srl a0, a0, 13 |
---|
| 24 | mtc2 a0, VC_PTPR |
---|
| 25 | nop |
---|
| 26 | |
---|
| 27 | li a0, VC_TLB_EN_ITLB | VC_TLB_EN_DTLB | VC_TLB_EN_ICACHE | VC_TLB_EN_DCACHE |
---|
| 28 | mtc2 a0, VC_TLB_EN |
---|
| 29 | |
---|
| 30 | PRINT(mmustr) |
---|
| 31 | jal doload |
---|
| 32 | nop |
---|
| 33 | PRINTX |
---|
| 34 | PUTCHAR(' ') |
---|
| 35 | la t0, pte2_a |
---|
| 36 | la a0, (BOOT_ADDRESS+0x2000) >> 12 |
---|
| 37 | sw a0, 12(t0) /* change PTE2 */ |
---|
| 38 | sync |
---|
| 39 | 1: |
---|
| 40 | ll a0, 8(t0) |
---|
| 41 | la a0, PTE2_V | PTE2_C | PTE2_X |
---|
| 42 | sc a0, 8(t0) |
---|
| 43 | beqz a0, 1b |
---|
| 44 | nop |
---|
| 45 | |
---|
| 46 | jal doload /* now we should get the second value */ |
---|
| 47 | nop |
---|
| 48 | PRINTX |
---|
| 49 | PUTCHAR('\n') |
---|
| 50 | /* we should get there */ |
---|
| 51 | EXIT(0) |
---|
| 52 | |
---|
| 53 | .globl excep |
---|
| 54 | excep: |
---|
| 55 | .set noreorder |
---|
| 56 | PRINT(statusstr) |
---|
| 57 | mfc0 a0, COP0_STATUS |
---|
| 58 | PRINTX |
---|
| 59 | |
---|
| 60 | PRINT(causestr) |
---|
| 61 | mfc0 a0, COP0_CAUSE |
---|
| 62 | PRINTX |
---|
| 63 | |
---|
| 64 | PRINT(pcstr) |
---|
| 65 | mfc0 a0, COP0_EXPC |
---|
| 66 | PRINTX |
---|
| 67 | |
---|
| 68 | PRINT(badvastr) |
---|
| 69 | mfc0 a0, COP_0_BADVADDR |
---|
| 70 | PRINTX |
---|
| 71 | |
---|
| 72 | PUTCHAR('\n') |
---|
| 73 | /* we should not get there */ |
---|
| 74 | EXIT(1) |
---|
| 75 | |
---|
| 76 | .rodata: |
---|
| 77 | statusstr: .ascii "status \0" |
---|
| 78 | causestr: .ascii " cause \0" |
---|
| 79 | pcstr: .ascii " pc \0" |
---|
| 80 | badvastr: .ascii " badva \0" |
---|
| 81 | mmustr: .ascii "mmu started \0" |
---|
| 82 | startstr: .ascii "start\n\0" |
---|
| 83 | |
---|
| 84 | .org EXCEP_ADDRESS - BOOT_ADDRESS |
---|
| 85 | .globl evect |
---|
| 86 | evect: |
---|
| 87 | j excep |
---|
| 88 | nop |
---|
| 89 | |
---|
| 90 | /* |
---|
| 91 | * code that will be switched by MMU switch. |
---|
| 92 | * we use a ldscript trick here, to load this function at |
---|
| 93 | * the appropriate address |
---|
| 94 | */ |
---|
| 95 | .section .text2, "ax" |
---|
| 96 | .globl doload |
---|
| 97 | doload: |
---|
| 98 | jr ra |
---|
| 99 | li a0, MAGIC1 |
---|
| 100 | /* we should not get there */ |
---|
| 101 | EXIT(1) |
---|
| 102 | nop |
---|
| 103 | .align 12 |
---|
| 104 | .globl doload2 |
---|
| 105 | doload2: |
---|
| 106 | jr ra |
---|
| 107 | li a0, MAGIC2 |
---|
| 108 | /* we should not get there */ |
---|
| 109 | EXIT(1) |
---|
| 110 | nop |
---|
| 111 | |
---|
| 112 | .data |
---|
| 113 | .word MAGIC1 |
---|
| 114 | testval: |
---|
| 115 | .word MAGIC2 |
---|
| 116 | .globl pte2_a |
---|
| 117 | |
---|
| 118 | /* |
---|
| 119 | * one PD with a level 2 PTP: we change an entry in the PTP and |
---|
| 120 | * check that the ITLB has been invalidated |
---|
| 121 | */ |
---|
| 122 | pte2_a: |
---|
| 123 | .align 12 |
---|
| 124 | .word PTE2_V | PTE2_C | PTE2_X |
---|
| 125 | .word BOOT_ADDRESS >> 12 |
---|
| 126 | .word PTE2_V | PTE2_C | PTE2_X |
---|
| 127 | .word (BOOT_ADDRESS+0x1000) >> 12 |
---|
| 128 | .org pte2_a + 4092 |
---|
| 129 | .word 0 |
---|
| 130 | .globl pte2_b |
---|
| 131 | .globl pte1_a |
---|
| 132 | pte1_a: |
---|
| 133 | .align 13 |
---|
| 134 | .word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */ |
---|
| 135 | .word 0x0 |
---|
| 136 | .org pte1_a + (BOOT_ADDRESS >> 21) * 4 |
---|
| 137 | .word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */ |
---|
| 138 | .org pte1_a + (TTY_BASE >> 21) * 4 |
---|
| 139 | .word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */ |
---|
| 140 | .org pte1_a + (EXIT_BASE >> 21) * 4 |
---|
| 141 | .word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */ |
---|
| 142 | .org pte1_a + 8192 |
---|