Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / arch / prm / tso / tso_directed / tso_n1_mutex4_casx.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: tso_n1_mutex4_casx.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 0x4
47
48#if defined CREGS_LSU_CTL_REG_DC && CREGS_LSU_CTL_REG_DC == 0
49#define TIMEOUT 0x2000
50#define ITERATIONS 0x1
51#endif
52
53#if defined CREGS_LSU_CTL_REG_IC && CREGS_LSU_CTL_REG_IC == 0
54#define TIMEOUT 0x2000
55#define ITERATIONS 0x1
56#endif
57
58#if defined CREGS_L2_CTL_REG_DIS && CREGS_L2_CTL_REG_DIS == 1
59#define TIMEOUT 0x2000
60#define ITERATIONS 0x1
61#endif
62
63#include "hboot.s"
64
65.global main
66
67main:
68
69 wr %g0, 0x4, %fprs ! make sure fef is 1
70 setx spinlock_address, %l0, spinlock_addr_reg ! spinlock address
71 set TIMEOUT, to_reg ! set timeout count
72 set ITERATIONS, global_cnt_reg
73
74 or spinlock_addr_reg, %g0, my_id_reg
75
76th_fork(th_main,%l0)
77
78th_main_0:
79 add my_id_reg, 0x20, my_id_reg ! my ID address
80 stb my_id_reg, [my_id_reg] ! store my ID there
81 ba getlock
82 nop
83
84th_main_1:
85 add my_id_reg, 0x24, my_id_reg
86 stb my_id_reg, [my_id_reg]
87 ba getlock
88 nop
89
90
91th_main_2:
92 add my_id_reg, 0x28, my_id_reg
93 stb my_id_reg, [my_id_reg]
94 ba getlock
95 nop
96
97th_main_3:
98 add my_id_reg, 0x2c, my_id_reg
99 stb my_id_reg, [my_id_reg]
100 ba getlock
101 nop
102
103th_main_4:
104 add my_id_reg, 0x30, my_id_reg
105 stb my_id_reg, [my_id_reg]
106 ba getlock
107 nop
108
109th_main_5:
110 add my_id_reg, 0x34, my_id_reg
111 stb my_id_reg, [my_id_reg]
112 ba getlock
113 nop
114
115th_main_6:
116 add my_id_reg, 0x38, my_id_reg
117 stb my_id_reg, [my_id_reg]
118 ba getlock
119 nop
120
121th_main_7:
122 add my_id_reg, 0x3c, my_id_reg
123 stb my_id_reg, [my_id_reg]
124 ba getlock
125 nop
126
127getlock:
128 deccc to_reg ! dec timeout count
129 be bad_end ! branch if no timeout
130 nop
131 or %g0, my_id_reg, test_reg
132 casx [spinlock_addr_reg], %g0, test_reg ! try to acquire lock
133 tst test_reg ! did we get it?
134 bne getlock
135 nop
136
137gotlock: ! do something
138 set TIMEOUT, to_reg ! set to count again
139 setx protected_area, %l0, data_base_reg ! the data area
140
141 set 10, %l0
142loop1:
143 ld [my_id_reg], %f16 ! read the ID
144 st %f16, [data_base_reg] ! store my ID in there
145 add data_base_reg, 8, data_base_reg ! increment the address
146 deccc %l0
147 bne loop1 ! repeat
148 nop
149
150 set 10, %l0
151loop2:
152 sub data_base_reg, 8, data_base_reg
153 ld [my_id_reg], %f16 ! read the ID
154 ld [data_base_reg], %f0 ! read the data area
155 fcmps %fcc0, %f0, %f16 ! should be my ID
156 fbne %fcc0, bad_end
157 nop
158 deccc %l0 ! repeat
159 bne loop2
160 nop
161
162clearlock:
163 stx %g0, [spinlock_addr_reg] ! unlock
164
165check_done: ! finish or iterate
166 deccc global_cnt_reg
167 be good_end
168 nop
169 ba getlock
170 nop
171
172good_end:
173 ta T_GOOD_TRAP
174bad_end:
175 ta T_BAD_TRAP
176
177!==========================
178 .data
179
180user_data_start:
181
182spinlock_address:
183 .word 0x0
184 .skip 0x1000
185protected_area:
186 .word 0xbeef
187 .skip 0x1000
188 .word 0xbeef
189
190
191