Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: tso_n1_cross_mod5.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_BASE_DATA_ADDR 0x160000 | |
39 | #define MAIN_BASE_TEXT_ADDR 0x150000 | |
40 | #define MAIN_BASE_DATA_ADDR_RA 0x100160000 | |
41 | #define MAIN_BASE_TEXT_ADDR_RA 0x100150000 | |
42 | ||
43 | #define USER_PAGE_CUSTOM_MAP | |
44 | #include "hboot.s" | |
45 | ||
46 | SECTION .MAIN TEXT_VA=0x150000, DATA_VA=0x160000 | |
47 | ||
48 | attr_text { | |
49 | Name = .MAIN, | |
50 | VA=MAIN_BASE_TEXT_ADDR, | |
51 | RA=MAIN_BASE_TEXT_ADDR_RA, | |
52 | PA=ra2pa(MAIN_BASE_TEXT_ADDR_RA,0), | |
53 | part_0_ctx_nonzero_tsb_config_0, | |
54 | TTE_G=0, TTE_Context=PCONTEXT, TTE_V=1, TTE_Size=0, TTE_NFO=0, | |
55 | TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0, | |
56 | TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_EP=1, TTE_P=0, TTE_W=1 | |
57 | } | |
58 | ||
59 | attr_data { | |
60 | Name = .MAIN, | |
61 | VA=MAIN_BASE_DATA_ADDR, | |
62 | RA=MAIN_BASE_DATA_ADDR_RA, | |
63 | PA=ra2pa(MAIN_BASE_DATA_ADDR_RA,0), | |
64 | part_0_ctx_nonzero_tsb_config_0, | |
65 | TTE_G=0, TTE_Context=PCONTEXT, TTE_V=1, TTE_Size=0, TTE_NFO=0, | |
66 | TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0, | |
67 | TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1 | |
68 | } | |
69 | ||
70 | .text | |
71 | .global main | |
72 | main: | |
73 | clr %l0 | |
74 | ||
75 | th_fork(th_main,%l0) | |
76 | ||
77 | ||
78 | ! this thread modfifies the code | |
79 | !=============================== | |
80 | th_main_0: | |
81 | ||
82 | set 0x40, %i7 ! loop counting | |
83 | ||
84 | setx ready, %l0, %l1 ! pointers... | |
85 | setx noop, %l0, %l2 | |
86 | ld [%l2], %o7 ! %o7 contains the nop command | |
87 | ||
88 | deliver_loop: | |
89 | ||
90 | setx modified1, %l0, %l3 ! | |
91 | deliver_loop1: | |
92 | ld [%l1], %o0 ! read ready. | |
93 | tst %o0 ! should be 0. | |
94 | bne deliver_loop1 | |
95 | nop | |
96 | ||
97 | st %o7, [%l3] ! modify the code. | |
98 | st %o7, [%l3 + 4] ! and then flush. | |
99 | flush %l3 ! the register value does not matter | |
100 | ||
101 | setx modified2, %l0, %l3 ! | |
102 | deliver_loop2: | |
103 | ld [%l1 + 0x4], %o0 ! read ready. | |
104 | tst %o0 ! should be 0. | |
105 | bne deliver_loop2 | |
106 | nop | |
107 | ||
108 | st %o7, [%l3] ! modify the code. | |
109 | st %o7, [%l3 + 4] ! and then flush. | |
110 | flush %l3 ! the register value does not matter | |
111 | ||
112 | setx modified3, %l0, %l3 ! | |
113 | deliver_loop3: | |
114 | ld [%l1 + 0x8], %o0 ! read ready. | |
115 | tst %o0 ! should be 0. | |
116 | bne deliver_loop3 | |
117 | nop | |
118 | ||
119 | st %o7, [%l3] ! modify the code. | |
120 | st %o7, [%l3 + 4] ! and then flush. | |
121 | flush %l3 ! the register value does not matter | |
122 | ||
123 | deccc %i7 ! count | |
124 | bne goon | |
125 | nop | |
126 | ba final_stuff ! go to end if finished | |
127 | nop | |
128 | ||
129 | goon: | |
130 | set 1, %i0 ! set ready | |
131 | st %i0, [%l1] ! | |
132 | st %i0, [%l1+4] ! | |
133 | st %i0, [%l1+8] ! | |
134 | ba deliver_loop ! repeat | |
135 | nop | |
136 | ||
137 | final_stuff: | |
138 | set 0x1, %i0 ! 55 means we are done. | |
139 | st %i0, [%l1] ! | |
140 | st %i0, [%l1+4] ! | |
141 | set 0x55, %i0 ! 55 means we are done. | |
142 | st %i0, [%l1+8] ! | |
143 | ba good_end | |
144 | nop | |
145 | ||
146 | ! these are the receivers | |
147 | !------------------------ | |
148 | th_main_1: | |
149 | th_main_4: | |
150 | ||
151 | setx ready, %l0, %l1 ! pointers... | |
152 | setx bad_end, %l0, %l2 | |
153 | ld [%l2], %o7 ! o7 contains a ta 0x101 | |
154 | ||
155 | wait_loop: ! wait for ready flag | |
156 | wait_loop1: ! wait for ready flag | |
157 | ld [%l1], %o0 | |
158 | subcc %o0, 0x1, %i1 ! code for available data | |
159 | bne wait_loop1 | |
160 | nop | |
161 | nop | |
162 | modified1: | |
163 | ta T_BAD_TRAP ! this data is overwritten | |
164 | ta T_BAD_TRAP ! with nop-s, so diag goes on. | |
165 | ||
166 | wait_loop2: ! wait for ready flag | |
167 | ld [%l1+0x4], %o0 | |
168 | subcc %o0, 0x1, %i1 ! check for end of test flag. | |
169 | bne wait_loop2 | |
170 | nop | |
171 | nop | |
172 | modified2: | |
173 | ta T_BAD_TRAP ! this data is overwritten | |
174 | ta T_BAD_TRAP ! with nop-s, so diag goes on. | |
175 | ||
176 | wait_loop3: ! wait for ready flag | |
177 | ld [%l1+0x8], %o0 | |
178 | subcc %o0, 0x55, %i1 ! check for end of test flag. | |
179 | be good_end ! end the test | |
180 | nop | |
181 | subcc %o0, 0x1, %i1 ! code for available data | |
182 | bne wait_loop3 | |
183 | nop | |
184 | nop | |
185 | modified3: | |
186 | ta T_BAD_TRAP ! this data is overwritten | |
187 | ta T_BAD_TRAP ! with nop-s, so diag goes on. | |
188 | ||
189 | setx modified1, %l0, %l3 | |
190 | st %o7, [%l3] ! now overwrite again to ta T_BAD_TRAP | |
191 | st %o7, [%l3 + 4] | |
192 | setx modified2, %l0, %l3 | |
193 | st %o7, [%l3] ! now overwrite again to ta T_BAD_TRAP | |
194 | st %o7, [%l3 + 4] | |
195 | setx modified3, %l0, %l3 | |
196 | st %o7, [%l3] ! now overwrite again to ta T_BAD_TRAP | |
197 | st %o7, [%l3 + 4] | |
198 | ||
199 | st %g0, [%l1] ! reset the flags | |
200 | st %g0, [%l1 + 4] | |
201 | st %g0, [%l1 + 8] | |
202 | ||
203 | ba wait_loop ! do it again | |
204 | nop | |
205 | ||
206 | good_end: | |
207 | ta T_GOOD_TRAP | |
208 | bad_end: | |
209 | ta T_BAD_TRAP | |
210 | noop: | |
211 | nop | |
212 | ||
213 | !------------------------------------------------------------------------------ | |
214 | ||
215 | .data | |
216 | .global ready | |
217 | ready: | |
218 | .word 0x0 | |
219 | .word 0x0 | |
220 | .word 0x0 | |
221 | .word 0x0 | |
222 | ||
223 | .end | |
224 |