Print this page
de-linting of .s files
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/sun4/brand/common/brand_solaris.s
+++ new/usr/src/uts/sun4/brand/common/brand_solaris.s
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
↓ open down ↓ |
23 lines elided |
↑ open up ↑ |
24 24
25 25 /*
26 26 * This is an assembly file that gets #include-ed into the brand-specific
27 27 * assembly files (e.g. sn1_brand_asm.s) for Solaris-derived brands.
28 28 * We can't make these into functions since in the trap context there's
29 29 * no easy place to save the extra parameters that would be required, so
30 30 * each brand module needs its own copy of this code. We #include this and
31 31 * use brand-specific #defines to replace the XXX_brand_... definitions.
32 32 */
33 33
34 -#ifdef lint
35 -
36 -#include <sys/systm.h>
37 -
38 -void
39 -XXX_brand_syscall32_callback(void)
40 -{
41 -}
42 -
43 -void
44 -XXX_brand_syscall_callback(void)
45 -{
46 -}
47 -
48 -#else /* !lint */
49 -
50 34 #include <sys/asm_linkage.h>
51 35 #include <sys/machthread.h>
52 36 #include <sys/privregs.h>
53 37 #include "assym.h"
54 38
55 39 #ifdef _ASM /* The remainder of this file is only for assembly files */
56 40
57 41 #if defined(sun4v)
58 42
59 43 #define GLOBALS_SWAP(reg) \
60 44 rdpr %gl, reg; \
61 45 wrpr reg, 1, %gl
62 46
63 47 /*
64 48 * The GLOBALS_RESTORE macro can only be one instruction since it's
65 49 * used in a delay slot.
66 50 */
67 51 #define GLOBALS_RESTORE(reg) \
68 52 wrpr reg, 0, %gl
69 53
70 54 #else /* !sun4v */
71 55
72 56 #define GLOBALS_SWAP(reg) \
73 57 rdpr %pstate, reg; \
74 58 wrpr reg, PSTATE_AG, %pstate
75 59
76 60 /*
77 61 * The GLOBALS_RESTORE macro can only be one instruction since it's
78 62 * used in a delay slot.
79 63 */
80 64 #define GLOBALS_RESTORE(reg) \
81 65 wrpr reg, %g0, %pstate
82 66
83 67 #endif /* !sun4v */
84 68
85 69 /*
86 70 * Input parameters:
87 71 * %g1: return point
88 72 * %g2: pointer to our cpu structure
89 73 */
90 74 ENTRY(XXX_brand_syscall32_callback)
91 75 /*
92 76 * If the trapping thread has the address mask bit clear, then it's
93 77 * a 64-bit process, and has no business calling 32-bit syscalls.
94 78 */
95 79 rdpr %tstate, %g3; /* %tstate.am is the trapping */
96 80 andcc %g3, TSTATE_AM, %g3; /* threads address mask bit */
97 81 bne,pt %xcc, _entry;
98 82 nop;
99 83 jmp %g1; /* 64 bit process, bail out */
100 84 nop;
101 85 SET_SIZE(XXX_brand_syscall32_callback)
102 86
103 87 /*
104 88 * Input parameters:
105 89 * %g1: return point
106 90 * %g2: pointer to our cpu structure
107 91 */
108 92 ENTRY(XXX_brand_syscall_callback)
109 93 /*
110 94 * If the trapping thread has the address mask bit set, then it's
111 95 * a 32-bit process, and has no business calling 64-bit syscalls.
112 96 */
113 97 rdpr %tstate, %g3; /* %tstate.am is the trapping */
114 98 andcc %g3, TSTATE_AM, %g3; /* threads address mask bit */
115 99 be,pt %xcc, _entry;
116 100 nop;
117 101 jmp %g1; /* 32 bit process, bail out */
118 102 nop;
119 103 SET_SIZE(XXX_brand_syscall_callback)
120 104
121 105 ENTRY(XXX_brand_syscall_callback_common)
122 106 _entry:
123 107 /*
124 108 * Input parameters:
125 109 * %g1: return point
126 110 * %g2: pointer to our cpu structure
127 111 *
128 112 * Note that we're free to use any %g? registers as long as
129 113 * we are are executing with alternate globals. If we're
130 114 * executing with user globals we need to backup any registers
131 115 * that we want to use so that we can restore them when we're
132 116 * done.
133 117 *
134 118 * Save some locals in the CPU tmp area to give us a little
135 119 * room to work.
136 120 */
137 121 stn %l0, [%g2 + CPU_TMP1];
138 122 stn %l1, [%g2 + CPU_TMP2];
139 123
140 124 #if defined(sun4v)
141 125 /*
142 126 * On sun4v save our input parameters (which are stored in the
143 127 * alternate globals) since we'll need to switch between alternate
144 128 * globals and normal globals, and on sun4v the alternate globals
145 129 * are not preserved across these types of switches.
146 130 */
147 131 stn %l2, [%g2 + CPU_TMP3];
148 132 stn %l3, [%g2 + CPU_TMP4];
149 133
150 134 mov %g1, %l2; /* save %g1 in %l2 */
151 135 mov %g2, %l3; /* save %g2 in %l3 */
152 136 #endif /* sun4v */
153 137
154 138 /*
155 139 * Switch from the alternate to user globals to grab the syscall
156 140 * number.
157 141 */
158 142 GLOBALS_SWAP(%l0); /* switch to normal globals */
159 143
160 144 /*
161 145 * If the system call number is >= 1024, then it is a native
162 146 * syscall that doesn't need emulation.
163 147 */
164 148 cmp %g1, 1024; /* is this a native syscall? */
165 149 bl,a _indirect_check; /* probably not, continue checking */
166 150 mov %g1, %l1; /* delay slot - grab syscall number */
167 151
168 152 /*
169 153 * This is a native syscall, probably from the emulation library.
170 154 * Subtract 1024 from the syscall number and let it go through.
171 155 */
172 156 sub %g1, 1024, %g1; /* convert magic num to real syscall */
173 157 ba _exit; /* jump back into syscall path */
174 158 GLOBALS_RESTORE(%l0); /* delay slot - */
175 159 /* switch back to alternate globals */
176 160
177 161 _indirect_check:
178 162 /*
179 163 * If the system call number is 0 (SYS_syscall), then this might be
180 164 * an indirect syscall, in which case the actual syscall number
181 165 * would be stored in %o0, in which case we need to redo the
182 166 * the whole >= 1024 check.
183 167 */
184 168 brnz,pt %g1, _emulation_check; /* is this an indirect syscall? */
185 169 nop; /* if not, goto the emulation check */
186 170
187 171 /*
188 172 * Indirect syscalls are only supported for 32 bit processes so
189 173 * consult the tstate address mask again.
190 174 */
191 175 rdpr %tstate, %l1; /* %tstate.am is the trapping */
192 176 andcc %l1, TSTATE_AM, %l1; /* threads address mask bit */
193 177 be,a,pn %xcc, _exit;
194 178 GLOBALS_RESTORE(%l0); /* delay slot - */
195 179 /* switch back to alternate globals */
196 180
197 181 /*
198 182 * The caller is 32 bit and this an indirect system call.
199 183 */
200 184 cmp %o0, 1024; /* is this a native syscall? */
201 185 bl,a _emulation_check; /* no, goto the emulation check */
202 186 mov %o0, %l1; /* delay slot - grab syscall number */
203 187
204 188 /*
205 189 * This is native indirect syscall, probably from the emulation
206 190 * library. Subtract 1024 from the syscall number and let it go
207 191 * through.
208 192 */
209 193 sub %o0, 1024, %o0; /* convert magic num to real syscall */
210 194 ba _exit; /* jump back into syscall path */
211 195 GLOBALS_RESTORE(%l0); /* delay slot - */
212 196 /* switch back to alternate globals */
213 197
214 198 _emulation_check:
215 199 GLOBALS_RESTORE(%l0); /* switch back to alternate globals */
216 200
217 201 /*
218 202 * Check to see if we want to interpose on this system call. If
219 203 * not, we jump back into the normal syscall path and pretend
220 204 * nothing happened. %l1 contains the syscall we're invoking.
221 205 */
222 206 set XXX_emulation_table, %g3;
223 207 ldn [%g3], %g3;
224 208 add %g3, %l1, %g3;
225 209 ldub [%g3], %g3;
226 210 brz %g3, _exit;
227 211 nop;
228 212
229 213 /*
230 214 * Find the address of the userspace handler.
231 215 * cpu->cpu_thread->t_procp->p_brand_data->spd_handler.
232 216 */
233 217 #if defined(sun4v)
234 218 /* restore the alternate global registers after incrementing %gl */
235 219 mov %l3, %g2;
236 220 #endif /* sun4v */
237 221 ldn [%g2 + CPU_THREAD], %g3; /* get thread ptr */
238 222 ldn [%g3 + T_PROCP], %g4; /* get proc ptr */
239 223 ldn [%g4 + P_BRAND_DATA], %g5; /* get brand data ptr */
240 224 ldn [%g5 + SPD_HANDLER], %g5; /* get userland brnd hdlr ptr */
241 225 brz %g5, _exit; /* has it been set? */
242 226 nop;
243 227
244 228 /*
245 229 * Make sure this isn't an agent lwp. We can't do syscall
246 230 * interposition for system calls made by a agent lwp. See
247 231 * the block comments in the top of the brand emulation library
248 232 * for more information.
249 233 */
250 234 ldn [%g4 + P_AGENTTP], %g4; /* get agent thread ptr */
251 235 cmp %g3, %g4; /* is this an agent thread? */
252 236 be,pn %xcc, _exit; /* if so don't emulate */
253 237 nop;
254 238
255 239 /*
256 240 * Now the magic happens. Grab the trap return address and then
257 241 * reset it to point to the user space handler. When we execute
258 242 * the 'done' instruction, we will jump into our handler instead of
259 243 * the user's code. We also stick the old return address in %g5,
260 244 * so we can return to the proper instruction in the user's code.
261 245 * Note: we also pass back the base address of the syscall
262 246 * emulation table. This is a performance hack to avoid having to
263 247 * look it up on every call.
264 248 */
265 249 rdpr %tnpc, %l1; /* save old tnpc */
266 250 wrpr %g0, %g5, %tnpc; /* setup tnpc */
267 251 GLOBALS_SWAP(%l0); /* switch to normal globals */
268 252 mov %l1, %g5; /* pass tnpc to user code in %g5 */
269 253 GLOBALS_RESTORE(%l0); /* switch back to alternate globals */
270 254
271 255 /* Update the address we're going to return to */
272 256 #if defined(sun4v)
273 257 set fast_trap_done_chk_intr, %l2;
274 258 #else /* !sun4v */
275 259 set fast_trap_done_chk_intr, %g1;
276 260 #endif /* !sun4v */
277 261
278 262 _exit:
279 263 /*
280 264 * Restore registers before returning.
281 265 *
282 266 * Note that %g2 should be loaded with the CPU struct addr and
283 267 * %g1 should be loaded the address we're going to return to.
284 268 */
285 269 #if defined(sun4v)
286 270 /* restore the alternate global registers after incrementing %gl */
287 271 mov %l2, %g1; /* restore %g1 from %l2 */
288 272 mov %l3, %g2; /* restore %g2 from %l3 */
289 273
290 274 ldn [%g2 + CPU_TMP4], %l3; /* restore locals */
291 275 ldn [%g2 + CPU_TMP3], %l2;
↓ open down ↓ |
232 lines elided |
↑ open up ↑ |
292 276 #endif /* sun4v */
293 277
294 278 ldn [%g2 + CPU_TMP2], %l1; /* restore locals */
295 279 ldn [%g2 + CPU_TMP1], %l0;
296 280
297 281 jmp %g1;
298 282 nop;
299 283 SET_SIZE(XXX_brand_syscall_callback_common)
300 284
301 285 #endif /* _ASM */
302 -#endif /* !lint */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX