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