4 ****************************************************************************
5 * Copyright IBM Corporation 1988, 1989 - All Rights Reserved *
7 * Permission to use, copy, modify, and distribute this software and its *
8 * documentation for any purpose and without fee is hereby granted, *
9 * provided that the above copyright notice appear in all copies and *
10 * that both that copyright notice and this permission notice appear in *
11 * supporting documentation, and that the name of IBM not be used in *
12 * advertising or publicity pertaining to distribution of the software *
13 * without specific, written prior permission. *
15 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
17 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY *
18 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER *
19 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *
20 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
21 ****************************************************************************
28 #if defined(__sparc64__) && !defined(__sparcv9)
33 #if defined(AFS_SUN5_ENV)
34 #include <sys/asm_linkage.h>
36 #elif defined(AFS_BSD_ENV)
37 #ifdef HAVE_MACHINE_ASM_H
38 #include <machine/asm.h>
40 #include <machine/trap.h>
41 #define ST_FLUSH_WINDOWS ST_FLUSHWIN
42 #elif defined(AFS_LINUX_ENV)
43 #define ST_FLUSH_WINDOWS 0x03 /* XXX: from asm/traps.h */
45 #include <sun4/asm_linkage.h>
46 #include <sun4/trap.h>
52 #define STACK_BIAS (2048-1)
61 #else /* !__sparcv9 */
73 #endif /* __sparcv9 */
76 #define SA(x) (((x)+(STACK_ALIGN-1))& ~(STACK_ALIGN-1))
82 .globl _C_LABEL(PRE_Block)
84 # savecontext(f, area1, newsp)
85 # int (*f)(); struct savearea *area1; char *newsp;
89 .globl _C_LABEL(savecontext)
91 save %sp, -SA(MINFRAME), %sp ! Get new window
92 ta ST_FLUSH_WINDOWS ! FLush all other active windows
94 /* The following 3 lines do the equivalent of: _PRE_Block = 1 */
96 sethi %hh(PRE_Block),%l0
97 or %l0,%hm(PRE_Block),%l0
98 sethi %lm(PRE_Block),%g1
99 or %g1,%lo(PRE_Block),%g1
103 sethi %hi(PRE_Block),%l0
104 or %l0,%lo(_C_LABEL(PRE_Block)),%l0
114 /* These declarations are needed if you're running Solaris 7,
115 * and are compiling with -xarch=v9 and have an as from WorkShop
116 * Compilers 5.0 98/12/21 (or more recent). Hopefully,
117 * PROG_AS_UNDERSTANDS_REGISTER will be set correctly by configure,
118 * if that's not the case, edit here and send a bug report.
121 #if PROG_AS_UNDERSTANDS_REGISTER
122 .register %g2, #scratch
123 .register %g3, #scratch
124 .register %g6, #scratch
125 .register %g7, #scratch
128 stx %fp,[%i1+topstack] ! area1->topstack = sp
130 stx %g1, [%i1 + globals + 0] /* Save all globals just in case */
131 stx %g2, [%i1 + globals + 8]
132 stx %g3, [%i1 + globals + 16]
133 stx %g4, [%i1 + globals + 24]
134 stx %g5, [%i1 + globals + 32]
135 stx %g6, [%i1 + globals + 40]
136 stx %g7, [%i1 + globals + 48]
138 stx %g1, [%i1 + globals + 56]
141 stx %f0, [%i1 + globals + 64 + 0]
142 stx %f1, [%i1 + globals + 64 + 8]
143 stx %f2, [%i1 + globals + 64 + 16]
144 stx %f3, [%i1 + globals + 64 + 24]
145 stx %f4, [%i1 + globals + 64 + 32]
146 stx %f5, [%i1 + globals + 64 + 40]
147 stx %f6, [%i1 + globals + 64 + 48]
148 stx %f7, [%i1 + globals + 64 + 56]
149 stx %f8, [%i1 + globals + 64 + 64]
150 stx %f9, [%i1 + globals + 64 + 72]
151 stx %f10, [%i1 + globals + 64 + 80]
152 stx %f11, [%i1 + globals + 64 + 88]
153 stx %f12, [%i1 + globals + 64 + 96]
154 stx %f13, [%i1 + globals + 64 + 104]
155 stx %f14, [%i1 + globals + 64 + 112]
156 stx %f15, [%i1 + globals + 64 + 120]
157 stx %f16, [%i1 + globals + 64 + 128]
158 stx %f17, [%i1 + globals + 64 + 136]
159 stx %f18, [%i1 + globals + 64 + 144]
160 stx %f19, [%i1 + globals + 64 + 152]
161 stx %f20, [%i1 + globals + 64 + 160]
162 stx %f21, [%i1 + globals + 64 + 168]
163 stx %f22, [%i1 + globals + 64 + 176]
164 stx %f23, [%i1 + globals + 64 + 184]
165 stx %f24, [%i1 + globals + 64 + 192]
166 stx %f25, [%i1 + globals + 64 + 200]
167 stx %f26, [%i1 + globals + 64 + 208]
168 stx %f27, [%i1 + globals + 64 + 216]
169 stx %f28, [%i1 + globals + 64 + 224]
170 stx %f29, [%i1 + globals + 64 + 232]
171 stx %f30, [%i1 + globals + 64 + 240]
172 stx %f31, [%i1 + globals + 64 + 248]
173 stx %f32, [%i1 + globals + 64 + 256]
174 stx %f33, [%i1 + globals + 64 + 264]
175 stx %f34, [%i1 + globals + 64 + 272]
176 stx %f35, [%i1 + globals + 64 + 280]
177 stx %f36, [%i1 + globals + 64 + 288]
178 stx %f37, [%i1 + globals + 64 + 296]
179 stx %f38, [%i1 + globals + 64 + 304]
180 stx %f39, [%i1 + globals + 64 + 312]
181 stx %f40, [%i1 + globals + 64 + 320]
182 stx %f41, [%i1 + globals + 64 + 328]
183 stx %f42, [%i1 + globals + 64 + 336]
184 stx %f43, [%i1 + globals + 64 + 344]
185 stx %f44, [%i1 + globals + 64 + 352]
186 stx %f45, [%i1 + globals + 64 + 360]
187 stx %f46, [%i1 + globals + 64 + 368]
188 stx %f47, [%i1 + globals + 64 + 376]
189 stx %f48, [%i1 + globals + 64 + 384]
190 stx %f49, [%i1 + globals + 64 + 392]
191 stx %f50, [%i1 + globals + 64 + 400]
192 stx %f51, [%i1 + globals + 64 + 408]
193 stx %f52, [%i1 + globals + 64 + 416]
194 stx %f53, [%i1 + globals + 64 + 424]
195 stx %f54, [%i1 + globals + 64 + 432]
196 stx %f55, [%i1 + globals + 64 + 440]
197 stx %f56, [%i1 + globals + 64 + 448]
198 stx %f57, [%i1 + globals + 64 + 456]
199 stx %f59, [%i1 + globals + 64 + 464]
200 stx %f60, [%i1 + globals + 64 + 472]
201 stx %f61, [%i1 + globals + 64 + 480]
204 stx %g1, [%i1 + globals + 64 + 488]
206 stx %g1, [%i1 + globals + 64 + 496]
211 #else /* !__sparcv9 */
216 st %fp,[%i1+topstack] ! area1->topstack = sp
218 st %g1, [%i1 + globals + 0] /* Save all globals just in case */
219 st %g2, [%i1 + globals + 4]
220 st %g3, [%i1 + globals + 8]
221 st %g4, [%i1 + globals + 12]
222 st %g5, [%i1 + globals + 16]
223 st %g6, [%i1 + globals + 20]
224 st %g7, [%i1 + globals + 24]
226 st %g1, [%i1 + globals + 28]
229 st %f0, [%i1 + globals + 32 + 0] ! Save all floating point registers
230 st %f1, [%i1 + globals + 32 + 4]
231 st %f2, [%i1 + globals + 32 + 8]
232 st %f3, [%i1 + globals + 32 + 12]
233 st %f4, [%i1 + globals + 32 + 16]
234 st %f5, [%i1 + globals + 32 + 20]
235 st %f6, [%i1 + globals + 32 + 24]
236 st %f7, [%i1 + globals + 32 + 28]
237 st %f8, [%i1 + globals + 64 + 0]
238 st %f9, [%i1 + globals + 64 + 4]
239 st %f10, [%i1 + globals + 64 + 8]
240 st %f11, [%i1 + globals + 64 + 12]
241 st %f12, [%i1 + globals + 64 + 16]
242 st %f13, [%i1 + globals + 64 + 20]
243 st %f14, [%i1 + globals + 64 + 24]
244 st %f15, [%i1 + globals + 64 + 28]
245 st %f16, [%i1 + globals + 64 + 32]
246 st %f17, [%i1 + globals + 64 + 36]
247 st %f18, [%i1 + globals + 64 + 40]
248 st %f19, [%i1 + globals + 64 + 44]
249 st %f20, [%i1 + globals + 64 + 48]
250 st %f21, [%i1 + globals + 64 + 52]
251 st %f22, [%i1 + globals + 64 + 56]
252 st %f23, [%i1 + globals + 64 + 60]
253 st %f24, [%i1 + globals + 64 + 64]
254 st %f25, [%i1 + globals + 64 + 68]
255 st %f26, [%i1 + globals + 64 + 72]
256 st %f27, [%i1 + globals + 64 + 76]
257 st %f28, [%i1 + globals + 64 + 80]
258 st %f29, [%i1 + globals + 64 + 84]
259 st %f30, [%i1 + globals + 64 + 88]
260 st %f31, [%i1 + globals + 64 + 92]
263 st %g1, [%i1 + globals + 64 + 96]
265 st %g1, [%i1 + globals + 64 + 100]
268 st %c0, [%i1 + globals + 168 + 0] ! Save all coprocessor registers
269 st %c1, [%i1 + globals + 168 + 4]
270 st %c2, [%i1 + globals + 168 + 8]
271 st %c3, [%i1 + globals + 168 + 12]
272 st %c4, [%i1 + globals + 168 + 16]
273 st %c5, [%i1 + globals + 168 + 20]
274 st %c6, [%i1 + globals + 168 + 24]
275 st %c7, [%i1 + globals + 168 + 28]
276 st %c8, [%i1 + globals + 200 + 0]
277 st %c9, [%i1 + globals + 200 + 4]
278 st %c10, [%i1 + globals + 200 + 8]
279 st %c11, [%i1 + globals + 200 + 12]
280 st %c12, [%i1 + globals + 200 + 16]
281 st %c13, [%i1 + globals + 200 + 20]
282 st %c14, [%i1 + globals + 200 + 24]
283 st %c15, [%i1 + globals + 200 + 28]
284 st %c16, [%i1 + globals + 200 + 32]
285 st %c17, [%i1 + globals + 200 + 36]
286 st %c18, [%i1 + globals + 200 + 40]
287 st %c19, [%i1 + globals + 200 + 44]
288 st %c20, [%i1 + globals + 200 + 48]
289 st %c21, [%i1 + globals + 200 + 52]
290 st %c22, [%i1 + globals + 200 + 56]
291 st %c23, [%i1 + globals + 200 + 60]
292 st %c24, [%i1 + globals + 200 + 64]
293 st %c25, [%i1 + globals + 200 + 68]
294 st %c26, [%i1 + globals + 200 + 72]
295 st %c27, [%i1 + globals + 200 + 76]
296 st %c28, [%i1 + globals + 200 + 80]
297 st %c29, [%i1 + globals + 200 + 84]
298 st %c30, [%i1 + globals + 200 + 88]
299 st %c31, [%i1 + globals + 200 + 92]
302 st %g1, [%i1 + globals + 200 + 96]
304 st %g1, [%i1 + globals + 200 + 100]
308 #endif /* __sparcv9 */
311 be,a L1 ! if (newsp == 0) no stack switch
314 add %i2, STACK_ALIGN - 1, %i2
315 and %i2, ~(STACK_ALIGN - 1), %i2
316 sub %i2, SA(MINFRAME), %fp
320 ! This used to compute a new stack frame base, write it into
321 ! FP, and restore to enter the new frame. But that left a window
322 ! in which FP could be written into the backing store for this
323 ! frame, to be tripped over later by returnto. So instead we do
324 ! the restore first, then modify SP to enter the new frame. We
325 ! can still refer to our argument as %02.
327 add %o2, STACK_ALIGN - 1, %o2
328 and %o2, ~(STACK_ALIGN - 1), %o2
330 sub %o2, SA(MINFRAME) + STACK_BIAS, %sp
333 L1: call %i0 ! call f()
338 ! struct savearea *area1;
339 .globl _C_LABEL(returnto)
341 ta ST_FLUSH_WINDOWS ! FLush all other active windows
346 ldx [%i1 + globals + 64 + 0], %f0
347 ldx [%i1 + globals + 64 + 8], %f1
348 ldx [%i1 + globals + 64 + 16], %f2
349 ldx [%i1 + globals + 64 + 24], %f3
350 ldx [%i1 + globals + 64 + 32], %f4
351 ldx [%i1 + globals + 64 + 40], %f5
352 ldx [%i1 + globals + 64 + 48], %f6
353 ldx [%i1 + globals + 64 + 56], %f7
354 ldx [%i1 + globals + 64 + 64], %f8
355 ldx [%i1 + globals + 64 + 72], %f9
356 ldx [%i1 + globals + 64 + 80], %f10
357 ldx [%i1 + globals + 64 + 88], %f11
358 ldx [%i1 + globals + 64 + 96], %f12
359 ldx [%i1 + globals + 64 + 104], %f13
360 ldx [%i1 + globals + 64 + 112], %f14
361 ldx [%i1 + globals + 64 + 120], %f15
362 ldx [%i1 + globals + 64 + 128], %f16
363 ldx [%i1 + globals + 64 + 136], %f17
364 ldx [%i1 + globals + 64 + 144], %f18
365 ldx [%i1 + globals + 64 + 152], %f19
366 ldx [%i1 + globals + 64 + 160], %f20
367 ldx [%i1 + globals + 64 + 168], %f21
368 ldx [%i1 + globals + 64 + 176], %f22
369 ldx [%i1 + globals + 64 + 184], %f23
370 ldx [%i1 + globals + 64 + 192], %f24
371 ldx [%i1 + globals + 64 + 200], %f25
372 ldx [%i1 + globals + 64 + 208], %f26
373 ldx [%i1 + globals + 64 + 216], %f27
374 ldx [%i1 + globals + 64 + 224], %f28
375 ldx [%i1 + globals + 64 + 232], %f29
376 ldx [%i1 + globals + 64 + 240], %f30
377 ldx [%i1 + globals + 64 + 248], %f31
378 ldx [%i1 + globals + 64 + 256], %f32
379 ldx [%i1 + globals + 64 + 264], %f33
380 ldx [%i1 + globals + 64 + 272], %f34
381 ldx [%i1 + globals + 64 + 280], %f35
382 ldx [%i1 + globals + 64 + 288], %f36
383 ldx [%i1 + globals + 64 + 296], %f37
384 ldx [%i1 + globals + 64 + 304], %f38
385 ldx [%i1 + globals + 64 + 312], %f39
386 ldx [%i1 + globals + 64 + 320], %f40
387 ldx [%i1 + globals + 64 + 328], %f41
388 ldx [%i1 + globals + 64 + 336], %f42
389 ldx [%i1 + globals + 64 + 344], %f43
390 ldx [%i1 + globals + 64 + 352], %f44
391 ldx [%i1 + globals + 64 + 360], %f45
392 ldx [%i1 + globals + 64 + 368], %f46
393 ldx [%i1 + globals + 64 + 376], %f47
394 ldx [%i1 + globals + 64 + 384], %f48
395 ldx [%i1 + globals + 64 + 392], %f49
396 ldx [%i1 + globals + 64 + 400], %f50
397 ldx [%i1 + globals + 64 + 408], %f51
398 ldx [%i1 + globals + 64 + 416], %f52
399 ldx [%i1 + globals + 64 + 424], %f53
400 ldx [%i1 + globals + 64 + 432], %f54
401 ldx [%i1 + globals + 64 + 440], %f55
402 ldx [%i1 + globals + 64 + 448], %f56
403 ldx [%i1 + globals + 64 + 456], %f57
404 ldx [%i1 + globals + 64 + 464], %f59
405 ldx [%i1 + globals + 64 + 472], %f60
406 ldx [%i1 + globals + 64 + 480], %f61
409 ldx [%i1 + globals + 64 + 488], %g1
411 ldx [%i1 + globals + 64 + 496], %g1
416 ldx [%o0+topstack],%g1 ! sp = area1->topstack
417 sub %g1, SA(MINFRAME), %fp ! Adjust sp to the right place
418 sub %fp, SA(MINFRAME), %sp
420 ldx [%o0 + globals + 56], %g1 ! Restore global regs back
422 ldx [%o0 + globals + 0], %g1
423 ldx [%o0 + globals + 8], %g2
424 ldx [%o0 + globals + 16], %g3
425 ldx [%o0 + globals + 24],%g4
426 ldx [%o0 + globals + 32],%g5
427 ldx [%o0 + globals + 40],%g6
428 ldx [%o0 + globals + 48],%g7
430 #else /* !__sparcv9 */
432 ld [%o0+topstack],%g1 ! sp = area1->topstack
433 sub %g1, SA(MINFRAME), %fp ! Adjust sp to the right place
434 sub %fp, SA(MINFRAME), %sp
437 ld [%o0 + globals + 32 + 0],%f0 ! Restore floating-point registers
438 ld [%o0 + globals + 32 + 4],%f1
439 ld [%o0 + globals + 32 + 8],%f2
440 ld [%o0 + globals + 32 + 12],%f3
441 ld [%o0 + globals + 32 + 16],%f4
442 ld [%o0 + globals + 32 + 20],%f5
443 ld [%o0 + globals + 32 + 24],%f6
444 ld [%o0 + globals + 32 + 28],%f7
445 ld [%o0 + globals + 64 + 0],%f8
446 ld [%o0 + globals + 64 + 4],%f9
447 ld [%o0 + globals + 64 + 8],%f10
448 ld [%o0 + globals + 64 + 12],%f11
449 ld [%o0 + globals + 64 + 16],%f12
450 ld [%o0 + globals + 64 + 20],%f13
451 ld [%o0 + globals + 64 + 24],%f14
452 ld [%o0 + globals + 64 + 28],%f15
453 ld [%o0 + globals + 64 + 32],%f16
454 ld [%o0 + globals + 64 + 36],%f17
455 ld [%o0 + globals + 64 + 40],%f18
456 ld [%o0 + globals + 64 + 44],%f19
457 ld [%o0 + globals + 64 + 48],%f20
458 ld [%o0 + globals + 64 + 52],%f21
459 ld [%o0 + globals + 64 + 56],%f22
460 ld [%o0 + globals + 64 + 60],%f23
461 ld [%o0 + globals + 64 + 64],%f24
462 ld [%o0 + globals + 64 + 68],%f25
463 ld [%o0 + globals + 64 + 72],%f26
464 ld [%o0 + globals + 64 + 76],%f27
465 ld [%o0 + globals + 64 + 80],%f28
466 ld [%o0 + globals + 64 + 84],%f29
467 ld [%o0 + globals + 64 + 88],%f30
468 ld [%o0 + globals + 64 + 92],%f31
470 ld [%o0 + globals + 64 + 96],%g1
472 ld [%o0 + globals + 64 + 100],%g1
476 ld [%o0 + globals + 168 + 0],%c0 ! Restore floating-point registers
477 ld [%o0 + globals + 168 + 4],%c1
478 ld [%o0 + globals + 168 + 8],%c2
479 ld [%o0 + globals + 168 + 12],%c3
480 ld [%o0 + globals + 168 + 16],%c4
481 ld [%o0 + globals + 168 + 20],%c5
482 ld [%o0 + globals + 168 + 24],%c6
483 ld [%o0 + globals + 168 + 28],%c7
484 ld [%o0 + globals + 200 + 0],%c8
485 ld [%o0 + globals + 200 + 4],%c9
486 ld [%o0 + globals + 200 + 8],%c10
487 ld [%o0 + globals + 200 + 12],%c11
488 ld [%o0 + globals + 200 + 16],%c12
489 ld [%o0 + globals + 200 + 20],%c13
490 ld [%o0 + globals + 200 + 24],%c14
491 ld [%o0 + globals + 200 + 28],%c15
492 ld [%o0 + globals + 200 + 32],%c16
493 ld [%o0 + globals + 200 + 36],%c17
494 ld [%o0 + globals + 200 + 40],%c18
495 ld [%o0 + globals + 200 + 44],%c19
496 ld [%o0 + globals + 200 + 48],%c20
497 ld [%o0 + globals + 200 + 52],%c21
498 ld [%o0 + globals + 200 + 56],%c22
499 ld [%o0 + globals + 200 + 60],%c23
500 ld [%o0 + globals + 200 + 64],%c24
501 ld [%o0 + globals + 200 + 68],%c25
502 ld [%o0 + globals + 200 + 72],%c26
503 ld [%o0 + globals + 200 + 76],%c27
504 ld [%o0 + globals + 200 + 80],%c28
505 ld [%o0 + globals + 200 + 84],%c29
506 ld [%o0 + globals + 200 + 88],%c30
507 ld [%o0 + globals + 200 + 92],%c31
509 ld [%o0 + globals + 200 + 96],%g1
511 ld [%o0 + globals + 200 + 100],%g1
515 ld [%o0 + globals + 28], %g1 ! Restore global regs back
517 ld [%o0 + globals + 0], %g1
518 ld [%o0 + globals + 4], %g2
519 ld [%o0 + globals + 8], %g3
520 ld [%o0 + globals + 12],%g4
521 ld [%o0 + globals + 16],%g5
522 ld [%o0 + globals + 20],%g6
523 ld [%o0 + globals + 24],%g7
525 #endif /* __sparcv9 */
527 /* The following 3 lines are equivalent to: _PRE_Block = 0 */
529 sethi %hh(_C_LABEL(PRE_Block)),%l0
530 or %l0,%hm(_C_LABEL(PRE_Block)),%l0
531 sethi %lm(_C_LABEL(PRE_Block)),%g1
532 or %g1,%lo(_C_LABEL(PRE_Block)),%g1
536 sethi %hi(_C_LABEL(PRE_Block)),%l0
537 or %l0,%lo(_C_LABEL(PRE_Block)),%l0