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