Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / arch / prm / tso / tso_directed / tso_n1_dekker1_pio.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: tso_n1_dekker1_pio.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#define global_cnt_reg %o0
40#define data_base_reg %o1
41#define addrA_reg %o2
42#define addrB_reg %o3
43#define to_reg %o4
44#define my_id_reg %o5
45#define test_reg %o6
46
47#define backoff_cnt %i4
48#define backoff_hlp1 %i5
49
50#define TIMEOUT 0x100
51#define ITERATIONS 0x2
52
53#include "hboot.s"
54
55.global main
56main:
57ta T_CHANGE_HPRIV
58nop
59 setx addrA, %l0, addrA_reg !
60 setx addrB, %l0, addrB_reg !
61 set TIMEOUT, to_reg ! set timeout count
62 inc to_reg
63 mov to_reg, backoff_hlp1
64 dec to_reg
65 set ITERATIONS, global_cnt_reg !
66 mov %g0, my_id_reg
67
68
69th_fork(th_main,%l0)
70
71th_main_0:
72 add my_id_reg, 0x20, my_id_reg ! this is my ID address
73
74getlock0:
75 set 1, test_reg ! load the swap data register
76 st test_reg, [addrA_reg] ! try to acquire lock
77 membar 0x40
78 ld [addrB_reg], test_reg ! try to acquire lock
79 tst test_reg
80 be gotlock0
81 nop
82
83 st %g0, [addrA_reg] ! release
84 membar 0x40
85
86 deccc to_reg ! dec timeout count
87 bne getlock0 ! branch if no timeout
88 nop
89 ba,a bad_end
90 nop
91
92gotlock0:
93 setx protected_area, %l0, data_base_reg ! the data area
94
95 set 10, %l0
96 add my_id_reg, data_base_reg, %i1
97loop01:
98 st %i1, [data_base_reg] ! store my ID in there
99 add data_base_reg, 4, data_base_reg ! increment the address
100 add %i1, 1, %i1
101 deccc %l0
102 bne loop01 ! repeat
103 nop
104
105 set 10, %l0
106loop02:
107 sub data_base_reg, 4, data_base_reg
108 sub %i1, 1, %i1
109 ld [data_base_reg], %l1 ! read the data area
110 subcc %l1, %i1, %l1 ! should be same is i1
111 bne bad_end
112 nop
113 deccc %l0 ! repeat
114 bne loop02
115 nop
116
117clearlock0:
118 st %g0, [addrA_reg] ! lock value (0=unlocked)
119 membar 0x40
120
121 mov to_reg, backoff_cnt
122backoff_loop01:
123 nop;nop;nop;nop; ! backoff
124 deccc backoff_cnt
125 bne backoff_loop01
126 nop
127
128 set TIMEOUT, to_reg ! set timeout count again
129
130check_done0:
131 deccc global_cnt_reg
132 be good_end
133 nop
134 ba getlock0
135 nop
136
137th_main_1:
138th_main_4:
139 add my_id_reg, 0x24, my_id_reg
140
141getlock1:
142 set 1, test_reg ! load the swap data register
143 st test_reg, [addrB_reg] ! try to acquire lock
144 membar 0x40
145 ld [addrA_reg], test_reg ! try to acquire lock
146 tst test_reg
147 be gotlock1
148 nop
149
150 st %g0, [addrB_reg] ! release
151 membar 0x40
152
153 sub backoff_hlp1, to_reg, backoff_cnt
154backoff_loop10:
155 nop;nop;nop;nop; ! wait - quasi exponential backoff
156 deccc backoff_cnt ! well, kinda linear.
157 bne backoff_loop10
158 nop
159
160 deccc to_reg ! dec timeout count
161 bne getlock1 ! branch if no timeout
162 nop
163 ba,a bad_end
164 nop
165
166gotlock1:
167 setx protected_area, %l0, data_base_reg ! the data area
168
169 set 10, %l0
170 add my_id_reg, data_base_reg, %i1
171loop11:
172 st %i1, [data_base_reg] ! store my ID in there
173 add data_base_reg, 4, data_base_reg ! increment the address
174 add %i1, 1, %i1
175 deccc %l0
176 bne loop11 ! repeat
177 nop
178
179 set 10, %l0
180loop12:
181 sub data_base_reg, 4, data_base_reg
182 sub %i1, 1, %i1
183 ld [data_base_reg], %l1 ! read the data area
184 subcc %l1, %i1, %l1 ! should be same is i1
185 bne bad_end
186 nop
187 deccc %l0 ! repeat
188 bne loop12
189 nop
190
191
192clearlock1:
193 st %g0, [addrB_reg] ! lock value (0=unlocked)
194 membar 0x40
195
196 set TIMEOUT, to_reg ! set timeout count again
197
198check_done1:
199 deccc global_cnt_reg
200 be good_end
201 nop
202 ba getlock1
203 nop
204
205good_end:
206 ta T_GOOD_TRAP
207bad_end:
208 ta T_BAD_TRAP
209
210!==========================
211
212
213SECTION .MY_DATA0 DATA_VA=0xd0100000
214attr_data {
215 Name = .MY_DATA0,
216 VA= 0x0d0100000
217 RA=0xc000000000,
218 PA=0xc000000000,
219 part_0_ctx_nonzero_tsb_config_0,
220 TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0,
221 TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0,
222 TTE_L=0, TTE_CP=1, TTE_CV=0, TTE_E=0, TTE_P=0, TTE_W=1
223 }
224
225 .data
226
227.global addrA
228.align 0x4
229addrA:
230 .word 0x0
231
232.skip 0x1000
233
234
235SECTION .MY_DATA1 DATA_VA=0xd1110000
236attr_data {
237 Name = .MY_DATA1,
238 VA= 0x0d1110000,
239 RA=0xc200000000,
240 PA=0xc200000000,
241 part_0_ctx_nonzero_tsb_config_1,
242 TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0,
243 TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0,
244 TTE_L=0, TTE_CP=1, TTE_CV=0, TTE_E=0, TTE_P=0, TTE_W=1
245 }
246
247 .data
248.global addrB
249.align 0x4
250addrB:
251 .word 0x0
252.global protected_area
253protected_area:
254 .word 0xbeef
255 .skip 0x1000
256 .word 0xbeef
257
258.end