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