Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / arch / prm / cmp / cmp_park_all_w1c_w1s.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: cmp_park_all_w1c_w1s.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_HV_ALSO
39
40#include "hboot.s"
41#include "ncu_defines.h"
42
43
44
45/************************************************************************
46 Test case code start
47 ************************************************************************/
48.text
49.global main
50
51main:
52 ta T_CHANGE_HPRIV
53 nop
54
55 /* Get thread ID */
56
57 ta T_RD_THID
58
59 /* Wait until this thread's turn to run. */
60start_loop:
61 setx 0x1000, %g1, %g7
62 setx user_data_start, %g1, %g2
63
64start_loop_top:
65 cmp %g7, 0
66 beq local_test_failed ! timeout failure
67 dec %g7
68
69 ldx [%g2], %g6
70 cmp %o1, %g6
71 bne start_loop_top
72 nop
73
74 /* Attempt to park all threads. */
75diag_0:
76 setx ASI_CMP_CORE_RUNNING_W1C, %g1, %g2
77 setx ASI_CMP_CORE_RUNNING_STATUS, %g1, %g3
78#ifndef PORTABLE_CORE
79 orn %g0, %g0, %g1
80 stxa %g1, [%g2]ASI_CMP_CORE
81#else
82 /* Note parking only threads in 1 core */
83core_portable_0:
84 ldxa [%g0]ASI_INTR_ID, %o2 ! full thread ID
85 and %o2, 0x38, %o2 ! first thread in core
86 set 0xff, %g1
87 sllx %g1, %o2, %g1 ! all threads in this core
88 stxa %g1, [%g2]ASI_CMP_CORE
89#endif
90
91 /* Wait to give time for threads to park. */
92park_wait_loop:
93 set 0x40, %g7
94
95park_wait_loop_top:
96 cmp %g7, 0
97 bne park_wait_loop_top
98 dec %g7
99
100 /* Check CORE_RUNNING_RW and CORE_RUNNING_STATUS registers
101 indicate that only this thread is running. */
102diag_1:
103 ldxa [%g0]ASI_INTR_ID, %o2 ! full thread ID
104 set 1, %g4
105 sllx %g4, %o2, %g4
106
107 setx ASI_CMP_CORE_RUNNING_RW, %g1, %g2
108 ldxa [%g2]ASI_CMP_CORE, %g5 ! CORE_RUNNING_RW
109 ldxa [%g3]ASI_CMP_CORE, %g6 ! CORE_RUNNING_STATUS
110 cmp %g5, %g6
111 bne local_test_failed ! should be same by now
112 cmp %g6, %g4
113 bne local_test_failed ! should only be this thread unparked
114 nop
115
116 /* Unpark all threads. */
117diag_2:
118 setx ASI_CMP_CORE_RUNNING_W1S, %g1, %g2
119#ifndef PORTABLE_CORE
120 orn %g0, %g0, %g4
121 stxa %g4, [%g2]ASI_CMP_CORE ! CORE_RUNNING_W1S
122#else
123 /* Note unparking only threads in 1 core */
124core_portable_1:
125 ldxa [%g0]ASI_INTR_ID, %o2 ! full thread ID
126 and %o2, 0x38, %o2 ! first thread in core
127 set 0xff, %g4
128 sllx %g4, %o2, %g4 ! all threads in this core
129 stxa %g4, [%g2]ASI_CMP_CORE
130#endif
131
132 /* Wait to give time for threads to unpark. */
133unpark_wait_loop:
134 set 0x40, %g7
135
136unpark_wait_loop_top:
137 cmp %g7, 0
138 bne unpark_wait_loop_top
139 dec %g7
140
141 /* Check CORE_RUNNING_RW and CORE_RUNNING_STATUS registers
142 indicated that all threads are running. */
143diag_3:
144 setx ASI_CMP_CORE_RUNNING_RW, %g1, %g2
145 ldxa [%g2]ASI_CMP_CORE, %g5 ! CORE_RUNNING_RW
146 ldxa [%g3]ASI_CMP_CORE, %g6 ! CORE_RUNNING_STATUS
147 cmp %g5, %g6
148 bne local_test_failed ! should be same by now
149#ifndef PORTABLE_CORE
150 orn %g0, %g0, %g4
151#else
152 ldxa [%g0]ASI_INTR_ID, %o2 ! full thread ID
153 and %o2, 0x38, %o2 ! first thread in core
154 set 0xff, %g4
155 sllx %g4, %o2, %g4 ! all threads in this core
156#endif
157 cmp %g6, %g4
158 bne local_test_failed ! all threads should be running now
159 nop
160
161 /* Signal the next thread to do its testing. */
162diag_4:
163 setx user_data_start, %g1, %g5
164 ldx [%g5], %g6
165 inc %g6
166 stx %g6, [%g5]
167
168 /* Wait until all threads are done. */
169end_wait_loop:
170 setx 0x1000, %g1, %g7
171
172end_wait_loop_top:
173 cmp %g7, 0
174 beq local_test_failed ! fail on a timeout
175 dec %g7
176
177 ldx [%g5], %g4
178#ifndef PORTABLE_CORE
179 cmp %g4, 64 ! 64 = all threads done
180#else
181 cmp %g4, 8 ! 8 = all threads in core done
182#endif
183 bne end_wait_loop_top
184 nop
185
186 /* Done */
187
188 ba test_passed
189 nop
190
191
192
193test_passed:
194 EXIT_GOOD
195
196local_test_failed:
197 EXIT_BAD
198
199
200
201/************************************************************************
202 Test case data start
203 ************************************************************************/
204
205.align 1024
206.data
207user_data_start:
208 .word 0x0
209 .word 0x0
210 .word 0x0
211 .word 0x0