Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / include / mcu_trap.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: mcu_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*/
38My_H_HT0_Hw_Corrected_Error_0x63:
39 inc %o7 !keep count of traps taken
40
41read_core_desr_0x63:
42 clr %g5 !use as intermediate register for setx
43 ldxa [%g0] 0x4c, %g1 !read DESR
44 srlx %g1, 61, %g2 !check if SWR or HWC
45 and %g2, 1, %g2
46 cmp %g2, 1
47 be %xcc, test_fail
48 nop
49 srlx %g1, 56, %g2
50 and %g2, 0x1f, %g2
51 cmp %g2, 4
52 ble %xcc, 1f ! branch to I$
53 nop
54 cmp %g2, 8
55 ble %xcc, 2f ! branch to D$
56 nop
57 cmp %g2, 9
58 bne %xcc, test_fail
59 nop
60 ba 3f ! branch normal, first check L2 esr, then check MCU esr
61 nop
621:
63 and %g1, 0x7ff, %g2
64 sllx %g2, 6, %g2 !index is in bits 11:6 of load_addr
65 ldxa [%g2] 0x67, %g3 !ASI_ICACHE_TAG
66 mov 8, %g7
671:
68 ldxa [%g2] 0x66, %g3 !ASI_ICACHE_INSTR
69 add %g2, 8, %g2
70 dec %g7
71 brnz %g7, 1b
72 nop
73 ba 3f
74 nop
752:
76 and %g1, 0x7ff, %g2
77 sllx %g2, 4, %g2 !index is in bits 10:4 of load_addr
78 ldxa [%g2] 0x47, %g3 !ASI_DCACHE_TAG
79 mov 1, %g4
80 sllx %g4, 13, %g4
81 ldxa [%g2+%g4] 0x46, %g3 !ASI_DCACHE_DATA
82 add %g4, 8, %g4
83 ldxa [%g2+%g4] 0x46, %g3 !ASI_DCACHE_DATA
84
85
86! find which L2 bank logged error
873:
88find_l2_bank_0x63:
89 !need to find bank
90 setx L2_ERROR_STATUS_REGISTER, %g5, %g4
91 mov %g4, %o0 !copy to be used later
92 setx L2_LAST_ERROR_STATUS_REGISTER, %g5, %g6
93 mov 8, %o1
941:
95read_l2_bank_esr_0x63:
96 ldx [%g4], %g7
97
98#ifdef ECC_CE
99 mov 1, %g2
100 sllx %g2, 42, %g2 !DAC
101 and %g2, %g7, %g3
102 cmp %g2, %g3
103 be %xcc, 1f
104 nop
105#endif
106#ifdef CRC_RE
107 mov 1, %g2
108 sllx %g2, 38, %g2 !DSC
109 and %g2, %g7, %g3
110 cmp %g2, %g3
111 be %xcc, 1f
112 nop
113#endif
114#ifdef SCRUB_CE
115 mov 1, %g2
116 sllx %g2, 38, %g2 !DSC
117 and %g2, %g7, %g3
118 cmp %g2, %g3
119 be %xcc, 1f
120 nop
121#endif
122
123 add %g4, 0x40, %g4
124 dec %o1
125 brnz %o1,1b
126 nop
127 ba test_fail
128 nop
129
130! find which MCU logged error
1311:
132find_mcu_0x63:
133 sub %g4, %o0, %o1
134 and %o1, 0x180, %g2 !which MCU it is coming from
135 mov %g0, %g3
1361:
137 cmp %g2, %g3
138 be %xcc, 1f
139 nop
140 add %g3, 0x80, %g3
141 ba 1b
142 nop
1431:
144 udivx %g3, 0x80, %g3
145 setx 0x1000, %g5, %g1
146 mulx %g3, %g1, %g3
147 setx DRAM_ERROR_STATUS_REGISTER, %g5, %g6
148 add %g3, %g6, %g6
149
150read_mcu_esr_0x63:
151 ldx [%g6], %g7
152
153#ifdef ECC_CE
154 mov 1, %g2
155 sllx %g2, 61, %g2 !DAC
156 and %g2, %g7, %g1
157 cmp %g2, %g1
158 bne %xcc, test_fail
159 nop
160 setx 0xffff, %g5, %g2 !check MCU ECC synd
161 and %g2, %g7, %g1
162 cmp %g0, %g1 ! MSA 11/30/06: confirm that MCU SYND is non Zero
163 be %xcc, test_fail
164 nop
165 setx DRAM_ERROR_RETRY_REGISTER, %g5, %g2
166 add %g3, %g2, %g2
167 ldx [%g2], %g1
168 !and %g1, 0x3, %g1
169 !cmp %g1, 2
170 !bne test_fail ! MSA 11/30/06 DRAM_ERROR_RETRY_REGISTER check is disabled
171 !nop
172 setx VALID_BIT, %g5, %g1
173 stx %g1, [%g2]
174#endif
175#ifdef CRC_RE
176 mov 1, %g2
177 sllx %g2, 54, %g2 !FBR
178 and %g2, %g7, %g1
179 cmp %g2, %g1
180 bne %xcc, test_fail
181 nop
182
183check_fbd_synd_reg_0x63: ! MSA 11/30/06; added label
184 setx DRAM_FBD_ERROR_SYNDROME_REGISTER, %g5, %g2
185 add %g3, %g2, %g2
186 ldx [%g2], %g1
187#ifdef CRC_NB
188 and %g1, 0x1, %g1
189#endif
190#ifdef CRC_SB
191 and %g1, 0x2, %g1
192#endif
193 cmp %g0, %g1
194 be test_fail
195 nop
196!11/30/06 setx VALID_BIT, %g5, %g1
197!11/30/06 stx %g1, [%g2]
198
199#ifdef CRC_SB
200clear_amb_reg_0x63:
201 !First AMB Error Reg
202 !channel 0
203 setx 0x8400000900, %g5, %g3
204 set 0x190, %g4
205 stx %g4, [%g3]
206
207 setx 0x8400000908, %g5, %g3
208 set 0xff, %g4
209 stx %g4, [%g3]
210
211 !channel 1
212 setx 0x8400000900, %g5, %g3
213 set 0x8190, %g4
214 stx %g4, [%g3]
215
216 setx 0x8400000908, %g5, %g3
217 set 0xff, %g4
218 stx %g4, [%g3]
219
220 !Second AMB Error Reg
221 !channel 0
222 setx 0x8400000900, %g5, %g3
223 set 0x194, %g4
224 stx %g4, [%g3]
225
226 setx 0x8400000908, %g5, %g3
227 set 0xff, %g4
228 stx %g4, [%g3]
229
230 !channel 1
231 setx 0x8400000900, %g5, %g3
232 set 0x8194, %g4
233 stx %g4, [%g3]
234
235 setx 0x8400000908, %g5, %g3
236 set 0xff, %g4
237 stx %g4, [%g3]
238#endif
239#ifndef CRC_SB
240clear_fbd_Synd_reg_0x63: ! MSA 11/30/06
241 setx DRAM_FBD_ERROR_SYNDROME_REGISTER, %g5, %g2
242 stx %g0, [%g2]
243 stx %g0, [%g2]
244 ldx [%g2], %g5
245#endif
246#endif
247#ifdef SCRUB_CE
248 mov 1, %g2
249 sllx %g2, 59, %g2 !DSC
250 and %g2, %g7, %g1
251 cmp %g2, %g1
252 bne %xcc, test_fail
253 nop
254 setx 0xffff, %g5, %g2
255 and %g2, %g7, %g1
256 cmp %g0, %g1
257 be %xcc, test_fail
258 nop
259 setx DRAM_ERROR_ADDRESS_REGISTER, %g5, %g2
260 add %g3, %g2, %g2
261 ldx [%g2], %g1
262#endif
263
2642:
265clear_l2_bank_esr_0x63:
266 mov 8, %o1
267 setx L2_ESR_WRITE_1_TO_CLEAR, %g5, %g3
268 setx L2_ERROR_STATUS_REGISTER, %g5, %g4
2691:
270 stx %g3, [%g4]
271 add %g4, 0x40, %g4
272 dec %o1
273 brnz %o1,1b
274 nop
275clear_mcu_esr_0x63:
276 mov 4, %o1
277 setx DRAM_ESR_WRITE_1_TO_CLEAR, %g5, %g3
278 setx DRAM_ERROR_STATUS_REGISTER, %g5, %g6
279 set 0x1000, %g2
2801:
281 stx %g3, [%g6]
282 ldx [%g6], %g5 ! MSA
283 add %g6, %g2, %g6
284 dec %o1
285 brnz %o1,1b
286 nop
287
288 retry
289 nop
290
291
292! ***************************************************************************
293
294
295! ### # # ###
296! # # # # # # # #
297! # # # # # # # #
298! # # ## # # # #
299! # # ## ####### # #
300! # # # # # # #
301! ### # # # ###
302
303
304
305My_H_HT0_Sw_Recoverable_Error_0x40:
306 inc %o7 !keep count of traps taken
307 mov %g0,%o5
308
309read_core_desr_0x40:
310 clr %g5 !use as intermediate register for setx
311 ldxa [%g0] 0x4c, %g1 !DESR
312 mov %g1, %o0 !copy to be used later
313 srlx %g1, 61, %g2
314 and %g2, 1, %g2
315 cmp %g2, 1
316 bne %xcc, test_fail
317 nop
318 srlx %g1, 56, %g2
319 and %g2, 0x1f, %g2
320#ifdef ECC_UE
321 cmp %g2, 17
322 be %xcc, 4f ! branch if you see notdata in DESR, clear L2 notdata register
323 nop
324 cmp %g2, 16
325 bne %xcc, test_fail
326 nop
327#else
328 cmp %g2, 4
329 ble %xcc, 2f ! branch normal, check which L2 esr logged, which MCU esr logged
330 nop
331 cmp %g2, 20
332 be %xcc, 2f ! branch normal, check which L2 esr logged, which MCU esr logged
333 nop
334#endif
335
336#ifdef ECC_UE
3374:
338clear_l2_notdata_error_register_0x40:
339 mov 1,%o5
340 mov 8, %o1
341 setx L2_NOTDATA_REGISTER_WRITE_1_TO_CLEAR, %g5, %g3
342 setx L2_NOTDATA_REGISTER, %g5, %g4
3431:
344 stx %g3, [%g4]
345 add %g4, 0x40, %g4
346 dec %o1
347 brnz %o1,1b
348 nop
349 ba 2f ! MSA: 12/04/06; it was bypassing all check to almost end of the handler with "ba 3f"
350 nop
351#endif
352
353! find which L2 bank esr is logged
3542:
355find_l2_bank_0x40:
356 !need to find bank
357 setx L2_ERROR_STATUS_REGISTER, %g5, %g4
358 mov %g4, %o1 !copy to be used later
359 setx L2_LAST_ERROR_STATUS_REGISTER, %g5, %g6
360 mov 8, %o2
3611:
362read_l2_bank_esr_0x40:
363 ldx [%g4], %g7
364
365#ifdef ECC_CE
366 mov 1, %g2
367 sllx %g2, 42, %g2 !DAC
368 and %g2, %g7, %g3
369 cmp %g2, %g3
370 be %xcc, 1f
371 nop
372#endif
373#ifdef ECC_UE
374 mov 1, %g2
375 sllx %g2, 41, %g2 !DAU
376 and %g2, %g7, %g3
377 cmp %g2, %g3
378 be %xcc, 1f
379 nop
380#endif
381#ifdef CRC_RE
382 mov 1, %g2
383 sllx %g2, 38, %g2 !DSC
384 and %g2, %g7, %g3
385 cmp %g2, %g3
386 be %xcc, 1f
387 nop
388#endif
389#ifdef CRC_UE
390#ifdef CRC_SB
391 mov 1, %g2
392 sllx %g2, 37, %g2 !DSU
393 and %g2, %g7, %g3
394 cmp %g2, %g3
395 be %xcc, 1f
396 nop
397#endif
398#ifdef CRC_NB
399 mov 1, %g2
400 sllx %g2, 41, %g2 !DAU
401 and %g2, %g7, %g3
402 cmp %g2, %g3
403 be %xcc, 1f
404 nop
405#endif
406#endif
407#ifdef SCRUB_UE
408 mov 1, %g2
409 sllx %g2, 37, %g2 !DSU
410 and %g2, %g7, %g3
411 cmp %g2, %g3
412 be %xcc, 1f
413 nop
414#endif
415
416 add %g4, 0x40, %g4
417 dec %o2
418 brnz %o2,1b
419 nop
420 ba test_fail
421 nop
4221:
423! find which MCU esr is logged
424find_mcu_0x40:
425 sub %g4, %o1, %o2
426 and %o2, 0x180, %g2 !which MCU it is coming from
427 mov %g0, %g3
4281:
429 cmp %g2, %g3
430 be %xcc, 1f
431 nop
432 add %g3, 0x80, %g3
433 ba 1b
434 nop
4351:
436 udivx %g3, 0x80, %g3
437 setx 0x1000, %g5, %g1
438 mulx %g3, %g1, %g3
439 setx DRAM_ERROR_STATUS_REGISTER, %g5, %g6
440 add %g3, %g6, %g6
441
442read_mcu_esr_0x40:
443 ldx [%g6], %g7
444
445
446! if L2 writes data to MCU with UE in it, MCU marks it by inverting bits at 8221 for ECC,
447! so when MCU reads the data back from that address on future read requests, it will know
448! it already has UE error in it, known as poison syndrome. once L2 encounters the 0x8221 syndrome
449! it will continuously treat it as notdata, so we do a block store of all zeros
450! to the L2 line and a subsequent write/read to that address will then evict the zeros to memory
451! and the poison ECC bit will be wiped out
452
453check_mcu_esr_for_poison_syndrome_8221_0x40:
454 set 0xffff, %g2
455 and %g2, %g7, %g1
456 set 0x8221, %g2
457 cmp %g1, %g2
458 be %xcc, 4f
459 nop
460
461#ifdef ECC_CE
462 mov 1, %g2
463 sllx %g2, 61, %g2 !DAC
464 and %g2, %g7, %g1
465 cmp %g2, %g1
466 bne %xcc, test_fail
467 nop
468 setx 0xffff, %g5, %g2
469 and %g2, %g7, %g1
470 cmp %g0, %g1
471 be %xcc, test_fail
472 nop
473 setx DRAM_ERROR_RETRY_REGISTER, %g5, %g2
474 add %g3, %g2, %g2
475 ldx [%g2], %g1
476 !and %g1, 0x3, %g1
477 !cmp %g1, 2
478 !bne test_fail
479 !nop
480 setx VALID_BIT, %g5, %g1
481 stx %g1, [%g2]
482#endif
483#ifdef ECC_UE
484 mov 1, %g2
485 sllx %g2, 60, %g2 !DAU
486 and %g2, %g7, %g1
487 cmp %g2, %g1
488 be %xcc, 1f
489 nop
490 mov 1, %g2
491 sllx %g2, 57, %g2 !DBU
492 and %g2, %g7, %g1
493 cmp %g2, %g1
494 bne %xcc, test_fail
495 nop
4961:
497 setx 0xffff, %g5, %g2
498 and %g2, %g7, %g1
499 cmp %g0, %g1
500 be %xcc, test_fail
501 nop
502 mov 0x1f, %g2
503 sllx %g2, 56, %g2
504 and %g2, %o0, %g2
505 mov 16, %g1 !L2U
506 sllx %g1, 56, %g1
507 cmp %g2, %g1
508 bne %xcc, test_fail
509 nop
510 setx DRAM_ERROR_RETRY_REGISTER, %g5, %g2
511 add %g3, %g2, %g2
512 ldx [%g2], %g1
513 !and %g1, 0x3, %g1
514 !cmp %g1, 3
515 !bne test_fail
516 !nop
517 setx VALID_BIT, %g5, %g1
518 stx %g1, [%g2]
519#endif
520#ifdef CRC_RE
521 mov 1, %g2
522 sllx %g2, 54, %g2 !FBR
523 and %g2, %g7, %g1
524 cmp %g2, %g1
525 bne %xcc, test_fail
526 nop
527 setx DRAM_FBD_ERROR_SYNDROME_REGISTER, %g5, %g2
528 add %g3, %g2, %g2
529 ldx [%g2], %g1
530#ifdef CRC_NB
531 and %g1, 0x1, %g1
532#endif
533#ifdef CRC_SB
534 and %g1, 0x2, %g1
535#endif
536 cmp %g0, %g1
537 be test_fail
538 nop
539! MSA 12/04/06 setx VALID_BIT, %g5, %g1
540! Avoid SYND Clear in SB
541#ifndef CRC_SB
542! stx %g0, [%g2] ! MSA 12/04/06; SYND Reg is Write 0 to clear; 12/08/06: move it after AMB Reg Clear
543#endif
544
545#ifdef CRC_SB
546clear_amb_reg_0x40:
547 !First AMB Error Reg
548 !channel 0
549 setx 0x8400000900, %g5, %g3
550 set 0x190, %g4
551 stx %g4, [%g3]
552
553 setx 0x8400000908, %g5, %g3
554 set 0xff, %g4
555 stx %g4, [%g3]
556
557 !channel 1
558 setx 0x8400000900, %g5, %g3
559 set 0x8190, %g4
560 stx %g4, [%g3]
561
562 setx 0x8400000908, %g5, %g3
563 set 0xff, %g4
564 stx %g4, [%g3]
565
566 !Second AMB Error Reg
567 !channel 0
568 setx 0x8400000900, %g5, %g3
569 set 0x194, %g4
570 stx %g4, [%g3]
571
572 setx 0x8400000908, %g5, %g3
573 set 0xff, %g4
574 stx %g4, [%g3]
575
576 !channel 1
577 setx 0x8400000900, %g5, %g3
578 set 0x8194, %g4
579 stx %g4, [%g3]
580
581 setx 0x8400000908, %g5, %g3
582 set 0xff, %g4
583 stx %g4, [%g3]
584#endif
585
586! MSA 12/08/06
587#ifndef CRC_SB
588clear_fbd_Synd_reg_0x40_FBR: ! MSA 11/30/06
589 setx DRAM_FBD_ERROR_SYNDROME_REGISTER, %g5, %g2
590 stx %g0, [%g2]
591 stx %g0, [%g2]
592 ldx [%g2], %g5
593#endif
594#endif
595#ifdef CRC_UE
596 mov 1, %g2
597 sllx %g2, 55, %g2 !FBU
598 and %g2, %g7, %g1
599 cmp %g2, %g1
600 bne %xcc, test_fail
601 nop
602 setx DRAM_FBD_ERROR_SYNDROME_REGISTER, %g5, %g2
603 add %g3, %g2, %g2
604 ldx [%g2], %g1
605#ifdef CRC_NB
606 and %g1, 0x1, %g1
607#endif
608#ifdef CRC_SB
609 and %g1, 0x2, %g1
610#endif
611 cmp %g0, %g1
612 be test_fail
613 nop
614 setx VALID_BIT, %g5, %g1
615#ifndef CRC_SB
616! stx %g0, [%g2] ! MSA 12/08/06 : move it after AMB Reg Clear
617#endif
618
619#ifdef CRC_SB
620clear_amb_reg_0x40:
621 !First AMB Error Reg
622 !channel 0
623 setx 0x8400000900, %g5, %g3
624 set 0x190, %g4
625 stx %g4, [%g3]
626
627 setx 0x8400000908, %g5, %g3
628 set 0xff, %g4
629 stx %g4, [%g3]
630
631 !channel 1
632 setx 0x8400000900, %g5, %g3
633 set 0x8190, %g4
634 stx %g4, [%g3]
635
636 setx 0x8400000908, %g5, %g3
637 set 0xff, %g4
638 stx %g4, [%g3]
639
640 !Second AMB Error Reg
641 !channel 0
642 setx 0x8400000900, %g5, %g3
643 set 0x194, %g4
644 stx %g4, [%g3]
645
646 setx 0x8400000908, %g5, %g3
647 set 0xff, %g4
648 stx %g4, [%g3]
649
650 !channel 1
651 setx 0x8400000900, %g5, %g3
652 set 0x8194, %g4
653 stx %g4, [%g3]
654
655 setx 0x8400000908, %g5, %g3
656 set 0xff, %g4
657 stx %g4, [%g3]
658#endif
659! MSA 12/08/06
660#ifndef CRC_SB
661clear_fbd_Synd_reg_0x40_FBU: ! MSA 11/30/06
662 setx DRAM_FBD_ERROR_SYNDROME_REGISTER, %g5, %g2
663 stx %g0, [%g2]
664 stx %g0, [%g2]
665 ldx [%g2], %g5
666#endif
667#endif
668#ifdef SCRUB_UE
669 mov 1, %g2
670 sllx %g2, 58, %g2 !DSU
671 and %g2, %g7, %g1
672 cmp %g2, %g1
673 bne %xcc, test_fail
674 nop
675 setx 0xffff, %g5, %g2
676 and %g2, %g7, %g1
677 cmp %g0, %g1
678 be %xcc, test_fail
679 nop
680 setx DRAM_ERROR_ADDRESS_REGISTER, %g5, %g2
681 add %g3, %g2, %g2
682 ldx [%g2], %g1
683#endif
684
685
686! we need to prefetch ICE (invalidate cache entry) for instruction that had uncorrectable error.
687! eventually we need to re-fetch/retrieve the orig. instruction with no errors because we need it
688! as it is part of program code. prefetch ice will require doing prefetch of L2 line with prefetch_fcn
689! of 0x18 (which is N2 implementation dependent).
690! doing prefetch ICE means we will wipe out the entry in L2 cacheline with the dirty bit unset
691! so we can then re-fetch the instruction after core issues a retry specified at the end of this trap
692! handler routine. also note that bits [39:37] has to be 011 and way,index,bank will be
693! inside bits [21:18],[17:9],[8:6]
694! as such, after we clear out all of the L2 and MCU error status registers, we will issue a retry
695! which means we will fetch the instruction once again, assuming that this time verilog injector
696! did not inject an uncorrectable error. that is being decided within the injector where we do NOT inject on
697! every read (or write) transaction that comes to MCU
698
6992:
700prefetch_0x40:
701 setx L2_ERROR_ADDRESS_REGISTER, %g5, %o3
702 ldx [%o3+%o2], %o4
703 setx 0x3ffc0, %g5, %g2
704 and %o4, %g2, %g2
705 setx PREFETCH_ICE_BASE_ADDRESS, %g5, %g3
706 add %g2, %g3, %g3
707 mov 1, %g1
708 sllx %g1, 18, %g1
709 mov 16, %g2
7101:
711 prefetch [%g3], 0x18
712 add %g3, %g1, %g3
713 dec %g2
714 brnz %g2,1b
715 nop
716 ba 3f
717 nop
718
719! do 8 block stores to clear out data in L2 cacheline, we will issue a retry at the end
720! of trap handler because we have wiped out the orig. "uncorrectable" data with all zeros.
721! at least, all zeros means it has no more UE associated with it, we will be
722! fine the next time around when a write/read comes to that address
723
7244:
725do_8_block_stores_0x40:
726 setx L2_ERROR_ADDRESS_REGISTER, %g5, %g2
727 ldx [%g2+%o2], %g1
728 setx 0xffffffffc0, %g5, %g2
729 and %g2, %g1, %g1
730 mov 8, %o1
7311:
732 stx %g0, [%g1]
733 add %g1, 8, %g1
734 dec %o1
735 brnz %o1,1b
736 nop
737
7383:
739clear_l2_bank_esr_0x40:
740 mov 8, %o1
741 setx L2_ESR_WRITE_1_TO_CLEAR, %g5, %g3
742 setx L2_ERROR_STATUS_REGISTER, %g5, %g4
7431:
744 stx %g3, [%g4]
745 add %g4, 0x40, %g4
746 dec %o1
747 brnz %o1,1b
748 nop
749clear_mcu_esr_0x40:
750 mov 4, %o1
751 setx DRAM_ESR_WRITE_1_TO_CLEAR, %g5, %g3
752 setx DRAM_ERROR_STATUS_REGISTER, %g5, %g6
753 set 0x1000, %g2
7541:
755 stx %g3, [%g6]
756 add %g6, %g2, %g6
757 dec %o1
758 brnz %o1,1b
759 nop
760
761 cmp %o5,1
762 be 1f
763 nop
764 retry
765 nop
7661:
767 done
768 nop
769
770! ***************************************************************************
771
772
773!My_H_HT0_Instruction_Access_MMU_Error_0x71:
774! inc %o7 !keep count of traps taken
775
776!read_core_isfsr_0x71:
777! clr %g5 !use as intermediate register for setx
778! mov 0x18, %g2
779! ldxa [%g2] 0x50, %g1 !ISFSR
780! mov 0x7, %g3
781! and %g1, %g3, %g3
782! cmp %g3, 6
783! ble %xcc, 1f
784! nop
785! ba test_fail
786! nop
787
788
789! ***************************************************************************
790
791
792! ### ###
793! # # # # # #
794! # # # # # # #####
795! # # ## # # #
796! # # ## # # ######
797! # # # # # # # #
798! ### # # ### ######
799
800
801My_H_HT0_Instruction_access_error_0x0a:
802 inc %o7 !keep count of traps taken
803 mov %g0,%o5
804
805read_core_isfsr_0x0a:
806 clr %g5 !use as intermediate register for setx
807 mov 0x18, %g2
808 ldxa [%g2] 0x50, %g1 !ISFSR
809 ldxa [%g0] 0x4c, %g4 !DESR
810 mov 0x7, %g3
811 and %g1, %g3, %g3
812 cmp %g3, 1
813 be %xcc, 2f ! branch normal, first check MCU esr, then check L2 esr
814 nop
815 cmp %g3, 2
816 be %xcc, 3f ! branch if you see notdata in DESR, clear L2 notdata register
817 nop
818 ba test_fail
819 nop
820
8213:
822clear_l2_notdata_error_register_0x0a:
823 mov 1,%o5
824 mov 8, %o1
825 setx L2_NOTDATA_REGISTER_WRITE_1_TO_CLEAR, %g5, %g3
826 setx L2_NOTDATA_REGISTER, %g5, %g4
8271:
828 stx %g3, [%g4]
829 add %g4, 0x40, %g4
830 dec %o1
831 brnz %o1,1b
832 nop
833
834 ba 2f ! MSA: 12/04/06; it was bypassing all check to almost end of the handler with "ba 3f"
835 nop
836
8372:
838 stxa %g0, [%g2] 0x50
839! find which MCU logged error
840find_mcu_0x0a:
841 rdpr %tpc, %g1
842 mov %g1,%o2 !save a copy
843 and %g1, 0x180, %g2 !which MCU it is coming from
844 mov %g0, %g3
8451:
846 cmp %g2, %g3
847 be %xcc, 1f
848 nop
849 add %g3, 0x80, %g3
850 ba 1b
851 nop
8521:
853 udivx %g3, 0x80, %g3
854 setx 0x1000, %g5, %g1
855 mulx %g3, %g1, %g3
856 setx DRAM_ERROR_STATUS_REGISTER, %g5, %g6
857 add %g3, %g6, %g6
858
859read_mcu_esr_0x0a:
860 ldx [%g6], %g7
861
862#ifdef ECC_UE
863 mov 1, %g2
864 sllx %g2, 60, %g2 !DAU
865 and %g2, %g7, %g1
866 cmp %g2, %g1
867 bne %xcc, test_fail
868 nop
869 setx 0xffff, %g5, %g2
870 and %g2, %g7, %g1
871 cmp %g0, %g1
872 be %xcc, test_fail
873 nop
874 setx DRAM_ERROR_RETRY_REGISTER, %g5, %g2
875 add %g3, %g2, %g2
876 ldx [%g2], %g1
877 !and %g1, 0x3, %g1
878 !cmp %g1, 3
879 !bne test_fail
880 !nop
881 setx VALID_BIT, %g5, %g1
882 stx %g1, [%g2]
883#endif
884#ifdef CRC_UE
885 mov 1, %g2
886 sllx %g2, 55, %g2 !FBU
887 and %g2, %g7, %g1
888 cmp %g2, %g1
889 bne %xcc, test_fail
890 nop
891 setx DRAM_FBD_ERROR_SYNDROME_REGISTER, %g5, %g2
892 add %g3, %g2, %g2
893 ldx [%g2], %g1
894#ifdef CRC_NB
895 and %g1, 0x1, %g1
896#endif
897#ifdef CRC_SB
898 and %g1, 0x2, %g1
899#endif
900 cmp %g0, %g1
901 be test_fail
902 nop
903 setx VALID_BIT, %g5, %g1
904#ifndef CRC_SB
905! stx %g0, [%g2] ! MSA 12/08/06: moving at after AMB Reg Clear
906#endif
907
908#ifdef CRC_SB
909clear_amb_reg_0x0a:
910 !First AMB Error Reg
911 !channel 0
912 setx 0x8400000900, %g5, %g3
913 set 0x190, %g4
914 stx %g4, [%g3]
915
916 setx 0x8400000908, %g5, %g3
917 set 0xff, %g4
918 stx %g4, [%g3]
919
920 !channel 1
921 setx 0x8400000900, %g5, %g3
922 set 0x8190, %g4
923 stx %g4, [%g3]
924
925 setx 0x8400000908, %g5, %g3
926 set 0xff, %g4
927 stx %g4, [%g3]
928
929 !Second AMB Error Reg
930 !channel 0
931 setx 0x8400000900, %g5, %g3
932 set 0x194, %g4
933 stx %g4, [%g3]
934
935 setx 0x8400000908, %g5, %g3
936 set 0xff, %g4
937 stx %g4, [%g3]
938
939 !channel 1
940 setx 0x8400000900, %g5, %g3
941 set 0x8194, %g4
942 stx %g4, [%g3]
943
944 setx 0x8400000908, %g5, %g3
945 set 0xff, %g4
946 stx %g4, [%g3]
947#endif
948! MSA 12/08/06
949#ifndef CRC_SB
950clear_fbd_Synd_reg_0x0a: ! MSA 11/30/06
951 setx DRAM_FBD_ERROR_SYNDROME_REGISTER, %g5, %g2
952 stx %g0, [%g2]
953 stx %g0, [%g2]
954 ldx [%g2], %g5
955#endif
956#endif
957
958! now find which L2 bank logged error
9594:
960find_l2_bank_0x0a:
961 and %o2, 0x1c0, %g2 !which L2 bank it is coming from
962 mov %g0, %g3
9631:
964 cmp %g2, %g3
965 be %xcc, 1f
966 nop
967 add %g3, 0x40, %g3
968 ba 1b
969 nop
9701:
971 setx L2_ERROR_STATUS_REGISTER, %g5, %g4
972 add %g3, %g4, %g4
973
974read_l2_bank_esr_0x0a:
975 ldx [%g4], %g7
976
977#ifdef ECC_UE
978 mov 1, %g2
979 sllx %g2, 41, %g2 !DAU
980 and %g2, %g7, %g3
981 cmp %g2, %g3
982 bne %xcc, test_fail
983 nop
984#endif
985#ifdef CRC_UE
986! CRC unrecoverable error gives DSU if on SB, but DAU if on NB
987#ifdef CRC_SB
988 mov 1, %g2
989 sllx %g2, 37, %g2 !DSU
990 and %g2, %g7, %g3
991 cmp %g2, %g3
992 bne %xcc, test_fail
993 nop
994#endif
995#ifdef CRC_NB
996 mov 1, %g2
997 sllx %g2, 41, %g2 !DAU
998 and %g2, %g7, %g3
999 cmp %g2, %g3
1000 bne %xcc, test_fail
1001 nop
1002#endif
1003#endif
1004
1005! we need to prefetch ICE (invalidate cache entry) for instruction that had uncorrectable error.
1006! eventually we need to re-fetch/retrieve the orig. instruction with no errors because we need it
1007! as it is part of program code. prefetch ice will require doing prefetch of L2 line with prefetch_fcn
1008! of 0x18 (which is N2 implementation dependent).
1009! doing prefetch ICE means we will wipe out the entry in L2 cacheline with the dirty bit unset
1010! so we can then re-fetch the instruction after core issues a retry specified at the end of this trap
1011! handler routine. also note that bits [39:37] has to be 011 and way,index,bank will be
1012! inside bits [21:18],[17:9],[8:6]
1013! as such, after we clear out all of the L2 and MCU error status registers, we will issue a retry
1014! which means we will fetch the instruction once again, assuming that this time verilog injector
1015! did not inject an uncorrectable error. that is being decided within the injector where we do NOT inject on
1016! every read (or write) transaction that comes to MCU
1017
1018prefetch_0x0a:
1019 setx PREFETCH_ICE_BASE_ADDRESS, %g5, %g3
1020 setx 0x3ffc0, %g5, %g2
1021 and %o2, %g2, %g2
1022 add %g2, %g3, %g3
1023 mov 1, %g1
1024 sllx %g1, 18, %g1
1025 mov 16, %g2
10261:
1027 prefetch [%g3], 0x18
1028 add %g3, %g1, %g3
1029 dec %g2
1030 brnz %g2,1b
1031 nop
1032
10333:
1034clear_l2_bank_esr_0x0a:
1035 mov 8, %o1
1036 setx L2_ESR_WRITE_1_TO_CLEAR, %g5, %g3
1037 setx L2_ERROR_STATUS_REGISTER, %g5, %g4
10381:
1039 stx %g3, [%g4]
1040 add %g4, 0x40, %g4
1041 dec %o1
1042 brnz %o1,1b
1043 nop
1044clear_mcu_esr_0x0a:
1045 mov 4, %o1
1046 setx DRAM_ESR_WRITE_1_TO_CLEAR, %g5, %g3
1047 setx DRAM_ERROR_STATUS_REGISTER, %g5, %g6
1048 set 0x1000, %g2
10491:
1050 stx %g3, [%g6]
1051 add %g6, %g2, %g6
1052 dec %o1
1053 brnz %o1,1b
1054 nop
1055
1056 cmp %o5,1
1057 be 1f
1058 nop
1059 retry
1060 nop
10611:
1062 done
1063 nop
1064
1065! ***************************************************************************
1066
1067
1068!My_H_HT0_Data_Access_MMU_Error_0x72:
1069! inc %o7 !keep count of traps taken
1070
1071!read_core_dsfsr_0x72:
1072! clr %g5 !use as intermediate register for setx
1073! mov 0x18, %g2
1074! ldxa [%g2] 0x58, %g1 !DSFSR
1075! mov 0xf, %g3
1076! and %g1, %g3, %g3
1077! cmp %g3, 6
1078! ble %xcc, 1f
1079! nop
1080! ba test_fail
1081! nop
1082
1083
1084! ***************************************************************************
1085
1086
1087! ### ##### #####
1088! # # # # # #
1089! # # # # # #
1090! # # ## ##### #####
1091! # # ## # #
1092! # # # # # #
1093! ### # # ##### ######
1094
1095
1096
1097My_H_HT0_Data_access_error_0x32:
1098 inc %o7 !keep count of traps taken
1099 mov %g0,%o5
1100
1101read_core_dsfsr_0x32:
1102 clr %g5 !use as intermediate register for setx
1103 mov 0x18, %g2
1104 ldxa [%g2] 0x58, %g1 !DSFSR
1105 ldxa [%g0] 0x4c, %g4 !DESR
1106 mov 0xf, %g3
1107 and %g1, %g3, %g3
1108 cmp %g3, 1
1109 be %xcc, 2f ! branch normal, first check L2 esr, then check MCU esr
1110 nop
1111 cmp %g3, 2
1112 be %xcc, 4f ! branch if you see notdata in DESR, clear L2 notdata register
1113 nop
1114 ba test_fail
1115 nop
1116
11174:
1118clear_l2_notdata_error_register_0x32:
1119 mov 1,%o5
1120 mov 8, %o1
1121 setx L2_NOTDATA_REGISTER_WRITE_1_TO_CLEAR, %g5, %g3
1122 setx L2_NOTDATA_REGISTER, %g5, %g4
11231:
1124 stx %g3, [%g4]
1125 add %g4, 0x40, %g4
1126 dec %o1
1127 brnz %o1,1b
1128 nop
1129
1130 ba 2f ! MSA: 12/04/06; it was bypassing all check to almost end of the handler with "ba 3f"
1131 nop
1132
11332:
1134 stxa %g0, [%g2] 0x58
1135! find which L2 bank logged error
1136find_l2_bank_0x32:
1137 setx L2_ERROR_STATUS_REGISTER, %g5, %g4
1138 mov %g4, %o0 !copy to be used later
1139 setx L2_LAST_ERROR_STATUS_REGISTER, %g5, %g6
1140 mov 8, %o1
11411:
1142read_l2_bank_esr_0x32:
1143 ldx [%g4], %g7
1144
1145#ifdef ECC_UE
1146 mov 1, %g2
1147 sllx %g2, 41, %g2 !DAU
1148 and %g2, %g7, %g3
1149 cmp %g2, %g3
1150 be %xcc, 1f
1151 nop
1152#endif
1153#ifdef CRC_UE
1154! CRC unrecoverable error gives DSU if on SB, but DAU if on NB
1155#ifdef CRC_SB
1156 mov 1, %g2
1157 sllx %g2, 37, %g2 !DSU
1158 and %g2, %g7, %g3
1159 cmp %g2, %g3
1160 be %xcc, 1f
1161 nop
1162#endif
1163#ifdef CRC_NB
1164 mov 1, %g2
1165 sllx %g2, 41, %g2 !DAU
1166 and %g2, %g7, %g3
1167 cmp %g2, %g3
1168 be %xcc, 1f
1169 nop
1170#endif
1171#endif
1172
1173 add %g4, 0x40, %g4
1174 dec %o1
1175 brnz %o1,1b
1176 nop
1177 ba test_fail
1178 nop
1179! now find which MCU logged error
11801:
1181find_mcu_0x32:
1182 sub %g4, %o0, %o1
1183 and %o1, 0x180, %g2 !which MCU it is coming from
1184 mov %g0, %g3
11851:
1186 cmp %g2, %g3
1187 be %xcc, 1f
1188 nop
1189 add %g3, 0x80, %g3
1190 ba 1b
1191 nop
11921:
1193 udivx %g3, 0x80, %g3
1194 setx 0x1000, %g5, %g1
1195 mulx %g3, %g1, %g3
1196 setx DRAM_ERROR_STATUS_REGISTER, %g5, %g6
1197 add %g3, %g6, %g6
1198
1199read_mcu_esr_0x32:
1200 ldx [%g6], %g7
1201
1202#ifdef ECC_UE
1203 mov 1, %g2
1204 sllx %g2, 60, %g2 !DAU
1205 and %g2, %g7, %g1
1206 cmp %g2, %g1
1207 be %xcc, 1f
1208 nop
1209 mov 1, %g2
1210 sllx %g2, 57, %g2 !DBU
1211 and %g2, %g7, %g1
1212 cmp %g2, %g1
1213 bne %xcc, test_fail
1214 nop
12151:
1216 setx 0xffff, %g5, %g2
1217 and %g2, %g7, %g1
1218 cmp %g0, %g1
1219 be %xcc, test_fail
1220 nop
1221 setx DRAM_ERROR_RETRY_REGISTER, %g5, %g2
1222 add %g3, %g2, %g2
1223 ldx [%g2], %g1
1224 !and %g1, 0x3, %g1
1225 !cmp %g1, 3
1226 !bne test_fail
1227 !nop
1228 setx VALID_BIT, %g5, %g1
1229 stx %g1, [%g2]
1230#endif
1231#ifdef CRC_UE
1232 mov 1, %g2
1233 sllx %g2, 55, %g2 !FBU
1234 and %g2, %g7, %g1
1235 cmp %g2, %g1
1236 bne %xcc, test_fail
1237 nop
1238 setx DRAM_FBD_ERROR_SYNDROME_REGISTER, %g5, %g2 !clear valid bit for FBD
1239 add %g3, %g2, %g2
1240 ldx [%g2], %g1
1241#ifdef CRC_NB
1242 and %g1, 0x1, %g1
1243#endif
1244#ifdef CRC_SB
1245 and %g1, 0x2, %g1
1246#endif
1247 cmp %g0, %g1
1248 be test_fail
1249 nop
1250 setx VALID_BIT, %g5, %g1
1251#ifndef CRC_SB
1252! stx %g0, [%g2] ! MSA 12/08/06: moving it after AMB Reg clearing
1253#endif
1254
1255#ifdef CRC_SB
1256clear_amb_reg_0x32:
1257 !First AMB Error Reg
1258 !channel 0
1259 setx 0x8400000900, %g5, %g3
1260 set 0x190, %g4
1261 stx %g4, [%g3]
1262
1263 setx 0x8400000908, %g5, %g3
1264 set 0xff, %g4
1265 stx %g4, [%g3]
1266
1267 !channel 1
1268 setx 0x8400000900, %g5, %g3
1269 set 0x8190, %g4
1270 stx %g4, [%g3]
1271
1272 setx 0x8400000908, %g5, %g3
1273 set 0xff, %g4
1274 stx %g4, [%g3]
1275
1276 !Second AMB Error Reg
1277 !channel 0
1278 setx 0x8400000900, %g5, %g3
1279 set 0x194, %g4
1280 stx %g4, [%g3]
1281
1282 setx 0x8400000908, %g5, %g3
1283 set 0xff, %g4
1284 stx %g4, [%g3]
1285
1286 !channel 1
1287 setx 0x8400000900, %g5, %g3
1288 set 0x8194, %g4
1289 stx %g4, [%g3]
1290
1291 setx 0x8400000908, %g5, %g3
1292 set 0xff, %g4
1293 stx %g4, [%g3]
1294#endif
1295! MSA 12/08/06
1296#ifndef CRC_SB
1297clear_fbd_Synd_reg_0x32: ! MSA 11/30/06
1298 setx DRAM_FBD_ERROR_SYNDROME_REGISTER, %g5, %g2
1299 stx %g0, [%g2]
1300 stx %g0, [%g2]
1301 ldx [%g2], %g5
1302#endif
1303#endif
1304
1305
1306! do 8 block stores to clear out data in L2 cacheline, we will issue a retry at the end
1307! of trap handler because we have wiped out the orig. "uncorrectable" data with all zeros.
1308! at least, all zeros means it has no more UE associated with it, so we will be
1309! fine the next time around when a write/read comes to that address
1310
13112:
1312do_8_block_stores_0x32:
1313 setx L2_ERROR_ADDRESS_REGISTER, %g5, %g2
1314 ldx [%g2+%o1], %g1
1315 setx 0xffffffffc0, %g5, %g2
1316 and %g2, %g1, %g1
1317 mov 8, %o1
13181:
1319 stx %g0, [%g1]
1320 add %g1, 8, %g1
1321 dec %o1
1322 brnz %o1,1b
1323 nop
1324
13253:
1326clear_l2_bank_esr_0x32:
1327 mov 8, %o1
1328 setx L2_ESR_WRITE_1_TO_CLEAR, %g5, %g3
1329 setx L2_ERROR_STATUS_REGISTER, %g5, %g4
13301:
1331 stx %g3, [%g4]
1332 add %g4, 0x40, %g4
1333 dec %o1
1334 brnz %o1,1b
1335 nop
1336clear_mcu_esr_0x32:
1337 mov 4, %o1
1338 setx DRAM_ESR_WRITE_1_TO_CLEAR, %g5, %g3
1339 setx DRAM_ERROR_STATUS_REGISTER, %g5, %g6
1340 set 0x1000, %g2
13411:
1342 stx %g3, [%g6]
1343 add %g6, %g2, %g6
1344 dec %o1
1345 brnz %o1,1b
1346 nop
1347
1348 cmp %o5,1
1349 be 1f
1350 nop
1351 retry
1352 nop
13531:
1354 done
1355 nop
1356
1357! ***************************************************************************
1358
1359! ####### # # ######
1360! # ## # # #
1361! # # # # # #
1362! ##### # # # # #
1363! # # # # # #
1364! # # ## # #
1365! ####### # # ######
1366
1367! ***************************************************************************