Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / arch / prm / tso / tso_directed / tso_n1_mutex1_check.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: tso_n1_mutex1_check.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)
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
110getlock:
111 or %g0, my_id_reg, test_reg ! load the swap data register
112 swap [spinlock_addr_reg], test_reg ! try to acquire lock
113 tst test_reg ! did we get it?
114 be gotlock
115 nop
116
117dotimeout:
118 deccc to_reg ! dec timeout count
119 bne getlock ! branch if no timeout
120 nop
121 ba,a bad_end
122 nop
123
124gotlock:
125 set TIMEOUT, to_reg ! set timeout count again
126 setx protected_area, %l0, data_base_reg
127
128 set 100, %l0
129 add my_id_reg, data_base_reg, %i1
130loop1:
131 st %i1, [data_base_reg] ! st my ID in the protected area
132 add data_base_reg, 4, data_base_reg ! increment the address
133 add %i1, 1, %i1
134 deccc %l0
135 bne loop1 ! repeat
136 nop
137
138 set 100, %l0
139loop2:
140 sub data_base_reg, 4, data_base_reg
141 sub %i1, 1, %i1
142 ld [data_base_reg], %l1 ! read the data area
143 subcc %l1, %i1, %l1 ! should be same is i1
144 bne bad_end
145 nop
146 deccc %l0 ! repeat
147 bne loop2
148 nop
149
150clearlock:
151 st %g0, [spinlock_addr_reg] ! unlocked
152
153check_done:
154 deccc global_cnt_reg
155 be good_end
156 nop
157 ba getlock
158 nop
159
160good_end:
161 ta T_GOOD_TRAP
162bad_end:
163 ta T_BAD_TRAP
164
165!==========================
166
167
168SECTION .MY_DATA0 TEXT_VA=0xf0100000, DATA_VA=0xd0100000
169attr_data {
170 Name = .MY_DATA0,
171 VA= 0x0d0100000
172 RA= 0x1d0100000
173 PA= ra2pa(0x1d0100000,0),
174part_0_ctx_nonzero_tsb_config_0,
175 TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0,
176 TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0,
177 TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1
178 }
179
180attr_text {
181 Name = .MY_DATA0,
182 VA= 0x0f0100000
183 RA= 0x1f0100000
184 PA= ra2pa(0x1f0100000,0),
185part_0_ctx_nonzero_tsb_config_0,
186 TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0,
187 TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0,
188 TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1
189 }
190
191 .data
192
193.global spinlock_address
194spinlock_address:
195 .word 0x0
196 .skip 0x1000
197 .word 0x0
198
199SECTION .MY_DATA1 TEXT_VA=0xf1110000, DATA_VA=0xd1110000
200attr_data {
201 Name = .MY_DATA1,
202 VA= 0x0d1110000,
203 RA= 0x1d1110000,
204 PA= ra2pa(0x1d1110000,0),
205part_0_ctx_nonzero_tsb_config_0,
206 TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0,
207 TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0,
208 TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1
209 }
210
211attr_text {
212 Name = .MY_DATA1,
213 VA= 0x0f1110000,
214 RA= 0x1f1110000,
215 PA= ra2pa(0x1f1110000,0),
216part_0_ctx_nonzero_tsb_config_0,
217 TTE_G=1, TTE_Context=0x44, TTE_V=1, TTE_Size=0, TTE_NFO=0,
218 TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0,
219 TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1
220 }
221
222 .data
223.global protected_area
224protected_area:
225 .word 0xbeef
226 .skip 0x1000
227 .word 0xbeef
228
229! now do some post-procesing
230.end
231