1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Ralph Campbell. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11#include <machine/reg.h> 12#include <machine/machAsmDefs.h> 13 14#if defined(LIBC_SCCS) && !defined(lint) 15 ASMSTR("@(#)_setjmp.s 8.1 (Berkeley) 06/04/93") 16#endif /* LIBC_SCCS and not lint */ 17 18/* 19 * C library -- _setjmp, _longjmp 20 * 21 * _longjmp(a,v) 22 * will generate a "return(v)" from 23 * the last call to 24 * _setjmp(a) 25 * by restoring registers from the stack, 26 * The previous signal state is NOT restored. 27 */ 28 29 .set noreorder 30 31LEAF(_setjmp) 32 li v0, 0xACEDBADE # sigcontext magic number 33 sw ra, (2 * 4)(a0) # sc_pc = return address 34 sw v0, (3 * 4)(a0) # saved in sc_regs[0] 35 sw s0, ((S0 + 3) * 4)(a0) 36 sw s1, ((S1 + 3) * 4)(a0) 37 sw s2, ((S2 + 3) * 4)(a0) 38 sw s3, ((S3 + 3) * 4)(a0) 39 sw s4, ((S4 + 3) * 4)(a0) 40 sw s5, ((S5 + 3) * 4)(a0) 41 sw s6, ((S6 + 3) * 4)(a0) 42 sw s7, ((S7 + 3) * 4)(a0) 43 sw sp, ((SP + 3) * 4)(a0) 44 sw s8, ((S8 + 3) * 4)(a0) 45 cfc1 v0, $31 # too bad cant check if FP used 46 swc1 $f20, ((20 + 38) * 4)(a0) 47 swc1 $f21, ((21 + 38) * 4)(a0) 48 swc1 $f22, ((22 + 38) * 4)(a0) 49 swc1 $f23, ((23 + 38) * 4)(a0) 50 swc1 $f24, ((24 + 38) * 4)(a0) 51 swc1 $f25, ((25 + 38) * 4)(a0) 52 swc1 $f26, ((26 + 38) * 4)(a0) 53 swc1 $f27, ((27 + 38) * 4)(a0) 54 swc1 $f28, ((28 + 38) * 4)(a0) 55 swc1 $f29, ((29 + 38) * 4)(a0) 56 swc1 $f30, ((30 + 38) * 4)(a0) 57 swc1 $f31, ((31 + 38) * 4)(a0) 58 sw v0, ((32 + 38) * 4)(a0) 59 j ra 60 move v0, zero 61END(_setjmp) 62 63LEAF(_longjmp) 64 lw v0, (3 * 4)(a0) # get magic number 65 lw ra, (2 * 4)(a0) 66 bne v0, 0xACEDBADE, botch # jump if error 67 lw s0, ((S0 + 3) * 4)(a0) 68 lw s1, ((S1 + 3) * 4)(a0) 69 lw s2, ((S2 + 3) * 4)(a0) 70 lw s3, ((S3 + 3) * 4)(a0) 71 lw s4, ((S4 + 3) * 4)(a0) 72 lw s5, ((S5 + 3) * 4)(a0) 73 lw s6, ((S6 + 3) * 4)(a0) 74 lw s7, ((S7 + 3) * 4)(a0) 75 lw v0, ((32 + 38) * 4)(a0) # get fpu status 76 lw sp, ((SP + 3) * 4)(a0) 77 lw s8, ((S8 + 3) * 4)(a0) 78 ctc1 v0, $31 79 lwc1 $f20, ((20 + 38) * 4)(a0) 80 lwc1 $f21, ((21 + 38) * 4)(a0) 81 lwc1 $f22, ((22 + 38) * 4)(a0) 82 lwc1 $f23, ((23 + 38) * 4)(a0) 83 lwc1 $f24, ((24 + 38) * 4)(a0) 84 lwc1 $f25, ((25 + 38) * 4)(a0) 85 lwc1 $f26, ((26 + 38) * 4)(a0) 86 lwc1 $f27, ((27 + 38) * 4)(a0) 87 lwc1 $f28, ((28 + 38) * 4)(a0) 88 lwc1 $f29, ((29 + 38) * 4)(a0) 89 lwc1 $f30, ((30 + 38) * 4)(a0) 90 lwc1 $f31, ((31 + 38) * 4)(a0) 91 j ra 92 move v0, a1 93botch: 94 jal longjmperror 95 nop 96 jal abort 97 nop 98END(_longjmp) 99