Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * Hypervisor Software File: traps.s | |
5 | * | |
6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
7 | * | |
8 | * - Do no alter or remove copyright notices | |
9 | * | |
10 | * - Redistribution and use of this software in source and binary forms, with | |
11 | * or without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistribution of source code must retain the above copyright notice, | |
15 | * this list of conditions and the following disclaimer. | |
16 | * | |
17 | * - Redistribution in binary form must reproduce the above copyright notice, | |
18 | * this list of conditions and the following disclaimer in the | |
19 | * documentation and/or other materials provided with the distribution. | |
20 | * | |
21 | * Neither the name of Sun Microsystems, Inc. or the names of contributors | |
22 | * may be used to endorse or promote products derived from this software | |
23 | * without specific prior written permission. | |
24 | * | |
25 | * This software is provided "AS IS," without a warranty of any kind. | |
26 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
27 | * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
28 | * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
29 | * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
30 | * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
31 | * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
32 | * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
33 | * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
34 | * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
35 | * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
36 | * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
37 | * | |
38 | * You acknowledge that this software is not designed, licensed or | |
39 | * intended for use in the design, construction, operation or maintenance of | |
40 | * any nuclear facility. | |
41 | * | |
42 | * ========== Copyright Header End ============================================ | |
43 | */ | |
44 | /* | |
45 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
46 | * Use is subject to license terms. | |
47 | */ | |
48 | ||
49 | .ident "@(#)traps.s 1.10 07/04/22 SMI" | |
50 | ||
51 | .file "trap.s" | |
52 | ||
53 | #include <sys/privregs.h> | |
54 | #include <sys/asm_linkage.h> | |
55 | #include <hypervisor.h> | |
56 | #include <sys/stack.h> | |
57 | ||
58 | #define NWINDOWS 8 | |
59 | ||
60 | #if defined(lint) | |
61 | void | |
62 | watchdog(void) | |
63 | { | |
64 | } | |
65 | #else | |
66 | ENTRY(watchdog) | |
67 | mov 1, %o0 | |
68 | mov API_EXIT, %o5 | |
69 | ta CORE_TRAP | |
70 | illtrap | |
71 | SET_SIZE(watchdog) | |
72 | #endif /* lint */ | |
73 | ||
74 | #if defined(lint) | |
75 | void | |
76 | xir(void) | |
77 | { | |
78 | } | |
79 | #else | |
80 | ENTRY(xir) | |
81 | mov 2, %o0 | |
82 | mov API_EXIT, %o5 | |
83 | ta CORE_TRAP | |
84 | illtrap | |
85 | SET_SIZE(xir) | |
86 | #endif /* lint */ | |
87 | ||
88 | #if defined(lint) | |
89 | void | |
90 | __badtrap(void) | |
91 | { | |
92 | } | |
93 | #else | |
94 | ENTRY(__badtrap) | |
95 | save %sp, -SA(MINFRAME+(30*8)), %sp ! Room for uint64_t n[30] | |
96 | ||
97 | rdpr %tpc, %o0; stx %o0, [%o6+STACK_BIAS+MINFRAME+(8*24)] ! %TPC | |
98 | rdpr %tnpc, %o0; stx %o0, [%o6+STACK_BIAS+MINFRAME+(8*25)] ! %TNPC | |
99 | rdpr %tstate, %o0; stx %o0, [%o6+STACK_BIAS+MINFRAME+(8*26)] ! %TSTATE | |
100 | rdpr %tl, %o0; stb %o0, [%o6+STACK_BIAS+MINFRAME+(8*27)+0] ! %TL | |
101 | rdpr %tt, %o0; stb %o0, [%o6+STACK_BIAS+MINFRAME+(8*27)+1] ! %TT | |
102 | rdpr %pil, %o0; stb %o0, [%o6+STACK_BIAS+MINFRAME+(8*27)+2] ! %PIL | |
103 | rdpr %gl, %o0; stb %o0, [%o6+STACK_BIAS+MINFRAME+(8*27)+3] ! %GL | |
104 | ||
105 | cmp %o0, 2 | |
106 | bne,a 0f | |
107 | stx %g0, [%o6+STACK_BIAS+MINFRAME+(8*16)] | |
108 | stx %g1, [%o6+STACK_BIAS+MINFRAME+(8*17)] | |
109 | stx %g2, [%o6+STACK_BIAS+MINFRAME+(8*18)] | |
110 | stx %g3, [%o6+STACK_BIAS+MINFRAME+(8*19)] | |
111 | stx %g4, [%o6+STACK_BIAS+MINFRAME+(8*20)] | |
112 | stx %g5, [%o6+STACK_BIAS+MINFRAME+(8*21)] | |
113 | stx %g6, [%o6+STACK_BIAS+MINFRAME+(8*22)] | |
114 | stx %g7, [%o6+STACK_BIAS+MINFRAME+(8*23)] | |
115 | wrpr %g0, 1, %gl | |
116 | 0: stx %g0, [%o6+STACK_BIAS+MINFRAME+(8* 8)] | |
117 | stx %g1, [%o6+STACK_BIAS+MINFRAME+(8* 9)] | |
118 | stx %g2, [%o6+STACK_BIAS+MINFRAME+(8*10)] | |
119 | stx %g3, [%o6+STACK_BIAS+MINFRAME+(8*11)] | |
120 | stx %g4, [%o6+STACK_BIAS+MINFRAME+(8*12)] | |
121 | stx %g5, [%o6+STACK_BIAS+MINFRAME+(8*13)] | |
122 | stx %g6, [%o6+STACK_BIAS+MINFRAME+(8*14)] | |
123 | stx %g7, [%o6+STACK_BIAS+MINFRAME+(8*15)] | |
124 | wrpr %g0, %gl | |
125 | stx %g0, [%o6+STACK_BIAS+MINFRAME+(8*0)] | |
126 | stx %g1, [%o6+STACK_BIAS+MINFRAME+(8*1)] | |
127 | stx %g2, [%o6+STACK_BIAS+MINFRAME+(8*2)] | |
128 | stx %g3, [%o6+STACK_BIAS+MINFRAME+(8*3)] | |
129 | stx %g4, [%o6+STACK_BIAS+MINFRAME+(8*4)] | |
130 | stx %g5, [%o6+STACK_BIAS+MINFRAME+(8*5)] | |
131 | stx %g6, [%o6+STACK_BIAS+MINFRAME+(8*6)] | |
132 | stx %g7, [%o6+STACK_BIAS+MINFRAME+(8*7)] | |
133 | ||
134 | wrpr %g0, 15, %pil | |
135 | setn badtrap, %g2, %g1 | |
136 | add %g1, 4, %g2 | |
137 | wrpr %g1, %tpc | |
138 | wrpr %g2, %tnpc | |
139 | add %o6, STACK_BIAS+MINFRAME, %o0 | |
140 | rdpr %tstate, %g1 | |
141 | andn %g1, 0x3f, %g1 | |
142 | rdpr %cwp, %g2 | |
143 | wrpr %g1, %g2, %tstate | |
144 | retry | |
145 | SET_SIZE(__badtrap) | |
146 | #endif /* lint */ | |
147 | ||
148 | #if defined(lint) | |
149 | void | |
150 | rtt(void *ti) | |
151 | { | |
152 | } | |
153 | #else | |
154 | ENTRY(rtt) | |
155 | ldx [%o0+(8*0)], %g0 | |
156 | ldx [%o0+(8*1)], %g1 | |
157 | ldx [%o0+(8*2)], %g2 | |
158 | ldx [%o0+(8*3)], %g3 | |
159 | ldx [%o0+(8*4)], %g4 | |
160 | ldx [%o0+(8*5)], %g5 | |
161 | ldx [%o0+(8*6)], %g6 | |
162 | ldx [%o0+(8*7)], %g7 | |
163 | ldub [%o0+(8*27)+0], %o1; wrpr %o1, %tl | |
164 | ldub [%o0+(8*27)+3], %o1; wrpr %o1, %gl | |
165 | cmp %o1, 2 | |
166 | bne,a 0f | |
167 | ldx [%o0+(8*16)], %g0 | |
168 | ldx [%o0+(8*17)], %g1 | |
169 | ldx [%o0+(8*18)], %g2 | |
170 | ldx [%o0+(8*19)], %g3 | |
171 | ldx [%o0+(8*20)], %g4 | |
172 | ldx [%o0+(8*21)], %g5 | |
173 | ldx [%o0+(8*22)], %g6 | |
174 | ldx [%o0+(8*23)], %g7 | |
175 | wrpr %g0, 1, %gl | |
176 | 0: ldx [%o0+(8* 8)], %g0 | |
177 | ldx [%o0+(8* 9)], %g1 | |
178 | ldx [%o0+(8*10)], %g2 | |
179 | ldx [%o0+(8*11)], %g3 | |
180 | ldx [%o0+(8*12)], %g4 | |
181 | ldx [%o0+(8*13)], %g5 | |
182 | ldx [%o0+(8*14)], %g6 | |
183 | ldx [%o0+(8*15)], %g7 | |
184 | ldx [%o0+(8*24)], %o1; wrpr %o1, %tpc | |
185 | ldx [%o0+(8*25)], %o1; wrpr %o1, %tnpc | |
186 | ldx [%o0+(8*26)], %o1; wrpr %o1, %tstate | |
187 | restore | |
188 | retry | |
189 | SET_SIZE(rtt) | |
190 | #endif /* lint */ | |
191 | ||
192 | #if defined(lint) | |
193 | void | |
194 | por(void) | |
195 | { | |
196 | } | |
197 | #else | |
198 | ENTRY(por) | |
199 | wrpr %g0, 0, %tl | |
200 | wrpr %g0, 0, %gl | |
201 | wrpr %g0, NWINDOWS-2, %cansave | |
202 | wrpr %g0, NWINDOWS-1, %cleanwin | |
203 | wrpr %g0, 0, %canrestore | |
204 | wrpr %g0, 0, %otherwin | |
205 | wrpr %g0, 0, %cwp | |
206 | wrpr %g0, 0, %wstate | |
207 | wr %g0, %y | |
208 | wrpr %g0, 0xf, %pil | |
209 | ||
210 | ! Establish API version | |
211 | call api_version_init | |
212 | nop | |
213 | ||
214 | ! Figure out RA base | |
215 | setn traptable0, %g2, %g1 | |
216 | wrpr %g1, %tba | |
217 | setn 0f, %g3, %g2 | |
218 | 0: rd %pc, %g3 | |
219 | sub %g2, %g1, %g1 | |
220 | sub %g3, %g1, %g1 ! %g1 = RA base | |
221 | ||
222 | ! Take over the MMU | |
223 | call mmu_init | |
224 | mov %g1, %o0 | |
225 | ||
226 | ! Setup env. for C and goto main() | |
227 | ba,a start | |
228 | nop | |
229 | SET_SIZE(por) | |
230 | #endif /* lint */ |