Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / arch / prm / tso / tso_directed / tso_n2_mutex1.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: tso_n2_mutex1.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 spinlock_addr_reg %o0
39#define data_base_reg %o1
40#define to_reg %o2
41#define my_id_reg %o3
42#define test_reg %o4
43#define global_cnt_reg %o5
44
45#define TIMEOUT 0x1000
46#define ITERATIONS 0x2
47
48#include "hboot.s"
49
50.global main
51main:
52
53 setx spinlock_address, %l0, spinlock_addr_reg ! spinlock address
54 set TIMEOUT, to_reg ! set timeout count
55 set ITERATIONS, global_cnt_reg !
56
57 or spinlock_addr_reg, %g0, my_id_reg
58
59th_fork(th_main,%l0)
60
61th_main_0:
62 add my_id_reg, 0x20, my_id_reg ! my ID address
63 stb %g0, [my_id_reg] ! reset the value
64 ba getlock
65 nop
66
67th_main_1:
68 add my_id_reg, 0x24, my_id_reg
69 stb %g0, [my_id_reg]
70 ba getlock
71 nop
72
73
74th_main_2:
75 add my_id_reg, 0x28, my_id_reg
76 stb %g0, [my_id_reg]
77 ba getlock
78 nop
79
80th_main_3:
81 add my_id_reg, 0x2c, my_id_reg
82 stb %g0, [my_id_reg]
83 ba getlock
84 nop
85
86th_main_4:
87 add my_id_reg, 0x30, my_id_reg
88 stb %g0, [my_id_reg]
89 ba getlock
90 nop
91
92th_main_5:
93 add my_id_reg, 0x34, my_id_reg
94 stb %g0, [my_id_reg]
95 ba getlock
96 nop
97
98th_main_6:
99 add my_id_reg, 0x38, my_id_reg
100 stb %g0, [my_id_reg]
101 ba getlock
102 nop
103
104th_main_7:
105 add my_id_reg, 0x3c, my_id_reg
106 stb %g0, [my_id_reg]
107 ba getlock
108 nop
109
110th_main_8:
111 add my_id_reg, 0x00, my_id_reg ! my ID address
112 stb %g0, [my_id_reg] ! reset the value
113 ba getlock
114 nop
115
116th_main_9:
117 add my_id_reg, 0x04, my_id_reg
118 stb %g0, [my_id_reg]
119 ba getlock
120 nop
121
122
123th_main_10:
124 add my_id_reg, 0x08, my_id_reg
125 stb %g0, [my_id_reg]
126 ba getlock
127 nop
128
129th_main_11:
130 add my_id_reg, 0x0c, my_id_reg
131 stb %g0, [my_id_reg]
132 ba getlock
133 nop
134
135th_main_12:
136 add my_id_reg, 0x10, my_id_reg
137 stb %g0, [my_id_reg]
138 ba getlock
139 nop
140
141th_main_13:
142 add my_id_reg, 0x14, my_id_reg
143 stb %g0, [my_id_reg]
144 ba getlock
145 nop
146
147th_main_14:
148 add my_id_reg, 0x18, my_id_reg
149 stb %g0, [my_id_reg]
150 ba getlock
151 nop
152
153th_main_15:
154 add my_id_reg, 0x1c, my_id_reg
155 stb %g0, [my_id_reg]
156 ba getlock
157 nop
158
159getlock:
160 or %g0, my_id_reg, test_reg ! load the swap data register
161 swap [spinlock_addr_reg], test_reg ! try to acquire lock
162 tst test_reg ! did we get it?
163 be gotlock
164 nop
165
166dotimeout:
167 deccc to_reg ! dec timeout count
168 bne getlock ! branch if no timeout
169 nop
170 ba,a bad_end
171 nop
172
173gotlock:
174 set TIMEOUT, to_reg ! set timeout count again
175 setx protected_area, %l0, data_base_reg
176
177 set 100, %l0
178 add my_id_reg, data_base_reg, %i1
179loop1:
180 st %i1, [data_base_reg] ! st my ID in the protected area
181 add data_base_reg, 4, data_base_reg ! increment the address
182 add %i1, 1, %i1
183 deccc %l0
184 bne loop1 ! repeat
185 nop
186
187 set 100, %l0
188loop2:
189 sub data_base_reg, 4, data_base_reg
190 sub %i1, 1, %i1
191 ld [data_base_reg], %l1 ! read the data area
192 subcc %l1, %i1, %l1 ! should be same is i1
193 bne bad_end
194 nop
195 deccc %l0 ! repeat
196 bne loop2
197 nop
198
199clearlock:
200 st %g0, [spinlock_addr_reg] ! unlocked
201
202check_done:
203 deccc global_cnt_reg
204 be good_end
205 nop
206 ba getlock
207 nop
208
209good_end:
210 ta T_GOOD_TRAP
211bad_end:
212 ta T_BAD_TRAP
213
214!==========================
215
216
217SECTION .MY_DATA0 TEXT_VA=0xf0100000, DATA_VA=0xd0100000
218attr_data {
219 Name = .MY_DATA0,
220 VA= 0x0d0100000
221 RA= 0x1d0100000
222 PA= ra2pa(0x1d0100000,0),
223part_0_ctx_nonzero_tsb_config_0,
224 TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0,
225 TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0,
226 TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1
227 }
228
229attr_text {
230 Name = .MY_DATA0,
231 VA= 0x0f0100000
232 RA= 0x1f0100000
233 PA= ra2pa(0x1f0100000,0),
234part_0_ctx_nonzero_tsb_config_0,
235 TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0,
236 TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0,
237 TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1
238 }
239
240 .data
241
242.global spinlock_address
243spinlock_address:
244 .word 0x0
245 .skip 0x1000
246 .word 0x0
247
248SECTION .MY_DATA1 TEXT_VA=0xf1110000, DATA_VA=0xd1110000
249attr_data {
250 Name = .MY_DATA1,
251 VA= 0x0d1110000,
252 RA= 0x1d1110000,
253 PA= ra2pa(0x1d1110000,0),
254part_0_ctx_nonzero_tsb_config_0,
255 TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0,
256 TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0,
257 TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1
258 }
259
260attr_text {
261 Name = .MY_DATA1,
262 VA= 0x0f1110000,
263 RA= 0x1f1110000,
264 PA= ra2pa(0x1f1110000,0),
265part_0_ctx_nonzero_tsb_config_0,
266 TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0,
267 TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0,
268 TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1
269 }
270
271 .data
272.global protected_area
273protected_area:
274 .word 0xbeef
275 .skip 0x1000
276 .word 0xbeef
277
278! now do some post-procesing
279.end
280
281__PERL__
282
283use strict;
284
285system("vlog > vlog.log");
286open (F, "critsec.p -startcs=20000134 -endcs=20000198 |") or die "cannot open critsec.p...\n";
287
288while(<F>){
289 print;
290 if(/Everything OK/){
291 exit 0;
292 }
293}
294
295print "ERROR, something went wrong in perl postprocessing\n";
296exit 1;