Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: n2_err_L2_LDWC_cecc_trap.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_HV_ALSO | |
39 | ||
40 | #define L2_ENTRY_PA 0x517590000 | |
41 | #define TEST_DATA 0x555555555555555 | |
42 | #define L2_ES_W1C_VALUE 0xc03ffff800000000 | |
43 | ||
44 | ||
45 | #include "hboot.s" | |
46 | #include "asi_s.h" | |
47 | #include "err_defines.h" | |
48 | ||
49 | .text | |
50 | .global main | |
51 | .global My_Corrected_ECC_error_trap | |
52 | ||
53 | ||
54 | main: | |
55 | ||
56 | ||
57 | ! Boot code does not provide TLB translation for IO address space | |
58 | ta T_CHANGE_HPRIV | |
59 | ||
60 | setx L2_ES_W1C_VALUE, %l0, %g4 | |
61 | ||
62 | ! Now access L2 control and status registers | |
63 | disable_l1: | |
64 | ldxa [%g0] ASI_LSU_CONTROL, %l0 | |
65 | ! Remove the lower 2 bits (I-Cache and D-Cache enables) | |
66 | andn %l0, 0x3, %l0 | |
67 | stxa %l0, [%g0] ASI_LSU_CONTROL | |
68 | ||
69 | ||
70 | enable_err_reporting: | |
71 | setx L2EE_PA0, %l0, %l1 | |
72 | ldx [%l1], %l2 | |
73 | mov 0x1, %l0 | |
74 | or %l2, %l0, %l2 | |
75 | stx %l2, [%l1] | |
76 | ||
77 | ||
78 | ! Write 1 to clear L2 Error status registers | |
79 | ||
80 | clear_l2_ESR: | |
81 | setx L2ES_PA0, %l3, %l4 | |
82 | stx %g4, [%l4] | |
83 | nop | |
84 | ||
85 | ||
86 | set_L2_Directly_Mapped_Mode: | |
87 | setx L2CS_PA0, %l6, %g1 | |
88 | mov 0x2, %l0 | |
89 | stx %l0, [%g1] | |
90 | ||
91 | ||
92 | store_to_L2_way0: | |
93 | setx TEST_DATA, %l0, %g5 | |
94 | setx 0x202000aa00, %l0, %g1 | |
95 | stx %g5, [%g1] | |
96 | stx %g5, [%g1+8] | |
97 | membar #Sync | |
98 | ||
99 | ||
100 | generate_VD_addr: | |
101 | ! Generate L2 VD Diag read address | |
102 | ! Addressing: [39:32] See PRM, [22] 1 for V/D, [17:8] set, [7:6] bank, [2:0] = 0 | |
103 | setx 0x3ffc0, %l0, %l2 ! Mask for extracting [17:6] | |
104 | and %g1, %l2, %l7 | |
105 | ||
106 | mov 0xb6, %l0 | |
107 | sllx %l0, 32, %l0 ! Bits [39:32] | |
108 | or %l7, %l0, %l7 | |
109 | ||
110 | mov 0x1, %l0 | |
111 | sllx %l0, 22, %l0 ! Bit [22] | |
112 | or %l7, %l0, %l7 | |
113 | ||
114 | read_l2_VD_diag: | |
115 | ! ldx [%l7], %l6 | |
116 | ||
117 | ! Now find out which way it is being stored | |
118 | setx 0xffff, %l0, %l2 ! Mask for [16:0] | |
119 | and %l6, %l2, %l6 ! Valid bits at [31:16] | |
120 | ||
121 | clr %g2 ! %g2 will store the "way" | |
122 | ||
123 | ! Direct comparison - avoid loops to save run time | |
124 | ! cmp %l6, 0x1 | |
125 | ! bne test_fail | |
126 | ! nop | |
127 | ||
128 | way_found: | |
129 | ! Read L2 Data Diag - %g2 has the "way" | |
130 | ! Addressing: [39:32] See PRM, [22] odd/even word, [21:18] way, [17:8] set, [7:6] bank, [5:3] D-word, [2:0] = 0 | |
131 | setx 0x3fff8, %l0, %l2 ! Mask for extracting [17:3] | |
132 | and %g1, %l2, %g5 | |
133 | ||
134 | sllx %g2, 18, %l0 ! Position Way | |
135 | or %g5, %l0, %g5 | |
136 | ||
137 | mov 0xa3, %l0 | |
138 | sllx %l0, 32, %l0 ! Bits [39:32] | |
139 | or %g5, %l0, %g5 ! %g5 has L2 Data Diag addressing | |
140 | ||
141 | ||
142 | read_l2_data_diag: | |
143 | ldx [%g5], %g6 | |
144 | ||
145 | ! Flip one bit from the data field | |
146 | xor %g6, 0x80, %g6 ! save on %g6 for future reference | |
147 | write_back_with_error: | |
148 | stx %g6, [%g5] | |
149 | ||
150 | ! Now set allocate bits for all other 15 ways (to ensure a write-back later) | |
151 | set_allocate: | |
152 | mov 0x1, %l0 | |
153 | sllx %l0, 22, %l1 ! L2_VD and L2_UA addressing differ on bit 22 | |
154 | xor %l7, %l1, %l7 ! change %l7 from L2_VD to L2_UA address | |
155 | ||
156 | read_l2_UA_diag: | |
157 | ! ldx [%l7], %l6 | |
158 | ||
159 | sllx %l0, %g2, %l1 ! Shift "way" into its bit position | |
160 | not %l1 | |
161 | setx 0xffff,%l5, %g2 | |
162 | and %l1, %g2 , %l1 ! Allocate bits on [15:0] | |
163 | or %l6, %l1, %l6 ! Write 1 to all other 15 ways' allocate bits | |
164 | ||
165 | ! also need to set ECC bits for Allocate bits (Bits [38:32]) | |
166 | set_ECC_Allocate: | |
167 | mov 0x7f, %l0 | |
168 | sllx %l0, 32, %l0 | |
169 | xor %l6, %l0, %l1 | |
170 | or %l6, %l1, %l6 | |
171 | ||
172 | write_l2_UA_diag: | |
173 | ! stx %l6, [%l7] | |
174 | ||
175 | ||
176 | ! Now do another store with the same index but different tag - to force a Write-Back | |
177 | error_address: | |
178 | mov 0x1, %l0 | |
179 | sllx %l0, 28, %l0 | |
180 | xor %g1, %l0, %l1 ! Flip bit 28 of previous L2 entry PA | |
181 | ||
182 | ! This should cause L2 LDWC (bit 51) | |
183 | store_to_L2_with_error: | |
184 | st %g5, [%l1] | |
185 | membar #Sync | |
186 | ||
187 | /**** | |
188 | ! Check if a Corrected ECC Trap happened | |
189 | check_error_trap1: | |
190 | setx EXECUTED, %l1, %l0 | |
191 | cmp %o0, %l0 | |
192 | bne test_fail | |
193 | nop | |
194 | mov TT_Corrected_ECC, %l0 | |
195 | cmp %o1, %l0 | |
196 | bne test_fail | |
197 | nop | |
198 | ||
199 | ****/ | |
200 | ||
201 | enable_l1: | |
202 | ldxa [%g0] ASI_LSU_CONTROL, %l0 | |
203 | or %l0, 0x3, %l0 | |
204 | stxa %l0, [%g0] ASI_LSU_CONTROL | |
205 | ||
206 | ||
207 | ! Compute expected value of L2 error status register | |
208 | compute_expected_L2_ESR: | |
209 | mov 0x1, %l1 | |
210 | sllx %l1, L2ES_LDWC, %l0 | |
211 | sllx %l1, L2ES_VEC, %l3 ! VEC bit | |
212 | or %l0, %l3, %l0 | |
213 | ! No RW bit or Syndrome field for LDWC - %l0 has expected value | |
214 | ||
215 | setx L2ES_PA0, %l2, %l3 | |
216 | ||
217 | ||
218 | check_l2_ESR: | |
219 | ldx [%l3], %l4 | |
220 | ||
221 | cmp %l4, %l0 | |
222 | bne test_fail | |
223 | nop | |
224 | ||
225 | setx L2EA_PA0, %l2, %l3 | |
226 | check_l2_EAR: | |
227 | ldx [%l3], %l4 | |
228 | ||
229 | ! Error address is the physical address of the cache line (PA[5:0] 0) | |
230 | andn %g1, 0x3f, %l1 | |
231 | cmp %l4, %l1 | |
232 | bne test_fail | |
233 | nop | |
234 | ||
235 | ! Check if a Corrected ECC Trap happened | |
236 | check_error_trap: | |
237 | setx EXECUTED, %l1, %l0 | |
238 | cmp %o0, %l0 | |
239 | bne test_fail | |
240 | nop | |
241 | mov TT_Corrected_ECC, %l0 | |
242 | cmp %o1, %l0 | |
243 | bne test_fail | |
244 | nop | |
245 | ||
246 | ba test_pass | |
247 | nop | |
248 | ||
249 | My_Corrected_ECC_error_trap: | |
250 | ! Signal trap taken | |
251 | setx EXECUTED, %l0, %o0 | |
252 | ! save trap type value | |
253 | rdpr %tt, %o1 | |
254 | // retry | |
255 | done | |
256 | nop | |
257 | /******************************************************* | |
258 | * Exit code | |
259 | *******************************************************/ | |
260 | ||
261 | test_pass: | |
262 | ta T_GOOD_TRAP | |
263 | ||
264 | test_fail: | |
265 | ta T_BAD_TRAP | |
266 |