1/*- 2 * Copyright (c) 1991 The Regents of the University of California. 3 * 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 5.4 (Berkeley) 07/26/92") 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 29LEAF(_setjmp) 30 li v0, 0xACEDBADE # sigcontext magic number 31 sw ra, (2 * 4)(a0) # sc_pc = return address 32 sw v0, (3 * 4)(a0) # saved in sc_regs[0] 33 sw s0, ((S0 + 3) * 4)(a0) 34 sw s1, ((S1 + 3) * 4)(a0) 35 sw s2, ((S2 + 3) * 4)(a0) 36 sw s3, ((S3 + 3) * 4)(a0) 37 sw s4, ((S4 + 3) * 4)(a0) 38 sw s5, ((S5 + 3) * 4)(a0) 39 sw s6, ((S6 + 3) * 4)(a0) 40 sw s7, ((S7 + 3) * 4)(a0) 41 sw sp, ((SP + 3) * 4)(a0) 42 sw s8, ((S8 + 3) * 4)(a0) 43 cfc1 v0, $31 # too bad can't check if FP used 44 swc1 $f20, ((20 + 38) * 4)(a0) 45 swc1 $f21, ((21 + 38) * 4)(a0) 46 swc1 $f22, ((22 + 38) * 4)(a0) 47 swc1 $f23, ((23 + 38) * 4)(a0) 48 swc1 $f24, ((24 + 38) * 4)(a0) 49 swc1 $f25, ((25 + 38) * 4)(a0) 50 swc1 $f26, ((26 + 38) * 4)(a0) 51 swc1 $f27, ((27 + 38) * 4)(a0) 52 swc1 $f28, ((28 + 38) * 4)(a0) 53 swc1 $f29, ((29 + 38) * 4)(a0) 54 swc1 $f30, ((30 + 38) * 4)(a0) 55 swc1 $f31, ((31 + 38) * 4)(a0) 56 sw v0, ((32 + 38) * 4)(a0) 57 move v0, zero 58 j ra 59END(_setjmp) 60 61LEAF(_longjmp) 62 lw v0, (3 * 4)(a0) # get magic number 63 bne v0, 0xACEDBADE, botch # jump if error 64 lw ra, (2 * 4)(a0) 65 lw s0, ((S0 + 3) * 4)(a0) 66 lw s1, ((S1 + 3) * 4)(a0) 67 lw s2, ((S2 + 3) * 4)(a0) 68 lw s3, ((S3 + 3) * 4)(a0) 69 lw s4, ((S4 + 3) * 4)(a0) 70 lw s5, ((S5 + 3) * 4)(a0) 71 lw s6, ((S6 + 3) * 4)(a0) 72 lw s7, ((S7 + 3) * 4)(a0) 73 lw sp, ((SP + 3) * 4)(a0) 74 lw s8, ((S8 + 3) * 4)(a0) 75 lw v0, ((32 + 38) * 4)(a0) # get fpu status 76 ctc1 v0, $31 77 lwc1 $f20, ((20 + 38) * 4)(a0) 78 lwc1 $f21, ((21 + 38) * 4)(a0) 79 lwc1 $f22, ((22 + 38) * 4)(a0) 80 lwc1 $f23, ((23 + 38) * 4)(a0) 81 lwc1 $f24, ((24 + 38) * 4)(a0) 82 lwc1 $f25, ((25 + 38) * 4)(a0) 83 lwc1 $f26, ((26 + 38) * 4)(a0) 84 lwc1 $f27, ((27 + 38) * 4)(a0) 85 lwc1 $f28, ((28 + 38) * 4)(a0) 86 lwc1 $f29, ((29 + 38) * 4)(a0) 87 lwc1 $f30, ((30 + 38) * 4)(a0) 88 lwc1 $f31, ((31 + 38) * 4)(a0) 89 move v0, a1 90 j ra 91botch: 92 jal longjmperror 93 jal abort 94END(_longjmp) 95