In legion build config, updated path to GNU tools and updated deprecated Sun CC flag...
[OpenSPARC-T2-SAM] / hypervisor / src / common / include / traptable.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* Hypervisor Software File: traptable.h
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#ifndef _TRAPTABLE_H
50#define _TRAPTABLE_H
51
52#pragma ident "@(#)traptable.h 1.1 07/05/03 SMI"
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58#include <platform/traptable.h>
59
60/* BEGIN CSTYLED */
61
62#define TRAP_ALIGN_SIZE 32
63#define TRAP_ALIGN .align TRAP_ALIGN_SIZE
64#define TRAP_ALIGN_BIG .align (TRAP_ALIGN_SIZE * 4)
65
66
67#define TRAP(ttnum, action) \
68 .global ttnum ;\
69 ttnum: ;\
70 action ;\
71 TRAP_ALIGN
72
73#define TRAP_NOALIGN(ttnum, action) \
74 .global ttnum ;\
75 ttnum: ;\
76 action ;\
77
78#define BIGTRAP(ttnum, action) \
79 .global ttnum ;\
80 ttnum: ;\
81 action ;\
82 TRAP_ALIGN_BIG
83
84#define GOTO(label) \
85 .global label ;\
86 ba,a label ;\
87 .empty
88
89#define NOT GOTO(badtrap)
90#define NOT_BIG NOT NOT NOT NOT
91#define RED NOT
92
93/*
94 * Note: First NOP instruction is for delay slot for preceding
95 * HCALL() trap table entry
96 */
97#define HCALL_BAD \
98 nop ;\
99 mov EBADTRAP, %o0 ;\
100 done
101
102/*
103 * First instruction of GUEST_STRUCT() is safe in delay slot
104 * for subsequent HCALL() trap entry
105 */
106#define HCALL(idx) \
107 GUEST_STRUCT(%g1) ;\
108 ldx [%g1 + GUEST_HCALL_TABLE], %g1 ;\
109 set (idx * API_ENTRY_SIZE), %g2 ;\
110 ldx [%g1 + %g2], %g1 ;\
111 jmp %g1
112
113/*
114 * Basic register window handling
115 */
116#define CLEAN_WINDOW \
117 rdpr %cleanwin, %l0; inc %l0; wrpr %l0, %cleanwin ;\
118 clr %l0; clr %l1; clr %l2; clr %l3 ;\
119 clr %l4; clr %l5; clr %l6; clr %l7 ;\
120 clr %o0; clr %o1; clr %o2; clr %o3 ;\
121 clr %o4; clr %o5; clr %o6; clr %o7 ;\
122 retry
123
124/*
125 * FIXME:
126 * We dont need the 32bit stack handling here since the HV is 64 bit only.
127 * could and prob. should use the extra instructions to check for
128 * strand stack over and under-runs for safety.
129 */
130#define SPILL_WINDOW \
131 andcc %o6, 1, %g0 ;\
132 be,pt %xcc, 0f ;\
133 wr %g0, 0x80, %asi ;\
134 stxa %l0, [%o6+V9BIAS64+(0*8)]%asi ;\
135 stxa %l1, [%o6+V9BIAS64+(1*8)]%asi ;\
136 stxa %l2, [%o6+V9BIAS64+(2*8)]%asi ;\
137 stxa %l3, [%o6+V9BIAS64+(3*8)]%asi ;\
138 stxa %l4, [%o6+V9BIAS64+(4*8)]%asi ;\
139 stxa %l5, [%o6+V9BIAS64+(5*8)]%asi ;\
140 stxa %l6, [%o6+V9BIAS64+(6*8)]%asi ;\
141 stxa %l7, [%o6+V9BIAS64+(7*8)]%asi ;\
142 stxa %i0, [%o6+V9BIAS64+(8*8)]%asi ;\
143 stxa %i1, [%o6+V9BIAS64+(9*8)]%asi ;\
144 stxa %i2, [%o6+V9BIAS64+(10*8)]%asi ;\
145 stxa %i3, [%o6+V9BIAS64+(11*8)]%asi ;\
146 stxa %i4, [%o6+V9BIAS64+(12*8)]%asi ;\
147 stxa %i5, [%o6+V9BIAS64+(13*8)]%asi ;\
148 stxa %i6, [%o6+V9BIAS64+(14*8)]%asi ;\
149 stxa %i7, [%o6+V9BIAS64+(15*8)]%asi ;\
150 ba 1f ;\
151 nop ;\
1520: srl %o6, 0, %o6 ;\
153 stda %i0, [%o6+(0*8)] %asi ;\
154 stda %i2, [%o6+(1*8)] %asi ;\
155 stda %i4, [%o6+(2*8)] %asi ;\
156 stda %i6, [%o6+(3*8)] %asi ;\
157 stda %l0, [%o6+(4*8)] %asi ;\
158 stda %l2, [%o6+(5*8)] %asi ;\
159 stda %l4, [%o6+(6*8)] %asi ;\
160 stda %l6, [%o6+(7*8)] %asi ;\
1611: saved ;\
162 retry
163
164#define FILL_WINDOW \
165 andcc %o6, 1, %g0 ;\
166 be,pt %xcc, 0f ;\
167 wr %g0, 0x80, %asi ;\
168 ldxa [%o6+V9BIAS64+(0*8)]%asi, %l0 ;\
169 ldxa [%o6+V9BIAS64+(1*8)]%asi, %l1 ;\
170 ldxa [%o6+V9BIAS64+(2*8)]%asi, %l2 ;\
171 ldxa [%o6+V9BIAS64+(3*8)]%asi, %l3 ;\
172 ldxa [%o6+V9BIAS64+(4*8)]%asi, %l4 ;\
173 ldxa [%o6+V9BIAS64+(5*8)]%asi, %l5 ;\
174 ldxa [%o6+V9BIAS64+(6*8)]%asi, %l6 ;\
175 ldxa [%o6+V9BIAS64+(7*8)]%asi, %l7 ;\
176 ldxa [%o6+V9BIAS64+(8*8)]%asi, %i0 ;\
177 ldxa [%o6+V9BIAS64+(9*8)]%asi, %i1 ;\
178 ldxa [%o6+V9BIAS64+(10*8)]%asi, %i2 ;\
179 ldxa [%o6+V9BIAS64+(11*8)]%asi, %i3 ;\
180 ldxa [%o6+V9BIAS64+(12*8)]%asi, %i4 ;\
181 ldxa [%o6+V9BIAS64+(13*8)]%asi, %i5 ;\
182 ldxa [%o6+V9BIAS64+(14*8)]%asi, %i6 ;\
183 ldxa [%o6+V9BIAS64+(15*8)]%asi, %i7 ;\
184 ba 1f ;\
185 nop ;\
1860: srl %o6, 0, %o6 ;\
187 ldda [%o6+(0*8)] %asi, %i0 ;\
188 ldda [%o6+(1*8)] %asi, %i2 ;\
189 ldda [%o6+(2*8)] %asi, %i4 ;\
190 ldda [%o6+(3*8)] %asi, %i6 ;\
191 ldda [%o6+(4*8)] %asi, %l0 ;\
192 ldda [%o6+(5*8)] %asi, %l2 ;\
193 ldda [%o6+(6*8)] %asi, %l4 ;\
194 ldda [%o6+(7*8)] %asi, %l6 ;\
1951: restored ;\
196 retry
197
198#define POR \
199 .global start_master ;\
200 ba,a start_master ;\
201 nop; nop; nop ;\
202 .global start_slave ;\
203 ba,a start_slave ;\
204 .empty
205
206/*
207 * Trap-trace layer trap table.
208 */
209
210#define LINK(sym) \
211 CLEAR_INJECTOR_REG ;\
212 rd %pc, %g7 ;\
213 ba sym ;\
214 sub %g7, SIZEOF_CLEAR_INJECTOR_REG, %g7
215
216#define NOTRACE \
217 ba,a (htraptable+(.-htraptracetable)) ;\
218 nop
219
220#define TTRACE(unused, action) \
221 action ;\
222 TRAP_ALIGN
223
224#define BIG_TTRACE(unused, action) \
225 action ;\
226 TRAP_ALIGN_BIG
227
228#define TTRACE_EXIT(pc, scr1) \
229 set (htraptracetable - htraptable), scr1 ;\
230 neg scr1 ;\
231 jmp pc + scr1 ;\
232 nop
233
234/* END CSTYLED */
235
236#ifdef __cplusplus
237}
238#endif
239
240#endif /* _TRAPTABLE_H */