Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: traps_save_restore.s | |
5 | * Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
6 | * 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
7 | * | |
8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; version 2 of the License. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 | * | |
23 | * For the avoidance of doubt, and except that if any non-GPL license | |
24 | * choice is available it will apply instead, Sun elects to use only | |
25 | * the General Public License version 2 (GPLv2) at this time for any | |
26 | * software where a choice of GPL license versions is made | |
27 | * available with the language indicating that GPLv2 or any later version | |
28 | * may be used, or where a choice of which version of the GPL is applied is | |
29 | * otherwise unspecified. | |
30 | * | |
31 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
32 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
33 | * have any questions. | |
34 | * | |
35 | * | |
36 | * ========== Copyright Header End ============================================ | |
37 | */ | |
38 | #define MAIN_PAGE_NUCLEUS_ALSO | |
39 | #define MAIN_PAGE_HV_ALSO | |
40 | !#include "nmacros.h" | |
41 | ||
42 | #define MY_SPILL_TRAP \ | |
43 | saved; \ | |
44 | wrpr %g0, %cwp; \ | |
45 | rdpr %tl, %l6; \ | |
46 | rdpr %tt, %l5; \ | |
47 | rd %pc, %l4; \ | |
48 | inc %l3; \ | |
49 | done; \ | |
50 | nop; | |
51 | ||
52 | #define MY_FILL_TRAP \ | |
53 | restored; \ | |
54 | wrpr %g0, %cwp; \ | |
55 | rdpr %tl, %l6; \ | |
56 | rdpr %tt, %l5; \ | |
57 | rd %pc, %l4; \ | |
58 | inc %l3; \ | |
59 | done; \ | |
60 | nop; | |
61 | ||
62 | #define MY_GENERIC_TRAP \ | |
63 | wrpr %g0, %cwp; \ | |
64 | rdpr %tl, %l6; \ | |
65 | rdpr %tt, %l5; \ | |
66 | rd %pc, %l4; \ | |
67 | inc %l3; \ | |
68 | done; \ | |
69 | nop; \ | |
70 | nop; | |
71 | ||
72 | ||
73 | #define H_T0_Window_Spill_0_Normal_Trap | |
74 | #define My_T0_Window_Spill_0_Normal_Trap MY_SPILL_TRAP | |
75 | #define H_T0_Window_Spill_1_Normal_Trap | |
76 | #define My_T0_Window_Spill_1_Normal_Trap MY_SPILL_TRAP | |
77 | #define H_T0_Window_Spill_2_Normal_Trap | |
78 | #define My_T0_Window_Spill_2_Normal_Trap MY_SPILL_TRAP | |
79 | #define H_T0_Window_Spill_3_Normal_Trap | |
80 | #define My_T0_Window_Spill_3_Normal_Trap MY_SPILL_TRAP | |
81 | #define H_T0_Window_Spill_4_Normal_Trap | |
82 | #define My_T0_Window_Spill_4_Normal_Trap MY_SPILL_TRAP | |
83 | #define H_T0_Window_Spill_5_Normal_Trap | |
84 | #define My_T0_Window_Spill_5_Normal_Trap MY_SPILL_TRAP | |
85 | #define H_T0_Window_Spill_6_Normal_Trap | |
86 | #define My_T0_Window_Spill_6_Normal_Trap MY_SPILL_TRAP | |
87 | #define H_T0_Window_Spill_7_Normal_Trap | |
88 | #define My_T0_Window_Spill_7_Normal_Trap MY_SPILL_TRAP | |
89 | ||
90 | #define H_T0_Window_Spill_0_Other_Trap | |
91 | #define My_T0_Window_Spill_0_Other_Trap MY_SPILL_TRAP | |
92 | #define H_T0_Window_Spill_1_Other_Trap | |
93 | #define My_T0_Window_Spill_1_Other_Trap MY_SPILL_TRAP | |
94 | #define H_T0_Window_Spill_2_Other_Trap | |
95 | #define My_T0_Window_Spill_2_Other_Trap MY_SPILL_TRAP | |
96 | #define H_T0_Window_Spill_3_Other_Trap | |
97 | #define My_T0_Window_Spill_3_Other_Trap MY_SPILL_TRAP | |
98 | #define H_T0_Window_Spill_4_Other_Trap | |
99 | #define My_T0_Window_Spill_4_Other_Trap MY_SPILL_TRAP | |
100 | #define H_T0_Window_Spill_5_Other_Trap | |
101 | #define My_T0_Window_Spill_5_Other_Trap MY_SPILL_TRAP | |
102 | #define H_T0_Window_Spill_6_Other_Trap | |
103 | #define My_T0_Window_Spill_6_Other_Trap MY_SPILL_TRAP | |
104 | #define H_T0_Window_Spill_7_Other_Trap | |
105 | #define My_T0_Window_Spill_7_Other_Trap MY_SPILL_TRAP | |
106 | ||
107 | ! fill | |
108 | #define H_T0_Window_Fill_0_Normal_Trap | |
109 | #define My_T0_Window_Fill_0_Normal_Trap MY_FILL_TRAP | |
110 | #define H_T0_Window_Fill_1_Normal_Trap | |
111 | #define My_T0_Window_Fill_1_Normal_Trap MY_FILL_TRAP | |
112 | #define H_T0_Window_Fill_2_Normal_Trap | |
113 | #define My_T0_Window_Fill_2_Normal_Trap MY_FILL_TRAP | |
114 | #define H_T0_Window_Fill_3_Normal_Trap | |
115 | #define My_T0_Window_Fill_3_Normal_Trap MY_FILL_TRAP | |
116 | #define H_T0_Window_Fill_4_Normal_Trap | |
117 | #define My_T0_Window_Fill_4_Normal_Trap MY_FILL_TRAP | |
118 | #define H_T0_Window_Fill_5_Normal_Trap | |
119 | #define My_T0_Window_Fill_5_Normal_Trap MY_FILL_TRAP | |
120 | #define H_T0_Window_Fill_6_Normal_Trap | |
121 | #define My_T0_Window_Fill_6_Normal_Trap MY_FILL_TRAP | |
122 | #define H_T0_Window_Fill_7_Normal_Trap | |
123 | #define My_T0_Window_Fill_7_Normal_Trap MY_FILL_TRAP | |
124 | ||
125 | #define H_T0_Window_Fill_0_Other_Trap | |
126 | #define My_T0_Window_Fill_0_Other_Trap MY_FILL_TRAP | |
127 | #define H_T0_Window_Fill_1_Other_Trap | |
128 | #define My_T0_Window_Fill_1_Other_Trap MY_FILL_TRAP | |
129 | #define H_T0_Window_Fill_2_Other_Trap | |
130 | #define My_T0_Window_Fill_2_Other_Trap MY_FILL_TRAP | |
131 | #define H_T0_Window_Fill_3_Other_Trap | |
132 | #define My_T0_Window_Fill_3_Other_Trap MY_FILL_TRAP | |
133 | #define H_T0_Window_Fill_4_Other_Trap | |
134 | #define My_T0_Window_Fill_4_Other_Trap MY_FILL_TRAP | |
135 | #define H_T0_Window_Fill_5_Other_Trap | |
136 | #define My_T0_Window_Fill_5_Other_Trap MY_FILL_TRAP | |
137 | #define H_T0_Window_Fill_6_Other_Trap | |
138 | #define My_T0_Window_Fill_6_Other_Trap MY_FILL_TRAP | |
139 | #define H_T0_Window_Fill_7_Other_Trap | |
140 | #define My_T0_Window_Fill_7_Other_Trap MY_FILL_TRAP | |
141 | ||
142 | ||
143 | #define H_T0_Clean_Window | |
144 | #define My_T0_Clean_Window MY_GENERIC_TRAP | |
145 | ||
146 | ||
147 | ||
148 | #include "hboot.s" | |
149 | ||
150 | /************************************************************************ | |
151 | Test case code start | |
152 | ************************************************************************/ | |
153 | ||
154 | .text | |
155 | .global main | |
156 | ||
157 | main: | |
158 | ||
159 | ta T_CHANGE_PRIV ! run in priv mode | |
160 | nop | |
161 | ||
162 | ! rdth_id ! get thread ID in %o1 | |
163 | ! umul %o1, 256, %l7 | |
164 | ! setx user_data_start, %g1, %g3 | |
165 | ! add %l7, %g3, %l7 | |
166 | ||
167 | single_thread: | |
168 | ba thread_0 | |
169 | ||
170 | ! thread_dispatch: | |
171 | ! cmp %o1, 0x0 | |
172 | ! be thread_0 | |
173 | ! nop | |
174 | ! cmp %o1, 0x1 | |
175 | ! be thread_1 | |
176 | ! nop | |
177 | ! cmp %o1, 0x2 | |
178 | ! be thread_2 | |
179 | ! nop | |
180 | ! cmp %o1, 0x3 | |
181 | ! be thread_3 | |
182 | ! nop | |
183 | ! cmp %o1, 0x4 | |
184 | ! be thread_4 | |
185 | ! nop | |
186 | ! cmp %o1, 0x5 | |
187 | ! be thread_5 | |
188 | ! nop | |
189 | ! cmp %o1, 0x6 | |
190 | ! be thread_6 | |
191 | ! nop | |
192 | ! cmp %o1, 0x7 | |
193 | ! be thread_7 | |
194 | ||
195 | ! ! ! nop | |
196 | ! ! ! EXIT_GOOD | |
197 | ||
198 | ||
199 | ||
200 | ! | |
201 | ! Thread 0 Start | |
202 | ! | |
203 | thread_0: | |
204 | ||
205 | ||
206 | theRealStuff: | |
207 | !# Execute Main Diag .. | |
208 | ||
209 | wrpr %g0, %cwp ! default window is zero | |
210 | ||
211 | ! table address | |
212 | setx HV_TRAP_BASE_PA, %g1, %i7 | |
213 | srlx %i7, 13, %i4 ! HV_TRAP_BASE | |
214 | setx TRAP_BASE_VA, %g1, %i7 | |
215 | srlx %i7, 13, %i5 ! TRAP_BASE | |
216 | ||
217 | ! trap count | |
218 | setx 0, %g1, %o6 | |
219 | ||
220 | ! outer loop cnt | |
221 | setx 0, %g1, %i3 | |
222 | ||
223 | save: | |
224 | ||
225 | ||
226 | ! 2 loops | |
227 | loopNormAndOther: | |
228 | ||
229 | ! no clean traps now | |
230 | mov 7, %g1 | |
231 | wrpr %g1, %cleanwin | |
232 | ||
233 | !loop cnt | |
234 | setx 7, %g1, %i6 | |
235 | setx 8, %g1, %i7 | |
236 | ||
237 | loop8traps: | |
238 | !spill 8 times | |
239 | wrpr %i3, %otherwin | |
240 | sll %i6, 3, %g7 | |
241 | or %g7, %i6, %g7 | |
242 | wrpr %g7, %wstate ! what trap we will take | |
243 | wrpr %g0, %cansave ! can't save | |
244 | wrpr %i6, %cwp | |
245 | save ! do it | |
246 | ||
247 | wrpr %g0, %cwp ! default window is zero | |
248 | ||
249 | cmp %l6, 1 ! trap level | |
250 | bne test_failed | |
251 | mov 0, %l6 | |
252 | ||
253 | !%o0 = itteration X 4 + 80 + 20 if other = TrapType | |
254 | mulx %i6, 0x04, %o0 | |
255 | add %o0, 0x80, %o0 | |
256 | mulx %i3, 0x20, %o1 | |
257 | add %o0, %o1, %o0 | |
258 | ||
259 | cmp %l5, %o0 !type check | |
260 | bne test_failed | |
261 | mov 0, %l5 | |
262 | srlx %l4, 13, %g3 ! table address | |
263 | cmp %g3, %i5 ! correct table used by tlu? | |
264 | bne test_failed | |
265 | mov 0, %l4 | |
266 | ||
267 | dec %i6 | |
268 | subcc %i7, 1, %i7 | |
269 | bne loop8traps | |
270 | nop | |
271 | ||
272 | subcc %i3, 1, %g1 | |
273 | bz clean_win | |
274 | nop | |
275 | inc %i3 | |
276 | ba loopNormAndOther | |
277 | nop | |
278 | ||
279 | clean_win: | |
280 | ||
281 | ! If CANSAVE 0, the SAVE instruction checks whether the new window | |
282 | ! needs to be cleaned. It causes a clean_windowtrap if the number of | |
283 | ! unused clean windows is zero, that is, (CLEANWIN - CANRESTORE) | |
284 | ! = 0. The clean_window trap handler is invoked with the CWP set to | |
285 | ! point to the window to be cleaned (that is, old CWP + 1). | |
286 | ||
287 | wrpr %g0, %cwp ! default window is zero | |
288 | ||
289 | mov 7, %g1 | |
290 | wrpr %g0, %cleanwin | |
291 | wrpr %g0, %canrestore | |
292 | ! wrpr %g0, %wstate ! what trap we will take | |
293 | wrpr %g1, %cansave ! can save | |
294 | wrpr %g0, %cwp | |
295 | save %g1, %g1, %g1! do it | |
296 | ||
297 | wrpr %g0, %cwp ! default window is zero | |
298 | ||
299 | cmp %l6, 1 !level check | |
300 | bne test_failed | |
301 | mov 0, %l6 | |
302 | cmp %l5, 0x24 !type check | |
303 | bne test_failed | |
304 | mov 0, %l5 | |
305 | srlx %l4, 13, %g3 ! table address | |
306 | cmp %g3, %i5 ! correct table used by tlu? | |
307 | bne test_failed | |
308 | mov 0, %l4 | |
309 | ||
310 | ! sas OK to here | |
311 | ||
312 | restore: | |
313 | ||
314 | wrpr %g0, %cwp ! default window is zero | |
315 | ||
316 | ! outer loop cnt | |
317 | setx 0, %g1, %i3 | |
318 | ||
319 | ! 2 loops | |
320 | loopNormAndOther_r: | |
321 | ||
322 | ! no clean traps | |
323 | mov 7, %g1 | |
324 | wrpr %g1, %cleanwin | |
325 | ||
326 | !loop cnt | |
327 | setx 7, %g1, %i6 | |
328 | setx 8, %g1, %i7 | |
329 | ||
330 | loop8traps_r: | |
331 | !fill 8 times | |
332 | wrpr %i3, %otherwin | |
333 | sll %i6, 3, %g7 | |
334 | or %g7, %i6, %g7 | |
335 | wrpr %g7, %wstate ! what trap we will take | |
336 | wrpr %g0, %canrestore ! can't restore | |
337 | wrpr %i6, %cwp | |
338 | restore ! do it | |
339 | ||
340 | wrpr %g0, %cwp ! default window is zero | |
341 | ||
342 | cmp %l6, 1 ! trap level | |
343 | bne test_failed | |
344 | mov 0, %l6 | |
345 | ||
346 | !%o0 = itteration X 4 + C0 + 20 if other = TrapType | |
347 | mulx %i6, 0x04, %o0 | |
348 | add %o0, 0xc0, %o0 | |
349 | mulx %i3, 0x20, %o1 | |
350 | add %o0, %o1, %o0 | |
351 | ||
352 | cmp %l5, %o0 !type check | |
353 | bne test_failed | |
354 | mov 0, %l5 | |
355 | srlx %l4, 13, %g3 ! table address | |
356 | cmp %g3, %i5 ! correct table used by tlu? | |
357 | bne test_failed | |
358 | mov 0, %l4 | |
359 | ||
360 | dec %i6 | |
361 | subcc %i7, 1, %i7 | |
362 | bne loop8traps_r | |
363 | nop | |
364 | ||
365 | subcc %i3, 1, %g1 | |
366 | bz test_passed | |
367 | nop | |
368 | inc %i3 | |
369 | ba loopNormAndOther_r | |
370 | nop | |
371 | ||
372 | ||
373 | ||
374 | ! check final trap count | |
375 | cmp %o6, %l3 | |
376 | bne test_failed | |
377 | ||
378 | test_passed: | |
379 | EXIT_GOOD | |
380 | ||
381 | test_failed: | |
382 | EXIT_BAD | |
383 | ||
384 | ||
385 | /************************************************************************ | |
386 | Test case data start | |
387 | ************************************************************************/ | |
388 | .data | |
389 | user_data_start: | |
390 | .xword 0xDEADBEEFDEADBEEF | |
391 | .xword 0x1111111122222222 | |
392 | .xword 0x3333333344444444 | |
393 | .xword 0x55555555 | |
394 | .end | |
395 | ||
396 | ||
397 |