Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / arch / prm / interrupt / interrupt_SWVR_INTR_REC_mode.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: interrupt_SWVR_INTR_REC_mode.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
41#define H_HT0_Interrupt_0x60
42#define My_HT0_Interrupt_0x60 \
43 call my_interrupt_code; \
44 nop; \
45 retry; \
46 nop;
47
48#define H_HT0_Privileged_Action_0x37
49#define My_HT0_Privileged_Action_0x37 \
50 call my_priv_action_trap_code; \
51 nop; \
52 done; \
53 nop;
54
55#include "hboot.s"
56
57#include "ncu_defines.h"
58
59/************************************************************************
60 Test case code start
61 ************************************************************************/
62
63.text
64.global main
65
66main:
67 ta T_CHANGE_HPRIV
68 nop
69
70 ! Determine thread running on
71
72 ta T_RD_THID
73 cmp %o1, 0
74 be main_t0 ! Branch if thread 0
75 nop
76
77 ba main_t1 ! Branch if not thread 0
78 nop
79
80/************************************************************************
81 Thread 0 code
82 ************************************************************************/
83
84
85 ! Wait for thread one to be ready.
86main_t0:
87 setx user_data_start, %g1, %g2
88#ifdef DTM_ENABLED
89 setx 800, %g1, %g3 ! DTM wait count
90#else
91 setx 200, %g1, %g3 ! wait count
92#endif
93
94t0_wait1_loop_top:
95 lda [%g2]ASI_AS_IF_USER_PRIMARY, %g7
96 cmp %g7, 1
97 be t0_wait1_loop_exit
98 nop
99
100 cmp %g3, 0
101 be test_failed ! T1 never started
102 dec %g3
103 ba t0_wait1_loop_top
104 nop
105
106 ! Reset the flag
107t0_wait1_loop_exit:
108 sta %g0, [%g2]ASI_AS_IF_USER_PRIMARY
109
110 ! Send the first interrupt to T1
111t0_send_first_intr:
112 wr %g0, INT_VEC_DIS, %asi
113 set 0x100, %g3
114 stxa %g3, [%g0]%asi
115 membar #Sync
116
117 ! Wait for T1 to be ready
118
119 setx user_data_start, %g1, %g2
120#ifdef DTM_ENABLED
121 setx 800, %g1, %g3 ! DTM wait count
122#else
123 setx 200, %g1, %g3 ! wait count
124#endif
125
126t0_wait2_loop_top:
127 lda [%g2]ASI_AS_IF_USER_PRIMARY, %g7
128 cmp %g7, 1
129 be t0_wait2_loop_exit
130 nop
131
132 cmp %g3, 0
133 be test_failed ! T1 never started
134 dec %g3
135 ba t0_wait2_loop_top
136 nop
137
138 ! Reset the flag
139t0_wait2_loop_exit:
140 sta %g0, [%g2]ASI_AS_IF_USER_PRIMARY
141
142 ! Send the second interrupt to T1
143t0_send_sec_intr:
144 wr %g0, INT_VEC_DIS, %asi
145 set 0x100, %g3
146 stxa %g3, [%g0]%asi
147 membar #Sync
148t0_done:
149 ba test_passed
150 nop
151
152
153/************************************************************************
154 Thread 1 code
155 ************************************************************************/
156
157 ! Switch to user mode
158main_t1:
159 ta T_CHANGE_NONHPRIV
160 ta T_CHANGE_NONPRIV
161
162 ! Tell T0 we're ready
163t1_ready1:
164 setx user_data_start, %g1, %g2
165 set 1, %g3
166 st %g3, [%g2]
167
168 ! Wait for first interrupt
169t1_intr1:
170 add %g2, 16, %g2
171#ifdef DTM_ENABLED
172 setx 800, %g1, %g4 ! DTM wait count
173#else
174 setx 200, %g1, %g4 ! wait count
175#endif
176
177t1_intr1_loop_top:
178 ld [%g2], %g7
179 cmp %g7, 1
180 be t1_intr1_loop_exit
181 nop
182
183 cmp %g4, 0
184 bge t1_intr1_loop_top
185 dec %g4
186 ba test_failed ! interrupt did not occur
187 nop
188
189 ! Reset flag
190t1_intr1_loop_exit:
191 setx user_data_start, %g1, %g2
192 st %g0, [%g2]
193
194 ! Try to read ASI_INTR_RECEIVE reg. should cause priviliged action trap
195t1_read1:
196 ldxa [%g0]ASI_INTR_RECEIVE, %g6
197 nop
198
199 ! Go to supervisor mode for next interrupt
200t1_supr:
201 ta T_CHANGE_PRIV
202 ta T_CHANGE_NONHPRIV
203
204 ! Signal T0 we're ready for next interrupt
205
206 setx user_data_start, %g1, %g2
207 set 1, %g1
208 st %g1, [%g2]
209
210 ! Wait for second interrupt
211t1_intr2:
212 add %g2, 16, %g2
213#ifdef DTM_ENABLED
214 setx 800, %g1, %g4 ! DTM wait count
215#else
216 setx 200, %g1, %g4 ! wait count
217#endif
218
219t1_intr2_loop_top:
220 ld [%g2], %g7
221 cmp %g7, 2
222 be t1_intr2_loop_exit
223 nop
224
225 cmp %g4, 0
226 bge t1_intr2_loop_top
227 dec %g4
228 ba test_failed ! interrupt did not occur
229 nop
230
231 ! Reset flag
232t1_intr2_loop_exit:
233 setx user_data_start, %g1, %g2
234 st %g0, [%g2]
235
236 ! Try to read ASI_INTR_RECEIVE reg. should cause DAE_invalid_ASI trap
237t1_read2:
238 ldxa [%g0]ASI_INTR_RECEIVE, %g6
239 nop
240
241 ! Have the two traps occured?
242t1_trap_check:
243 setx t1_trap_flag, %g1, %g2
244 ld [%g2], %g5
245 cmp %g5, 2
246 bne test_failed
247 nop
248
249 ! Signal T0 we're done.
250t1_done:
251 setx user_data_start, %g1, %g2
252 set 1, %g3
253 st %g3, [%g2]
254
255 ba test_passed
256 nop
257
258
259/**********************************************************************
260 Trap handlers:
261**********************************************************************/
262
263.global my_interrupt_code
264.global my_priv_action_trap_code
265.global my_H_T0_Reserved_0x14
266
267
268my_interrupt_code:
269 ! Clear the interrupt
270
271 ldxa [%g0]ASI_SWVR_INTR_R, %g0
272 membar #Sync
273
274 ! Indicate interrupt occured
275 setx user_data_start+16, %l1, %l2
276 lda [%l2]ASI_AS_IF_USER_PRIMARY, %l3
277 inc %l3
278 sta %l3, [%l2]ASI_AS_IF_USER_PRIMARY
279
280 jmpl %o7+0x8, %g0
281 nop
282
283
284
285
286my_priv_action_trap_code:
287
288 setx t1_trap_flag, %l1, %l2
289 lda [%l2]ASI_AS_IF_USER_PRIMARY, %l3
290 add %l3, 1, %l3
291 sta %l3, [%l2]ASI_AS_IF_USER_PRIMARY
292
293 jmpl %o7+0x8, %g0
294 nop
295
296
297
298
299test_passed:
300 EXIT_GOOD
301
302test_failed:
303 EXIT_BAD
304
305
306/************************************************************************
307 Test case data start
308 ************************************************************************/
309.data
310user_data_start:
311 .word 0x0
312 .word 0x0
313 .word 0x0
314 .word 0x0
315 .word 0x0
316 .word 0x0
317 .word 0x0
318 .word 0x0
319t1_trap_flag:
320 .word 0x0
321 .word 0x0
322.end