Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / diag / assembly / include / tlu_htraps_ext.s
CommitLineData
86530b38
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: tlu_htraps_ext.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*/
38resolve_bad_tte:
39 !if pc[63:15] matches tba, then relocated handler ..
40 rdpr %tpc, %r4
41check_tba:
42 set 0x7fff, %r5
43 andn %r4, %r5, %r5 !clear 14:0
44 rdpr %tba, %r6 !compare pc[63:15] to tba
45 cmp %r5, %r6
46 bne,a not_a_reloc_handler
47 andn %r27, 0x1f, %r6
48retry_with_base_tba:
49 best_set_reg(TRAP_BASE_VA, %r3, %r5)
50 cmp %r4, %r5
51 bz htrap_5_ext_done
52 set 0x7fff, %r3
53 and %r4, %r3, %r4
54 or %r5, %r4, %r4
55 wrpr %r4, %tpc
56 rdpr %tnpc, %r4
57 and %r4, %r3, %r4
58 or %r5, %r4, %r4
59 wrpr %r4, %tnpc
60 retry
61
62 !assume %r27 is where we came from ..
63not_a_reloc_handler:
64 stxa %r27, [%r6] 0x57
65 add %r27, 8, %r27
66 wrpr %r27, %tnpc
67 done
68
69htrap_5_ext:
70 rd %pc, %l2
71 inc %l3
72 add %l2, htrap_5_ext_done-htrap_5_ext, %l2
73 rdpr %tl, %l3
74 rdpr %tstate, %l4
75 rdhpr %htstate, %l5
76 or %l5, 0x4, %l5
77 inc %l3
78 wrpr %l3, %tl
79 wrpr %l2, %tpc
80 wrpr %l4, %tstate
81 wrhpr %l5, %htstate
82 retry
83htrap_5_ext_done:
84 done
85
86wdog_2_ext:
87 mov 0x1f, %l1
88 stxa %l1, [%g0] ASI_LSU_CTL_REG
89 ! If TT != 2, then goto trap handler
90 rdpr %tt, %l1
91 cmp %l1, 0x2
92 bne wdog_2_goto_handler
93 nop
94 ! else done
95 done
96wdog_2_goto_handler:
97 rdhpr %htstate, %l3
98 and %l3, 0x4, %l3 ! If previously in hpriv mode, go to hpriv
99 brnz,a %l3, wdog_2_goto_handler_1
100 rdhpr %htba, %l3
101 srlx %l1, 7, %l3 ! Send priv sw traps to priv mode ..
102 cmp %l3, 0x2 ! 0x2 = priv sw trap, 0x3=hpriv sw trap ..
103 be,a wdog_2_goto_handler_1
104 rdpr %tba, %l3
105 rdhpr %htba, %l3
106wdog_2_goto_handler_1:
107 sllx %l1, 5, %l1
108 add %l1, %l3, %l3
109 jmp %l3
110 nop
111