Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: tlu_custom_trap_extensions.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 | SECTION .HTRAPS | |
39 | .global wdog_2_ext | |
40 | .global retry_with_base_tba | |
41 | .global resolve_bad_tte | |
42 | ||
43 | .text | |
44 | resolve_bad_tte: | |
45 | !if pc[63:15] matches tba, then relocated handler .. | |
46 | rdpr %tpc, %r4 | |
47 | check_tba: | |
48 | set 0x7fff, %r5 | |
49 | andn %r4, %r5, %r5 !clear 14:0 | |
50 | rdpr %tba, %r6 !compare pc[63:15] to tba | |
51 | cmp %r5, %r6 | |
52 | bne,a not_a_reloc_handler | |
53 | andn %r27, 0x1f, %r6 | |
54 | retry_with_base_tba: | |
55 | best_set_reg(TRAP_BASE_VA, %r3, %r5) | |
56 | cmp %r4, %r5 | |
57 | bz htrap_5_ext_done | |
58 | set 0x7fff, %r3 | |
59 | and %r4, %r3, %r4 | |
60 | or %r5, %r4, %r4 | |
61 | wrpr %r4, %tpc | |
62 | rdpr %tnpc, %r4 | |
63 | and %r4, %r3, %r4 | |
64 | or %r5, %r4, %r4 | |
65 | wrpr %r4, %tnpc | |
66 | retry | |
67 | ||
68 | !assume %r27 is where we came from .. | |
69 | not_a_reloc_handler: | |
70 | stxa %r27, [%r6] 0x57 | |
71 | add %r27, 8, %r27 | |
72 | wrpr %r27, %tnpc | |
73 | done | |
74 | ||
75 | htrap_5_ext: | |
76 | rd %pc, %l2 | |
77 | inc %l3 | |
78 | add %l2, htrap_5_ext_done-htrap_5_ext, %l2 | |
79 | rdpr %tl, %l3 | |
80 | rdpr %tstate, %l4 | |
81 | rdhpr %htstate, %l5 | |
82 | or %l5, 0x4, %l5 | |
83 | inc %l3 | |
84 | wrpr %l3, %tl | |
85 | wrpr %l2, %tpc | |
86 | add %l2, 4, %l2 | |
87 | wrpr %l2, %tnpc | |
88 | wrpr %l4, %tstate | |
89 | wrhpr %l5, %htstate | |
90 | retry | |
91 | htrap_5_ext_done: | |
92 | done | |
93 | ||
94 | wdog_2_ext: | |
95 | mov 0x1f, %l1 | |
96 | stxa %l1, [%g0] ASI_LSU_CTL_REG | |
97 | ! If TT != 2, then goto trap handler | |
98 | rdpr %tt, %l1 | |
99 | cmp %l1, 0x2 | |
100 | bne wdog_2_goto_handler | |
101 | nop | |
102 | ! else done | |
103 | done | |
104 | wdog_2_goto_handler: | |
105 | rdhpr %htstate, %l3 | |
106 | and %l3, 0x4, %l3 ! If previously in hpriv mode, go to hpriv | |
107 | brnz,a %l3, wdog_2_goto_handler_1 | |
108 | rdhpr %htba, %l3 | |
109 | srlx %l1, 7, %l3 ! Send priv sw traps to priv mode .. | |
110 | cmp %l3, 0x2 ! 0x2 = priv sw trap, 0x3=hpriv sw trap .. | |
111 | be,a wdog_2_goto_handler_1 | |
112 | rdpr %tba, %l3 | |
113 | rdhpr %htba, %l3 | |
114 | wdog_2_goto_handler_1: | |
115 | sllx %l1, 5, %l1 | |
116 | add %l1, %l3, %l3 | |
117 | jmp %l3 | |
118 | nop | |
119 | ||
120 | ||
121 | ! Red mode other reset handler | |
122 | ! Get htba, and tt and make trap address | |
123 | ! Jump to trap handler .. | |
124 | ||
125 | SECTION .RED_SEC | |
126 | .global red_other_ext | |
127 | .global wdog_red_ext | |
128 | .text | |
129 | red_other_ext: | |
130 | ! IF TL=6, shift stack by one .. | |
131 | rdpr %tl, %l1 | |
132 | cmp %l1, 6 | |
133 | be start_tsa_shift | |
134 | nop | |
135 | ||
136 | continue_red_other: | |
137 | mov 0x1f, %l1 | |
138 | stxa %l1, [%g0] ASI_LSU_CTL_REG | |
139 | ||
140 | rdpr %tt, %l1 | |
141 | ||
142 | rdhpr %htstate, %l2 | |
143 | and %l2, 0x4, %l2 ! If previously in hpriv mode, go to hpriv | |
144 | brnz,a %l2, red_goto_handler | |
145 | rdhpr %htba, %l2 | |
146 | srlx %l1, 7, %l2 ! Send priv sw traps to priv mode .. | |
147 | cmp %l2, 0x2 ! 0x2 = priv sw trap, 0x3=hpriv sw trap .. | |
148 | be,a red_goto_handler | |
149 | rdpr %tba, %l2 | |
150 | rdhpr %htba, %l2 | |
151 | red_goto_handler: | |
152 | ||
153 | sllx %l1, 5, %l1 | |
154 | add %l1, %l2, %l2 | |
155 | rdhpr %htstate, %l1 | |
156 | andn %l1, 0x20, %l1 | |
157 | wrhpr %g0, %l1, %htstate | |
158 | rdhpr %hpstate, %l1 | |
159 | jmp %l2 | |
160 | wrhpr %l1, 0x20, %hpstate | |
161 | nop | |
162 | ||
163 | wdog_red_ext: | |
164 | ! Shift stack down by 1 ... | |
165 | rdpr %tl, %l1 | |
166 | cmp %l1, 6 | |
167 | bl wdog_end | |
168 | start_tsa_shift: | |
169 | mov 0x2, %l2 | |
170 | ||
171 | tsa_shift: | |
172 | wrpr %l2, %tl | |
173 | rdpr %tt, %l3 | |
174 | rdpr %tpc, %l4 | |
175 | rdpr %tnpc, %l5 | |
176 | rdpr %tstate, %l6 | |
177 | rdhpr %htstate, %l7 | |
178 | dec %l2 | |
179 | wrpr %l2, %tl | |
180 | wrpr %l3, %tt | |
181 | wrpr %l4, %tpc | |
182 | wrpr %l5, %tnpc | |
183 | wrpr %l6, %tstate | |
184 | wrhpr %l7, %htstate | |
185 | add %l2, 2, %l2 | |
186 | cmp %l2, %l1 | |
187 | ble tsa_shift | |
188 | nop | |
189 | tsa_shift_done: | |
190 | dec %l1 | |
191 | wrpr %l1, %tl | |
192 | ||
193 | wdog_end: | |
194 | ! If TT != 2, then goto trap handler | |
195 | rdpr %tt, %l1 | |
196 | ||
197 | cmp %l1, 0x2 | |
198 | bne continue_red_other | |
199 | nop | |
200 | ! else done | |
201 | mov 0x1f, %l1 | |
202 | stxa %l1, [%g0] ASI_LSU_CTL_REG | |
203 | done | |
204 | ||
205 |