[520] | 1 | /* |
---|
| 2 | * itlb inval: a write to a PTD1 should invalidate the corresponding |
---|
| 3 | * itlb and dtlb entries. |
---|
| 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 | /* cause a DTLB miss */ |
---|
| 32 | la t0, roval |
---|
| 33 | lw a0, 0(t0) |
---|
| 34 | PRINTX |
---|
| 35 | PUTCHAR(' ') |
---|
| 36 | |
---|
| 37 | /* cause a itlb miss */ |
---|
| 38 | jal doload |
---|
| 39 | nop |
---|
| 40 | PRINTX |
---|
| 41 | PUTCHAR(' ') |
---|
| 42 | |
---|
| 43 | la t0, pte1_ac |
---|
| 44 | 1: |
---|
| 45 | ll a0, 0(t0) |
---|
| 46 | la a0, (0x2000 >> 12) | PTE1_V | PTE1_T /* check real address of pet2_b */ |
---|
| 47 | sc a0, 0(t0) /* change PTD1 */ |
---|
| 48 | beqz a0, 1b |
---|
| 49 | nop |
---|
| 50 | |
---|
| 51 | /* now we should get the second values */ |
---|
| 52 | la t0, roval |
---|
| 53 | lw a0, 0(t0) |
---|
| 54 | PRINTX |
---|
| 55 | PUTCHAR(' ') |
---|
| 56 | |
---|
| 57 | jal doload |
---|
| 58 | nop |
---|
| 59 | PRINTX |
---|
| 60 | PUTCHAR('\n') |
---|
| 61 | /* we should get there */ |
---|
| 62 | EXIT(0) |
---|
| 63 | |
---|
| 64 | .globl excep |
---|
| 65 | excep: |
---|
| 66 | .set noreorder |
---|
| 67 | PRINT(statusstr) |
---|
| 68 | mfc0 a0, COP0_STATUS |
---|
| 69 | PRINTX |
---|
| 70 | |
---|
| 71 | PRINT(causestr) |
---|
| 72 | mfc0 a0, COP0_CAUSE |
---|
| 73 | PRINTX |
---|
| 74 | |
---|
| 75 | PRINT(pcstr) |
---|
| 76 | mfc0 a0, COP0_EXPC |
---|
| 77 | PRINTX |
---|
| 78 | |
---|
| 79 | PRINT(badvastr) |
---|
| 80 | mfc0 a0, COP_0_BADVADDR |
---|
| 81 | PRINTX |
---|
| 82 | |
---|
| 83 | PUTCHAR('\n') |
---|
| 84 | /* we should not get there */ |
---|
| 85 | EXIT(1) |
---|
| 86 | |
---|
| 87 | .rodata: |
---|
| 88 | statusstr: .ascii "status \0" |
---|
| 89 | causestr: .ascii " cause \0" |
---|
| 90 | pcstr: .ascii " pc \0" |
---|
| 91 | badvastr: .ascii " badva \0" |
---|
| 92 | mmustr: .ascii "mmu started \0" |
---|
| 93 | startstr: .ascii "start\n\0" |
---|
| 94 | |
---|
| 95 | .org EXCEP_ADDRESS - BOOT_ADDRESS |
---|
| 96 | .globl evect |
---|
| 97 | evect: |
---|
| 98 | j excep |
---|
| 99 | nop |
---|
| 100 | |
---|
| 101 | /* |
---|
| 102 | * code that will be switched by MMU switch. |
---|
| 103 | * we use a ldscript trick here, to load this function at |
---|
| 104 | * the appropriate address |
---|
| 105 | */ |
---|
| 106 | .section .text2, "ax" |
---|
| 107 | .globl doload |
---|
| 108 | doload: |
---|
| 109 | jr ra |
---|
| 110 | li a0, MAGIC1 |
---|
| 111 | /* we should not get there */ |
---|
| 112 | EXIT(1) |
---|
| 113 | nop |
---|
| 114 | roval: .word MAGIC2 |
---|
| 115 | .align 12 |
---|
| 116 | .globl doload2 |
---|
| 117 | doload2: |
---|
| 118 | jr ra |
---|
| 119 | li a0, MAGIC2 |
---|
| 120 | /* we should not get there */ |
---|
| 121 | EXIT(1) |
---|
| 122 | nop |
---|
| 123 | roval2: .word MAGIC1 |
---|
| 124 | |
---|
| 125 | .data |
---|
| 126 | .word MAGIC1 |
---|
| 127 | testval: |
---|
| 128 | .word MAGIC2 |
---|
| 129 | .globl pte2_a |
---|
| 130 | |
---|
| 131 | /* |
---|
| 132 | * one PD with a level 2 PTP: we change an entry in the PD and |
---|
| 133 | * check that the TLBs has been invalidated |
---|
| 134 | */ |
---|
| 135 | pte2_a: |
---|
| 136 | .align 12 |
---|
| 137 | .word PTE2_V | PTE2_C | PTE2_X |
---|
| 138 | .word BOOT_ADDRESS >> 12 |
---|
| 139 | .word PTE2_V | PTE2_C | PTE2_X |
---|
| 140 | .word (BOOT_ADDRESS+0x1000) >> 12 /* address of doload */ |
---|
| 141 | .org pte2_a + 4092 |
---|
| 142 | .word 0 |
---|
| 143 | .globl pte2_b |
---|
| 144 | .globl pte1_a |
---|
| 145 | pte2_b: |
---|
| 146 | .align 12 |
---|
| 147 | .word PTE2_V | PTE2_C | PTE2_X |
---|
| 148 | .word BOOT_ADDRESS >> 12 |
---|
| 149 | .word PTE2_V | PTE2_C | PTE2_X |
---|
| 150 | .word (BOOT_ADDRESS+0x2000) >> 12 /* address of doload2 */ |
---|
| 151 | .org pte2_b + 4092 |
---|
| 152 | .word 0 |
---|
| 153 | .globl pte2_b |
---|
| 154 | .globl pte1_a |
---|
| 155 | pte1_a: |
---|
| 156 | .align 13 |
---|
| 157 | .word PTE1_V | PTE1_C | PTE1_W | 0x0 /* map PA 0 at VA 0 */ |
---|
| 158 | .word 0x0 |
---|
| 159 | .org pte1_a + (BOOT_ADDRESS >> 21) * 4 |
---|
| 160 | pte1_ac: |
---|
| 161 | .word PTE1_V | PTE1_T | (0x1000 >> 12) /* map PA 0xbfc00000 at VA 0xbfc00000 with 4k page: check real address of pte2_a !!! */ |
---|
| 162 | .org pte1_a + (TTY_BASE >> 21) * 4 |
---|
| 163 | .word PTE1_V | PTE1_W | (TTY_BASE >> 21) /* map PA 0xd0200000 at VA 0xd0200000 */ |
---|
| 164 | .org pte1_a + (EXIT_BASE >> 21) * 4 |
---|
| 165 | .word PTE1_V | PTE1_W | (EXIT_BASE >> 21) /* map PA 0xe0000000 at VA 0xe0000000 */ |
---|
| 166 | .org pte1_a + 8192 |
---|