Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: interrupt_QUEUE_CPU_MONDO_trap.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_T0_Cpu_Mondo_Trap_0x7c | |
42 | #define My_T0_Cpu_Mondo_Trap_0x7c \ | |
43 | call my_Cpu_Mondo_trap; \ | |
44 | nop; \ | |
45 | done; \ | |
46 | nop; | |
47 | ||
48 | #define H_HT0_DAE_invalid_asi_0x14 my_H_T0_DAE_invalid_asi_0x14 | |
49 | ||
50 | ||
51 | #include "hboot.s" | |
52 | #include "asi_s.h" | |
53 | ||
54 | /************************************************************************ | |
55 | Test case code start | |
56 | ************************************************************************/ | |
57 | ||
58 | .text | |
59 | .global main | |
60 | ||
61 | main: | |
62 | ||
63 | ! Switch to Hypervisor mode. | |
64 | go_hyper1: | |
65 | ta T_CHANGE_HPRIV | |
66 | nop | |
67 | ||
68 | ! Enable interrupts in the Pstate reg. | |
69 | rdpr %pstate, %g5 | |
70 | wrpr %g5, 1, %pstate | |
71 | ||
72 | ! Initialize the queue head and tail pointers to same location. | |
73 | init_cpu_queue: | |
74 | set ASI_QUEUE, %g1 | |
75 | wr %g1, %g0, %asi | |
76 | setx queue_start, %g1, %g2 | |
77 | stxa %g2, [%g0 + ASI_CPU_MONDO_QUEUE_HEAD]%asi | |
78 | stxa %g2, [%g0 + ASI_CPU_MONDO_QUEUE_TAIL]%asi | |
79 | ||
80 | ! Switch to supervisor mode. | |
81 | go_super: | |
82 | ta T_CHANGE_PRIV | |
83 | nop | |
84 | ta T_CHANGE_NONHPRIV | |
85 | nop | |
86 | ||
87 | ! Change the queue head != queue tail to generate trap | |
88 | gen_mondo_trap: | |
89 | setx queue_end, %g1, %g2 | |
90 | stxa %g2, [%g0 + ASI_CPU_MONDO_QUEUE_HEAD]%asi | |
91 | membar #Sync | |
92 | ||
93 | ! Wait for mondo trap | |
94 | mondo_wait: | |
95 | setx 400, %g1, %g7 ! g7 = timeout count | |
96 | setx cpu_mondo_trap_count, %g1, %g3 | |
97 | mondo_loop: | |
98 | brz %g7, test_failed | |
99 | nop | |
100 | ld [%g3], %g4 | |
101 | brz %g4, mondo_loop | |
102 | sub %g7, 1, %g7 | |
103 | ||
104 | ! Change queue head == queue tail, no trap expected | |
105 | no_mondo_trap: | |
106 | setx queue_start, %g1, %g2 | |
107 | stxa %g2, [%g0 + ASI_CPU_MONDO_QUEUE_HEAD]%asi | |
108 | membar #Sync | |
109 | ||
110 | ! Try to write queue tail register, expect a | |
111 | ! DAE_invalid trap | |
112 | dae_inv_trap: | |
113 | setx queue_end, %g1, %g2 | |
114 | stxa %g2, [%g0 + ASI_CPU_MONDO_QUEUE_TAIL]%asi | |
115 | membar #Sync | |
116 | ||
117 | ! Switch to Hypervisor mode. | |
118 | go_hyper2: | |
119 | ta T_CHANGE_HPRIV | |
120 | nop | |
121 | ||
122 | ! Change queue tail != queue head, no trap expected. | |
123 | hyper_no_trap: | |
124 | setx queue_end, %g1, %g2 | |
125 | stxa %g2, [%g0 + ASI_CPU_MONDO_QUEUE_TAIL]%asi | |
126 | membar #Sync | |
127 | ||
128 | ! Wait a bit | |
129 | wait: | |
130 | setx 100, %g1, %g7 ! Loop count | |
131 | loop: | |
132 | brz %g7, go_super2 | |
133 | sub %g7, 1, %g7 | |
134 | ||
135 | ! Go back to privileged mode, trap should occur now. | |
136 | go_super2: | |
137 | ta T_CHANGE_NONHPRIV | |
138 | nop | |
139 | ||
140 | ! Wait a bit more | |
141 | wait_more: | |
142 | setx 400, %g1, %g7 ! Loop count | |
143 | loop_more: | |
144 | brz %g7, check_trap_counts | |
145 | sub %g7, 1, %g7 | |
146 | ||
147 | ! Check for expected number of traps. | |
148 | ||
149 | check_trap_counts: | |
150 | setx cpu_mondo_trap_count, %g1, %g3 | |
151 | ld [%g3], %g4 | |
152 | cmp %g4, 2 | |
153 | bne test_failed | |
154 | nop | |
155 | ||
156 | ta T_CHANGE_HPRIV | |
157 | nop | |
158 | ||
159 | setx dae_invalid_trap_count, %g1, %g3 | |
160 | ld [%g3], %g4 | |
161 | cmp %g4, 1 | |
162 | bne test_failed | |
163 | nop | |
164 | ||
165 | ! Done | |
166 | ||
167 | ba test_passed | |
168 | nop | |
169 | ||
170 | ||
171 | test_passed: | |
172 | EXIT_GOOD | |
173 | ||
174 | test_failed: | |
175 | EXIT_BAD | |
176 | ||
177 | ||
178 | /********************************************************************** | |
179 | Trap handlers. | |
180 | **********************************************************************/ | |
181 | ||
182 | .global my_Cpu_Mondo_trap | |
183 | .global my_H_T0_DAE_invalid_asi_0x14 | |
184 | ||
185 | my_Cpu_Mondo_trap: | |
186 | ! Increment the count | |
187 | ||
188 | setx cpu_mondo_trap_count, %g6, %g7 | |
189 | ld [%g7], %g5 | |
190 | add %g5, 1, %g5 | |
191 | st %g5, [%g7] | |
192 | membar #Sync | |
193 | ||
194 | ! Clear the interrupt | |
195 | ||
196 | ldxa [%g0 + ASI_CPU_MONDO_QUEUE_TAIL]%asi, %g2 | |
197 | stxa %g2, [%g0 + ASI_CPU_MONDO_QUEUE_HEAD]%asi | |
198 | membar #Sync | |
199 | ||
200 | jmpl %o7+0x8, %g0 | |
201 | nop | |
202 | ||
203 | ||
204 | my_H_T0_DAE_invalid_asi_0x14: | |
205 | ! Increment the count | |
206 | ||
207 | setx dae_invalid_trap_count, %g6, %g7 | |
208 | ld [%g7], %g5 | |
209 | add %g5, 1, %g5 | |
210 | st %g5, [%g7] | |
211 | membar #Sync | |
212 | ||
213 | done | |
214 | nop | |
215 | ||
216 | ||
217 | /************************************************************************ | |
218 | Test case data start | |
219 | ************************************************************************/ | |
220 | .data | |
221 | user_data_start: | |
222 | cpu_mondo_trap_count: | |
223 | .word 0x0 | |
224 | .word 0x0 | |
225 | dae_invalid_trap_count: | |
226 | .word 0x0 | |
227 | .word 0x0 | |
228 | queue_start: | |
229 | .word 0x0 | |
230 | .word 0x0 | |
231 | .word 0x0 | |
232 | .word 0x0 | |
233 | .word 0x0 | |
234 | .word 0x0 | |
235 | .word 0x0 | |
236 | .word 0x0 | |
237 | .word 0x0 | |
238 | .word 0x0 | |
239 | .word 0x0 | |
240 | .word 0x0 | |
241 | .word 0x0 | |
242 | .word 0x0 | |
243 | .word 0x0 | |
244 | .word 0x0 | |
245 | queue_end: | |
246 | .word 0x0 | |
247 | .word 0x0 | |
248 | .word 0x0 | |
249 | .word 0x0 | |
250 | .end | |
251 | ||
252 | ||
253 |