Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | :!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2 | :! | |
3 | :! TLU SW trap sweep testing | |
4 | :! | |
5 | :! This diag attempts to hit all the software traps for user/super/hyper | |
6 | :! modes | |
7 | :! | |
8 | :! For each trap, replace the 1st instruction in trap handler with | |
9 | :! 'done', then execute the SW trap and afterwards replace the original | |
10 | :! handler instruction back ... | |
11 | :! | |
12 | :! SAT : SPC2 or higher .. | |
13 | :! | |
14 | :! | |
15 | :! | |
16 | ||
17 | # PAL routines used in Diag | |
18 | # Set random seed | |
19 | srand(137329); | |
20 | ||
21 | @levels = (0..6); | |
22 | @all_sw_trap_type = qw(100 101 102 103 104 105 106 107 108 109 | |
23 | 10a 10b 10c 10d 10e 10f 110 111 112 113 114 115 116 | |
24 | 117 118 119 11a 11b 11c 11d 11e 11f 120 121 122 123 | |
25 | 124 125 126 127 128 129 12a 12b 12c 12d 12e 12f 130 | |
26 | 131 132 133 134 135 136 137 138 139 13a 13b 13c 13d | |
27 | 13e 13f 140 141 142 143 144 145 146 147 148 149 14a | |
28 | 14b 14c 14d 14e 14f 150 151 152 153 154 155 156 157 | |
29 | 158 159 15a 15b 15c 15d 15e 15f 160 161 162 163 164 | |
30 | 165 166 167 168 169 16a 16b 16c 16d 16e 16f 170 171 | |
31 | 172 173 174 175 176 177 178 179 17a 17b 17c 17d 17e | |
32 | 17f 180 181 182 183 184 185 186 187 188 189 18a 18b | |
33 | 18c 18d 18e 18f 190 191 192 193 194 195 196 197 198 | |
34 | 199 19a 19b 19c 19d 19e 19f 1a0 1a1 1a2 1a3 1a4 1a5 | |
35 | 1a6 1a7 1a8 1a9 1aa 1ab 1ac 1ad 1ae 1af 1b0 1b1 1b2 | |
36 | 1b3 1b4 1b5 1b6 1b7 1b8 1b9 1ba 1bb 1bc 1bd 1be 1bf | |
37 | 1c0 1c1 1c2 1c3 1c4 1c5 1c6 1c7 1c8 1c9 1ca 1cb 1cc | |
38 | 1cd 1ce 1cf 1d0 1d1 1d2 1d3 1d4 1d5 1d6 1d7 1d8 1d9 | |
39 | 1da 1db 1dc 1dd 1de 1df 1e0 1e1 1e2 1e3 1e4 1e5 1e6 | |
40 | 1e7 1e8 1e9 1ea 1eb 1ec 1ed 1ee 1ef 1f0 1f1 1f2 1f3 | |
41 | 1f4 1f5 1f6 1f7 1f8 1f9 1fa 1fb 1fc 1fd 1fe 1ff | |
42 | ); | |
43 | ||
44 | @reserved_traps = qw(100 101 102 103 120 122 180 181 182 1a0 1a1); | |
45 | ||
46 | # Function to return a random number .. | |
47 | sub get_rand {return int (rand $_[0])} | |
48 | ||
49 | # Diag Starts : | |
50 | :#define MAIN_PAGE_HV_ALSO | |
51 | :#define MAIN_PAGE_NUCLEUS_ALSO | |
52 | :#define DONE_OPCODE 0x81f00000 | |
53 | :#define H_HT0_Illegal_instruction_0x10 | |
54 | :#define My_HT0_Illegal_instruction_0x10 \ | |
55 | : done;nop | |
56 | : | |
57 | :#define H_HT0_Watchdog_Reset_0x02 | |
58 | :#define My_HT0_Watchdog_Reset_0x02 \ | |
59 | : rdpr %tt, %g1;\ | |
60 | : cmp %g1, 0x120;\ | |
61 | : te T_API_CHANGE_PRIV ;\ | |
62 | : rdhpr %htba, %g2;\ | |
63 | : sllx %g1, 5, %g1;\ | |
64 | : add %g2, %g1, %g2;\ | |
65 | : jmp %g2;\ | |
66 | : nop;\ | |
67 | : | |
68 | :#define My_RED_Mode_Other_Reset \ | |
69 | : rdpr %tt, %g1;\ | |
70 | : cmp %g1, 0x120;\ | |
71 | : te T_API_CHANGE_PRIV ;\ | |
72 | : rdhpr %htba, %g2;\ | |
73 | : sllx %g1, 5, %g1;\ | |
74 | : add %g2, %g1, %g2;\ | |
75 | : jmp %g2;\ | |
76 | : nop;\ | |
77 | : | |
78 | :#define My_Watchdog_Reset \ | |
79 | : rdpr %tt, %g1;\ | |
80 | : cmp %g1, 0x120;\ | |
81 | : te T_API_CHANGE_PRIV ;\ | |
82 | : rdhpr %htba, %g2;\ | |
83 | : sllx %g1, 5, %g1;\ | |
84 | : add %g2, %g1, %g2;\ | |
85 | : jmp %g2;\ | |
86 | : nop;\ | |
87 | : | |
88 | : | |
89 | :#include "hboot.s" | |
90 | : | |
91 | :.text | |
92 | :.global main | |
93 | : | |
94 | :main: | |
95 | : | |
96 | : ta T_RD_THID | |
97 | : brnz %o1, wait_for_ttable_rewrite | |
98 | : nop | |
99 | : ! T0 does ttable update | |
100 | : ta T_CHANGE_HPRIV | |
101 | : set HV_TRAP_BASE_PA, %r23 ! Save HTrap Base Address | |
102 | : set TRAP_BASE_VA, %r22 ! Save Trap Base Address | |
103 | : set (1<<14), %r24 | |
104 | : | |
105 | : setx testing_traps, %r21, %r20 | |
106 | : | |
107 | :next_tt: | |
108 | : set DONE_OPCODE, %r21 ! Done opcode | |
109 | : ldx [%r20], %r19 ! Get TT offset | |
110 | : brz %r19, done_ttable_rewrite | |
111 | : stw %r21, [%r19+%r23] ! Write 'done in Htrap handler | |
112 | : stwa %r21, [%r19+%r22]ASI_REAL_MEM ! Write 'done in trap(0) handler | |
113 | : or %r19, %r24, %r19 | |
114 | : stwa %r21, [%r19+%r22]ASI_REAL_MEM ! Write 'done in trap(1) handler | |
115 | : add %r20, 8, %r20 ! Next address | |
116 | : b next_tt | |
117 | : nop | |
118 | :done_ttable_rewrite: | |
119 | : ta T_CHANGE_NONHPRIV | |
120 | : setx done_tt_update, %g1, %g2 | |
121 | : stx %r20, [%g2] | |
122 | : b begin_sw_tt_test | |
123 | : nop | |
124 | : | |
125 | :wait_for_ttable_rewrite: ! All other threads wait here | |
126 | : mov 0x50, %g1 | |
127 | : setx rand_word1, %g3, %g2 | |
128 | : ldd [%g2], %f0 | |
129 | : stx %g1, [%g2+16] | |
130 | : ldd [%g2+16], %f2 | |
131 | : fdivs %f0, %f2, %f4 | |
132 | : setx done_tt_update, %g1, %g2 | |
133 | : ldx [%g2], %g1 | |
134 | : brz %g1, wait_for_ttable_rewrite | |
135 | : nop | |
136 | : | |
137 | :begin_sw_tt_test: | |
138 | : | |
139 | foreach $tl (@levels) { | |
140 | : | |
141 | if ($tl <3) { | |
142 | : ta T_CHANGE_HPRIV | |
143 | : wrpr %g0, $tl, %tl | |
144 | : ta T_CHANGE_NONPRIV | |
145 | : ta T_CHANGE_NONHPRIV | |
146 | : | |
147 | : | |
148 | :! User SW trap testing - level $tl: | |
149 | foreach $ttype (@all_sw_trap_type) { | |
150 | next if (grep(/^$ttype$/, @reserved_traps)); | |
151 | :! SW trap # $ttype | |
152 | :user_${tl}_tt_$ttype: | |
153 | : ta (0x$ttype-0x100) | |
154 | : | |
155 | } | |
156 | : | |
157 | :! Priv SW trap testing - level $tl: | |
158 | : ta T_CHANGE_PRIV | |
159 | foreach $ttype (@all_sw_trap_type) { | |
160 | next if (grep(/^$ttype$/, @reserved_traps)); | |
161 | :! SW trap # $ttype | |
162 | :priv_${tl}_tt_$ttype: | |
163 | : ta (0x$ttype-0x100) | |
164 | : | |
165 | } | |
166 | : | |
167 | :! Hyper SW trap testing - level $tl: | |
168 | : | |
169 | : ta T_CHANGE_HPRIV | |
170 | foreach $ttype (@all_sw_trap_type) { | |
171 | next if (grep(/^$ttype$/, @reserved_traps)); | |
172 | :! SW trap # $ttype | |
173 | :hpriv_${tl}_tt_$ttype: | |
174 | : ta (0x$ttype-0x100) | |
175 | : | |
176 | } | |
177 | } else { | |
178 | : | |
179 | : | |
180 | :! Hyper SW trap testing - level $tl: | |
181 | : wrpr %g0, $tl, %tl | |
182 | : | |
183 | foreach $ttype (@all_sw_trap_type) { | |
184 | next if (grep(/^$ttype$/, @reserved_traps)); | |
185 | :! SW trap # $ttype | |
186 | :hpriv_${tl}_tt_$ttype: | |
187 | : ta (0x$ttype-0x100) | |
188 | : | |
189 | } | |
190 | } | |
191 | : | |
192 | } | |
193 | : | |
194 | : | |
195 | :finished: | |
196 | : ta T_CHANGE_NONPRIV | |
197 | : EXIT_GOOD | |
198 | : nop | |
199 | : | |
200 | : | |
201 | ||
202 | :.data | |
203 | :rand_word1: | |
204 | : .xword 0xcfabdce123469ef0 | |
205 | : .xword 0x2355ce123470e901 | |
206 | :rand_word2: | |
207 | : .xword 0x0 | |
208 | : .xword 0x0 | |
209 | : .xword 0x0 | |
210 | :done_tt_update: | |
211 | : .xword 0x0 | |
212 | : | |
213 | :testing_traps: | |
214 | foreach $ttype (@all_sw_trap_type) { | |
215 | next if (grep(/^$ttype$/, @reserved_traps)); | |
216 | : .xword (0x$ttype << 5) | |
217 | } | |
218 | : .xword 0x0 | |
219 |