Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / arch / prm / cmp / ncu_all_core_wakeup.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: ncu_all_core_wakeup.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#include "hboot.s"
42#include "asi_s.h"
43
44.text
45.global main
46
47
48main:
49 ta T_CHANGE_HPRIV
50
51get_th_id_o0:
52 ta T_RD_THID
53 wr %g0,ASI_CMP_CORE,%asi
54
55 cmp %o1,0x0
56 be main_t0
57 nop
58 cmp %o1,56
59 bge t_last_core
60 nop
61 ba t_others
62 nop
63
64main_t0:
65
66 setx 0xffffff0000,%g7,%g1
67 lduw [%g1],%g2
68 cmp %g2,0x2
69 be test_2
70 nop
71 cmp %g2,0x1
72 be test_1
73 nop
74
75test_0:
76!! Read the core available register
77 ldxa [ASI_CMP_CORE_AVAIL]%asi, %g1
78 xnor %g0,%g0,%g6
79 cmp %g1,%g6
80 bne %xcc,test_fail
81 nop
82
83!! Enable/Disable other cores
84 setx 0x53ff017fff00ffff,%g7,%g1
85 stxa %g1,[ASI_CMP_CORE_ENABLE]%asi
86 ldxa [ASI_CMP_CORE_ENABLE]%asi, %g2
87 setx 0x00ff0000ff00ffff,%g7,%g3
88 cmp %g2,%g3
89 bne %xcc,test_fail
90 nop
91
92 setx 0x23ecffffff234400,%g7,%g1
93 stxa %g1,[ASI_CMP_CORE_ENABLE]%asi
94 ldxa [ASI_CMP_CORE_ENABLE]%asi, %g2
95 setx 0x0000ffffff000000,%g7,%g3
96 cmp %g2,%g3
97 bne %xcc,test_fail
98 nop
99
100 setx 0x0102040810204080,%g7,%g1
101 stxa %g1,[ASI_CMP_CORE_ENABLE]%asi
102 ldxa [ASI_CMP_CORE_ENABLE]%asi, %g2
103 setx 0x00000000000000ff,%g7,%g3
104 cmp %g2,%g3
105 bne %xcc,test_fail
106 nop
107
108 setx 0x0102040810204080,%g7,%g1
109 stxa %g1,[ASI_CMP_CORE_ENABLE]%asi
110 ldxa [ASI_CMP_CORE_ENABLE]%asi, %g2
111 cmp %g2,%g3
112 bne %xcc,test_fail
113 nop
114
115! Next test section
116 setx 0xffffff0000,%g7,%g1
117 set 0x1,%g3
118 stw %g3,[%g1]
119 lduw [%g1],%g3
120
121! Warm reset
122 setx 0x8900000808,%g7,%g2
123 stx %g3,[%g2]
124
125! Wait for warm reset
126halt:
127 ba halt
128 nop
129
130test_1:
131 ldxa [ASI_CMP_CORE_ENABLED]%asi, %g1
132 setx 0x00000000000000ff,%g7,%g6
133 cmp %g1,%g6
134 bne %xcc,test_fail
135 nop
136
137! Enable threads in all other cores
138 setx 0xffffffffffffff00,%g7,%g1
139 stxa %g1,[ASI_CMP_CORE_RUNNING_RW]%asi
140
141! Should not start the other core until a warm reset
142! Wait a while and see if any thread woke up
143
144 call sleep
145 nop
146 call sleep
147 nop
148
149 setx 0xffffff0100, %g7,%g4
150 lduw [%g4],%g2
151 cmp %g2,%g0
152 bne test_fail
153 nop
154
155! Enable some of the other cores
156 setx 0x19ff4071ffccffff,%g7,%g1
157 stxa %g1,[ASI_CMP_CORE_ENABLE]%asi
158
159! Next test section
160 setx 0xffffff0000,%g7,%g1
161 set 0x2,%g3
162 stw %g3,[%g1]
163 lduw [%g1],%g3
164
165! Warm reset
166 setx 0x8900000808,%g7,%g2
167 set 0x1,%g3
168 stx %g3,[%g2]
169
170! Wait for warm reset
171 ba halt
172 nop
173
174test_2:
175 ldxa [ASI_CMP_CORE_ENABLED]%asi, %g1
176 setx 0x00ff0000ff00ffff,%g7,%g6
177 cmp %g1,%g6
178 bne %xcc,test_fail
179 nop
180
181! Set flag in memory before waking up other threads
182 setx other_cores,%g7,%g1
183 set 0x1,%g2
184 stw %g2,[%g1]
185
186! Enable thread 0 in all other cores
187 setx 0xff01ffff01ff0101,%g7,%g1
188 stxa %g1,[ASI_CMP_CORE_RUNNING_RW]%asi
189
190! Just wait for a while first
191 call sleep
192 nop
193
194 setx 0xffffff0100,%g7,%g4
195wait_loop:
196 lduw [%g4],%g2
197 cmp %g2, 0x50
198 bne wait_loop
199 nop
200
201! Wait a little longer to see if someone else also woke up
202 call sleep
203 nop
204
205 lduw [%g4],%g2
206 cmp %g2, 0x50
207 bne test_fail
208 nop
209
210!! Disable yourself
211 setx 0xff00000000000000,%g7,%g1
212 stxa %g1,[ASI_CMP_CORE_ENABLE]%asi
213 setx 0x8900000808,%g7,%g2
214 set 0x01,%g3
215 stx %g3,[%g2]
216
217 ba halt
218 nop
219
220t_last_core:
221 wr %g0,ASI_CMP_CORE,%asi
222 ldxa [ASI_CMP_CORE_ENABLED]%asi, %g1
223 setx 0xff00000000000000,%g7,%g6
224 cmp %g1,%g6
225 bne %xcc,test_fail
226 nop
227
228! End of test
229 ba test_pass
230 nop
231
232t_others:
233! Get access to common cntrs
234 set 0x1,%g2
235 setx other_cores,%g7,%g1
236 set 0x0,%g3
237
238spin_lock_ot:
239 cas [%g1],%g2,%g3
240 cmp %g3,0x1
241 bne spin_lock_ot
242 nop
243
244 setx 0xffffff0100,%g7,%g4
245 lduw [%g4],%g2
246 add %g2,%o1,%g2
247 stw %g2,[%g4]
248 lduw [%g4],%g2
249
250! Release common cntrs
251 stw %g3,[%g1]
252 ba test_pass
253 nop
254
255/******************************************************
256 * Subroutine code
257 *******************************************************/
258
259sleep:
260 rd %tick,%l2
261 setx 0x0000000000000fff,%g7,%l1
262 add %l1,%l2,%l1
263sleep_loop:
264 rd %tick,%l2
265 cmp %l1,%l2
266 bpos %xcc,sleep_loop
267 nop
268 retl
269 nop
270
271/******************************************************
272 * Exit code
273 *******************************************************/
274
275test_pass:
276EXIT_GOOD
277
278test_fail:
279EXIT_BAD
280
281.data
282other_core_thrd_cnt:
283 .word 0x00000000
284other_cores:
285 .word 0x00000001
286.end
287