Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: tso_n1_indirection2.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 tmp0 %i0 | |
39 | #define tmp1 %i1 | |
40 | #define tmp2 %i2 | |
41 | #define tmp3 %i3 | |
42 | ||
43 | #define global_cnt_reg %i4 | |
44 | ||
45 | #define addrA_reg %l0 | |
46 | #define addrC_reg %l2 | |
47 | ||
48 | #define test_reg %o4 | |
49 | #define test2_reg %o5 | |
50 | ||
51 | #define ITERATIONS 0x4 | |
52 | ||
53 | #include "hboot.s" | |
54 | ||
55 | .global main | |
56 | ||
57 | main: | |
58 | ||
59 | setx addrA, tmp1, addrA_reg | |
60 | setx addrC, tmp1, addrC_reg | |
61 | ||
62 | set ITERATIONS, global_cnt_reg | |
63 | ||
64 | th_fork(th_main,tmp1) | |
65 | ||
66 | !===================================================== | |
67 | th_main_0: | |
68 | mov 0x20, test2_reg | |
69 | loop00: | |
70 | inc test2_reg | |
71 | st test2_reg, [addrA_reg] | |
72 | ||
73 | ! BARRIER here | |
74 | !============= | |
75 | set barrier_code, tmp0 | |
76 | jmpl tmp0,%o7 | |
77 | nop | |
78 | ||
79 | dec global_cnt_reg | |
80 | brz global_cnt_reg, good_end | |
81 | nop | |
82 | ||
83 | ba loop00 | |
84 | nop | |
85 | ||
86 | !========================================================= | |
87 | #ifdef ZERO_THREE_SIX | |
88 | th_main_3: | |
89 | #else | |
90 | th_main_1: | |
91 | #endif | |
92 | th_main_4: | |
93 | ||
94 | mov 0x21, test2_reg | |
95 | loop10: ! wait | |
96 | ld [addrA_reg], test_reg | |
97 | sub test_reg, test2_reg, tmp1 | |
98 | brnz tmp1, loop10 | |
99 | nop | |
100 | ||
101 | st test_reg, [addrC_reg] ! store non-zero to C | |
102 | inc test2_reg | |
103 | ||
104 | ! BARRIER here | |
105 | !============= | |
106 | set barrier_code, tmp0 | |
107 | jmpl tmp0,%o7 | |
108 | nop | |
109 | ||
110 | dec global_cnt_reg | |
111 | brz global_cnt_reg, good_end | |
112 | nop | |
113 | ||
114 | ba loop10 ! loop | |
115 | nop | |
116 | ||
117 | !========================================================= | |
118 | #ifdef ZERO_THREE_SIX | |
119 | th_main_6: | |
120 | #else | |
121 | th_main_2: | |
122 | #endif | |
123 | th_main_8: | |
124 | ||
125 | mov 0x21, test2_reg | |
126 | loop30: | |
127 | ld [addrC_reg], test_reg ! load C until set | |
128 | brz test_reg, loop30 | |
129 | nop | |
130 | ||
131 | ld [addrA_reg], test_reg | |
132 | subcc test_reg, test2_reg, %g0 | |
133 | bne bad_end | |
134 | nop | |
135 | ||
136 | inc test2_reg | |
137 | ||
138 | st %g0, [addrC_reg] ! clear | |
139 | st %g0, [addrA_reg] ! clear | |
140 | ||
141 | ! BARRIER here | |
142 | !============= | |
143 | set barrier_code, tmp0 | |
144 | jmpl tmp0,%o7 | |
145 | nop | |
146 | ||
147 | dec global_cnt_reg | |
148 | brz global_cnt_reg, good_end | |
149 | nop | |
150 | ||
151 | ba loop30 ! loop | |
152 | nop | |
153 | ||
154 | !============================================================ | |
155 | ||
156 | barrier_code: | |
157 | setx barrier_data, tmp1, tmp2 | |
158 | sll global_cnt_reg, 0x3, tmp1 | |
159 | add tmp1, tmp2, tmp2 | |
160 | ||
161 | bloop1: | |
162 | mov 0xff, tmp1 | |
163 | cas [tmp2], %g0, tmp1 | |
164 | brnz tmp1, bloop1 | |
165 | #ifdef PREFETCH ! lock the barrier counter | |
166 | prefetch [tmp2], #n_reads | |
167 | #else | |
168 | nop | |
169 | #endif | |
170 | ||
171 | ld [tmp2 + 4], tmp3 ! increment | |
172 | inc tmp3 | |
173 | st tmp3, [tmp2 + 4] | |
174 | ||
175 | st %g0, [tmp2] ! unlock | |
176 | bloop2: | |
177 | ld [tmp2 + 4], tmp3 ! if 0 | |
178 | brz tmp3, bout2 ! somebody already reset it | |
179 | sub tmp3, THREAD_COUNT, tmp3 ! subtract THREAD_COUNT | |
180 | brnz tmp3, bloop2 ! if 0 we are out. | |
181 | #ifdef PREFETCH | |
182 | prefetch [tmp2], #n_reads | |
183 | #else | |
184 | nop | |
185 | #endif | |
186 | ||
187 | st %g0, [tmp2 + 4] ! clear the barrier counter | |
188 | bout2: | |
189 | jmpl %o7+8, %g0 ! return | |
190 | nop | |
191 | ||
192 | good_end: | |
193 | ta T_GOOD_TRAP | |
194 | bad_end: | |
195 | ta T_BAD_TRAP | |
196 | ||
197 | !========================== | |
198 | ||
199 | .data | |
200 | ||
201 | .global addrA | |
202 | .align 0x40 | |
203 | addrA: | |
204 | .word 0x0 | |
205 | .skip 0x100 | |
206 | ||
207 | .align 0x40 | |
208 | .global addrC | |
209 | addrC: | |
210 | .word 0x0 | |
211 | .skip 0x100 | |
212 | .global barrier_data | |
213 | barrier_data: | |
214 | .skip 0x100 | |
215 | ||
216 | .end |