152705Sbostic/*- 252705Sbostic * Copyright (c) 1991 The Regents of the University of California. 352705Sbostic * All rights reserved. 452705Sbostic * 552705Sbostic * This code is derived from software contributed to Berkeley by 652705Sbostic * Ralph Campbell. 752705Sbostic * 852705Sbostic * %sccs.include.redist.c% 952705Sbostic */ 1052705Sbostic 1152856Sralph#include <machine/reg.h> 12*55705Sralph#include <machine/machAsmDefs.h> 1352739Sbostic 1452705Sbostic#if defined(LIBC_SCCS) && !defined(lint) 15*55705Sralph ASMSTR("@(#)_setjmp.s 5.4 (Berkeley) 07/26/92") 1652705Sbostic#endif /* LIBC_SCCS and not lint */ 1752705Sbostic 1852705Sbostic/* 1952705Sbostic * C library -- _setjmp, _longjmp 2052705Sbostic * 2152705Sbostic * _longjmp(a,v) 2252705Sbostic * will generate a "return(v)" from 2352705Sbostic * the last call to 2452705Sbostic * _setjmp(a) 2552705Sbostic * by restoring registers from the stack, 2652705Sbostic * The previous signal state is NOT restored. 2752705Sbostic */ 2852705Sbostic 2952705SbosticLEAF(_setjmp) 3052705Sbostic li v0, 0xACEDBADE # sigcontext magic number 3152705Sbostic sw ra, (2 * 4)(a0) # sc_pc = return address 3252705Sbostic sw v0, (3 * 4)(a0) # saved in sc_regs[0] 3352705Sbostic sw s0, ((S0 + 3) * 4)(a0) 3452705Sbostic sw s1, ((S1 + 3) * 4)(a0) 3552705Sbostic sw s2, ((S2 + 3) * 4)(a0) 3652705Sbostic sw s3, ((S3 + 3) * 4)(a0) 3752705Sbostic sw s4, ((S4 + 3) * 4)(a0) 3852705Sbostic sw s5, ((S5 + 3) * 4)(a0) 3952705Sbostic sw s6, ((S6 + 3) * 4)(a0) 4052705Sbostic sw s7, ((S7 + 3) * 4)(a0) 4152705Sbostic sw sp, ((SP + 3) * 4)(a0) 4252705Sbostic sw s8, ((S8 + 3) * 4)(a0) 4352705Sbostic cfc1 v0, $31 # too bad can't check if FP used 4452705Sbostic swc1 $f20, ((20 + 38) * 4)(a0) 4552705Sbostic swc1 $f21, ((21 + 38) * 4)(a0) 4652705Sbostic swc1 $f22, ((22 + 38) * 4)(a0) 4752705Sbostic swc1 $f23, ((23 + 38) * 4)(a0) 4852705Sbostic swc1 $f24, ((24 + 38) * 4)(a0) 4952705Sbostic swc1 $f25, ((25 + 38) * 4)(a0) 5052705Sbostic swc1 $f26, ((26 + 38) * 4)(a0) 5152705Sbostic swc1 $f27, ((27 + 38) * 4)(a0) 5252705Sbostic swc1 $f28, ((28 + 38) * 4)(a0) 5352705Sbostic swc1 $f29, ((29 + 38) * 4)(a0) 5452705Sbostic swc1 $f30, ((30 + 38) * 4)(a0) 5552705Sbostic swc1 $f31, ((31 + 38) * 4)(a0) 5652705Sbostic sw v0, ((32 + 38) * 4)(a0) 5752705Sbostic move v0, zero 5852705Sbostic j ra 5952705SbosticEND(_setjmp) 6052705Sbostic 6152705SbosticLEAF(_longjmp) 6252705Sbostic lw v0, (3 * 4)(a0) # get magic number 6352705Sbostic bne v0, 0xACEDBADE, botch # jump if error 6452705Sbostic lw ra, (2 * 4)(a0) 6552705Sbostic lw s0, ((S0 + 3) * 4)(a0) 6652705Sbostic lw s1, ((S1 + 3) * 4)(a0) 6752705Sbostic lw s2, ((S2 + 3) * 4)(a0) 6852705Sbostic lw s3, ((S3 + 3) * 4)(a0) 6952705Sbostic lw s4, ((S4 + 3) * 4)(a0) 7052705Sbostic lw s5, ((S5 + 3) * 4)(a0) 7152705Sbostic lw s6, ((S6 + 3) * 4)(a0) 7252705Sbostic lw s7, ((S7 + 3) * 4)(a0) 7352705Sbostic lw sp, ((SP + 3) * 4)(a0) 7452705Sbostic lw s8, ((S8 + 3) * 4)(a0) 7552705Sbostic lw v0, ((32 + 38) * 4)(a0) # get fpu status 7652705Sbostic ctc1 v0, $31 7752705Sbostic lwc1 $f20, ((20 + 38) * 4)(a0) 7852705Sbostic lwc1 $f21, ((21 + 38) * 4)(a0) 7952705Sbostic lwc1 $f22, ((22 + 38) * 4)(a0) 8052705Sbostic lwc1 $f23, ((23 + 38) * 4)(a0) 8152705Sbostic lwc1 $f24, ((24 + 38) * 4)(a0) 8252705Sbostic lwc1 $f25, ((25 + 38) * 4)(a0) 8352705Sbostic lwc1 $f26, ((26 + 38) * 4)(a0) 8452705Sbostic lwc1 $f27, ((27 + 38) * 4)(a0) 8552705Sbostic lwc1 $f28, ((28 + 38) * 4)(a0) 8652705Sbostic lwc1 $f29, ((29 + 38) * 4)(a0) 8752705Sbostic lwc1 $f30, ((30 + 38) * 4)(a0) 8852705Sbostic lwc1 $f31, ((31 + 38) * 4)(a0) 8952705Sbostic move v0, a1 9052705Sbostic j ra 9152705Sbosticbotch: 9252705Sbostic jal longjmperror 9352705Sbostic jal abort 9452705SbosticEND(_longjmp) 95