Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: tso_n1_self_mod111.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 | attr_data { | |
59 | Name = .MAIN, | |
60 | VA=MAIN_BASE_DATA_ADDR, | |
61 | RA=MAIN_BASE_DATA_ADDR_RA, | |
62 | PA=ra2pa(MAIN_BASE_DATA_ADDR_RA,0), | |
63 | part_0_ctx_nonzero_tsb_config_0, | |
64 | TTE_G=0, TTE_Context=PCONTEXT, TTE_V=1, TTE_Size=0, TTE_NFO=0, | |
65 | TTE_IE=0, TTE_Soft2=0, TTE_Diag=0, TTE_Soft=0, | |
66 | TTE_L=0, TTE_CP=1, TTE_CV=1, TTE_E=0, TTE_P=0, TTE_W=1 | |
67 | } | |
68 | ||
69 | .text | |
70 | .global main | |
71 | main: | |
72 | ||
73 | setx label0, %l0,%o0 ! prepare the addresses | |
74 | setx label1, %l0,%o1 | |
75 | setx label2, %l0,%o2 | |
76 | setx label3, %l0,%o3 | |
77 | setx label4, %l0,%o4 | |
78 | setx label5, %l0,%o5 | |
79 | setx label6, %l0,%o6 | |
80 | setx label7, %l0,%o7 | |
81 | ||
82 | setx 0xdeadbeef, %l0, %i1 ! bad data . | |
83 | ||
84 | setx 0x20, %l0, %l2 ! loop counter | |
85 | ||
86 | setx pref_label, %l0,%g1 ! the good instruction | |
87 | ld [%g1], %i0 ! goes to %i0 | |
88 | ||
89 | setx user_data_start, %l0,%g1 | |
90 | or %g0, 0x1, %i2 ! some stores for noise... | |
91 | setx 0x40, %l0, %l3 | |
92 | ||
93 | loop1: | |
94 | st %i2, [%g1] | |
95 | add %i2, 1, %i2 | |
96 | add %g1, 0x40, %g1 ! addr + 0x40 | |
97 | ||
98 | dec %l3 | |
99 | brnz,pt %l3, loop1 | |
100 | nop | |
101 | ||
102 | out_of_loop1: | |
103 | ||
104 | membar #Sync | |
105 | ||
106 | setx user_data_start, %l0,%g1 | |
107 | ||
108 | ba label0a | |
109 | prefetch [%g1], #n_writes | |
110 | ||
111 | pref_label: | |
112 | prefetch [%g1], #n_writes | |
113 | ||
114 | ! The real self-modifying code starts here. | |
115 | !========================================== | |
116 | label0a: | |
117 | st %i0, [%o0] ! store good data to label0 | |
118 | flush %o0 | |
119 | label0: | |
120 | ta T_BAD_TRAP ! | |
121 | ld [%o1], %i3 | |
122 | st %i0, [%o1] ! store good data to label1 | |
123 | flush %o0 ! | |
124 | add %g1, 0x40, %g1 | |
125 | prefetch [%g1], #n_writes ! prefetches are for noise... | |
126 | label1: | |
127 | ta T_BAD_TRAP ! | |
128 | ld [%o2], %i3 | |
129 | st %i0, [%o2] ! etc... | |
130 | flush %o0 ! | |
131 | prefetch [%g1], #n_writes | |
132 | prefetch [%g1], #n_writes | |
133 | add %g1, 0x40, %g1 | |
134 | label2: | |
135 | ta T_BAD_TRAP ! | |
136 | ld [%o3], %i3 | |
137 | st %i0, [%o3] | |
138 | flush %o0 ! | |
139 | prefetch [%g1], #n_writes | |
140 | prefetch [%g1], #n_writes | |
141 | prefetch [%g1], #n_writes | |
142 | add %g1, 0x40, %g1 | |
143 | label3: | |
144 | ta T_BAD_TRAP ! | |
145 | ld [%o4], %i3 | |
146 | st %i0, [%o4] ! | |
147 | flush %o0 ! | |
148 | prefetch [%g1], #n_writes | |
149 | prefetch [%g1], #n_writes | |
150 | prefetch [%g1], #n_writes | |
151 | prefetch [%g1], #n_writes | |
152 | add %g1, 0x40, %g1 | |
153 | label4: | |
154 | ta T_BAD_TRAP ! | |
155 | ld [%o5], %i3 | |
156 | st %i0, [%o5] ! | |
157 | flush %o0 ! | |
158 | prefetch [%g1], #n_writes | |
159 | prefetch [%g1], #n_writes | |
160 | prefetch [%g1], #n_writes | |
161 | prefetch [%g1], #n_writes | |
162 | prefetch [%g1], #n_writes | |
163 | add %g1, 0x40, %g1 | |
164 | label5: | |
165 | ta T_BAD_TRAP ! | |
166 | ld [%o6], %i3 | |
167 | st %i0, [%o6] ! | |
168 | flush %o0 ! | |
169 | prefetch [%g1], #n_writes | |
170 | prefetch [%g1], #n_writes | |
171 | prefetch [%g1], #n_writes | |
172 | prefetch [%g1], #n_writes | |
173 | prefetch [%g1], #n_writes | |
174 | prefetch [%g1], #n_writes | |
175 | add %g1, 0x40, %g1 | |
176 | ||
177 | label6: | |
178 | ta T_BAD_TRAP ! | |
179 | ld [%o7], %i3 | |
180 | st %i0, [%o7] | |
181 | flush %o0 ! | |
182 | prefetch [%g1], #n_writes | |
183 | prefetch [%g1], #n_writes | |
184 | prefetch [%g1], #n_writes | |
185 | prefetch [%g1], #n_writes | |
186 | prefetch [%g1], #n_writes | |
187 | prefetch [%g1], #n_writes | |
188 | prefetch [%g1], #n_writes | |
189 | add %g1, 0x40, %g1 | |
190 | ||
191 | label7: | |
192 | ta T_BAD_TRAP ! | |
193 | ld [%o0], %i3 | |
194 | st %i0, [%o0] | |
195 | flush %o0 ! | |
196 | ||
197 | ld [%o7], %i3 | |
198 | ld [%o1], %i3 | |
199 | ld [%o2], %i3 | |
200 | ld [%o3], %i3 | |
201 | ld [%o4], %i3 | |
202 | ld [%o5], %i3 | |
203 | ld [%o6], %i3 | |
204 | ld [%o7], %i3 | |
205 | st %i1, [%o0] ! store bad data to all the labels | |
206 | st %i1, [%o1] | |
207 | st %i1, [%o2] | |
208 | st %i1, [%o3] | |
209 | st %i1, [%o4] | |
210 | st %i1, [%o5] | |
211 | st %i1, [%o6] | |
212 | st %i1, [%o7] | |
213 | ||
214 | dec %l2 ! and loop again. | |
215 | brnz,pt %l2, label0a | |
216 | prefetch [%g1], #n_writes | |
217 | ||
218 | normal_end: | |
219 | ta T_GOOD_TRAP | |
220 | bad_end: | |
221 | ta T_BAD_TRAP | |
222 | ||
223 | ||
224 | user_text_end: | |
225 | ||
226 | /*********************************************************************** | |
227 | Test case data start | |
228 | ***********************************************************************/ | |
229 | .data | |
230 | .align 0x100 | |
231 | ||
232 | user_data_start: | |
233 | .skip 2048 | |
234 | user_data_end: |