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