Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: ncu_1core_wakup.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_NUCLEUS_ALSO | |
39 | #define MAIN_PAGE_HV_ALSO | |
40 | ||
41 | #include "hboot.s" | |
42 | #include "asi_s.h" | |
43 | ||
44 | .text | |
45 | .global main | |
46 | ||
47 | ||
48 | main: | |
49 | ta T_CHANGE_HPRIV | |
50 | ||
51 | get_th_id_o0: | |
52 | ta T_RD_THID | |
53 | ||
54 | cmp %o1,0x0 | |
55 | be main_t0 | |
56 | nop | |
57 | cmp %o1,0x7 | |
58 | ble t_1_7 | |
59 | nop | |
60 | bg test_fail | |
61 | nop | |
62 | ||
63 | main_t0: | |
64 | !! Wait a while and see if any other threads woke up too | |
65 | call sleep | |
66 | nop | |
67 | ||
68 | ! Get access to common cntrs | |
69 | set 0x1,%g2 | |
70 | setx cntr_access_flag,%g7,%g1 | |
71 | set 0x0,%g3 | |
72 | ||
73 | spin_lock_0: | |
74 | cas [%g1],%g2,%g3 | |
75 | cmp %g3,0x1 | |
76 | bne spin_lock_0 | |
77 | nop | |
78 | ||
79 | setx thrd_sum, %g7,%g4 | |
80 | ldx [%g4],%g2 | |
81 | cmp %g2, 0x0 | |
82 | bne test_fail | |
83 | nop | |
84 | ||
85 | setx thrd_cnt, %g7,%g4 | |
86 | ldx [%g4],%g2 | |
87 | cmp %g2, 0x0 | |
88 | bne test_fail | |
89 | nop | |
90 | ||
91 | ! Release common cntrs | |
92 | stw %g3,[%g1] | |
93 | ||
94 | ! Wake up threads, wait a while and check if the right threads woke up | |
95 | wr %g0,ASI_CMP_CORE,%asi | |
96 | set 0x2b,%g1 | |
97 | stxa %g1,[ASI_CMP_CORE_RUNNING_RW]%asi | |
98 | ||
99 | call sleep | |
100 | nop | |
101 | ||
102 | ! Wait for all other threads to do their bit | |
103 | setx thrd_cnt, %g7,%g4 | |
104 | check_loop: | |
105 | ldx [%g4],%g2 | |
106 | cmp %g2, 0x3 | |
107 | bne check_loop | |
108 | nop | |
109 | ||
110 | ! Wait for a bit in case other threads also wake up | |
111 | call sleep | |
112 | nop | |
113 | ||
114 | setx thrd_sum, %g7,%g4 | |
115 | ldx [%g4],%g2 | |
116 | cmp %g2, 0x9 | |
117 | bne test_fail | |
118 | nop | |
119 | ||
120 | ba test_pass | |
121 | nop | |
122 | ||
123 | t_1_7: | |
124 | ! Get access to common cntrs | |
125 | set 0x1,%g2 | |
126 | setx cntr_access_flag,%g7,%g1 | |
127 | set 0x0,%g3 | |
128 | ||
129 | spin_lock_1_7: | |
130 | cas [%g1],%g2,%g3 | |
131 | cmp %g3,0x1 | |
132 | bne spin_lock_1_7 | |
133 | nop | |
134 | ||
135 | setx thrd_sum,%g7,%g4 | |
136 | ldx [%g4],%g2 | |
137 | add %g2,%o1,%g2 | |
138 | stx %g2,[%g4] | |
139 | ||
140 | setx thrd_cnt,%g7,%g4 | |
141 | ldx [%g4],%g2 | |
142 | add %g2,0x1,%g2 | |
143 | stx %g2,[%g4] | |
144 | ||
145 | ! Release common cntrs | |
146 | stw %g3,[%g1] | |
147 | ||
148 | ba test_pass | |
149 | nop | |
150 | ||
151 | sleep: | |
152 | rd %tick,%l2 | |
153 | setx 0x0000000000000fff,%g7,%l1 | |
154 | add %l1,%l2,%l1 | |
155 | sleep_loop: | |
156 | rd %tick,%l2 | |
157 | cmp %l1,%l2 | |
158 | bpos %xcc,sleep_loop | |
159 | nop | |
160 | retl | |
161 | nop | |
162 | ||
163 | /****************************************************** | |
164 | * Exit code | |
165 | *******************************************************/ | |
166 | ||
167 | test_pass: | |
168 | EXIT_GOOD | |
169 | ||
170 | test_fail: | |
171 | EXIT_BAD | |
172 | ||
173 | .data | |
174 | thrd_cnt: | |
175 | .xword 0x0000000000000000 | |
176 | thrd_sum: | |
177 | .xword 0x0000000000000000 | |
178 | other_core_thrd_cnt: | |
179 | .xword 0x0000000000000000 | |
180 | cntr_access_flag: | |
181 | .word 0x00000001 | |
182 | other_cores: | |
183 | .word 0x00000001 | |
184 | .end | |
185 |