1251517Sandrew/* $NetBSD: setjmp.h,v 1.5 2013/01/11 13:56:32 matt Exp $ */ 2129198Scognet/* $FreeBSD$ */ 3129198Scognet 4129198Scognet/* 5129198Scognet * machine/setjmp.h: machine dependent setjmp-related information. 6129198Scognet */ 7129198Scognet 8132057Scognet#ifndef _MACHINE_SETJMP_H_ 9132057Scognet#define _MACHINE_SETJMP_H_ 10251517Sandrew 11129198Scognet#define _JBLEN 64 /* size, in longs, of a jmp_buf */ 12129198Scognet 13129198Scognet/* 14129198Scognet * NOTE: The internal structure of a jmp_buf is *PRIVATE* 15129198Scognet * This information is provided as there is software 16129198Scognet * that fiddles with this with obtain the stack pointer 17129198Scognet * (yes really ! and its commercial !). 18129198Scognet * 19129198Scognet * Description of the setjmp buffer 20129198Scognet * 21251517Sandrew * word 0 magic number (dependent on creator) 22251517Sandrew * 13 fpscr vfp status control register 23129198Scognet * 14 r4 register 4 24129198Scognet * 15 r5 register 5 25129198Scognet * 16 r6 register 6 26129198Scognet * 17 r7 register 7 27129198Scognet * 18 r8 register 8 28129198Scognet * 19 r9 register 9 29129198Scognet * 20 r10 register 10 (sl) 30129198Scognet * 21 r11 register 11 (fp) 31129198Scognet * 22 r12 register 12 (ip) 32129198Scognet * 23 r13 register 13 (sp) 33129198Scognet * 24 r14 register 14 (lr) 34251517Sandrew * 25 signal mask (dependent on magic) 35129198Scognet * 26 (con't) 36129198Scognet * 27 (con't) 37129198Scognet * 28 (con't) 38251517Sandrew * 32-33 d8 (vfp register d8) 39251517Sandrew * 34-35 d9 (vfp register d9) 40251517Sandrew * 36-37 d10 (vfp register d10) 41251517Sandrew * 38-39 d11 (vfp register d11) 42251517Sandrew * 40-41 d12 (vfp register d12) 43251517Sandrew * 42-43 d13 (vfp register d13) 44251517Sandrew * 44-45 d14 (vfp register d14) 45251517Sandrew * 46-47 d15 (vfp register d15) 46129198Scognet * 47129198Scognet * The magic number number identifies the jmp_buf and 48129198Scognet * how the buffer was created as well as providing 49129198Scognet * a sanity check 50129198Scognet * 51129198Scognet * A side note I should mention - Please do not tamper 52129198Scognet * with the floating point fields. While they are 53129198Scognet * always saved and restored at the moment this cannot 54129198Scognet * be garenteed especially if the compiler happens 55129198Scognet * to be generating soft-float code so no fp 56129198Scognet * registers will be used. 57129198Scognet * 58129198Scognet * Whilst this can be seen an encouraging people to 59129198Scognet * use the setjmp buffer in this way I think that it 60129198Scognet * is for the best then if changes occur compiles will 61129198Scognet * break rather than just having new builds falling over 62129198Scognet * mysteriously. 63129198Scognet */ 64129198Scognet 65129198Scognet#define _JB_MAGIC__SETJMP 0x4278f500 66129198Scognet#define _JB_MAGIC_SETJMP 0x4278f501 67251517Sandrew#define _JB_MAGIC__SETJMP_VFP 0x4278f502 68251517Sandrew#define _JB_MAGIC_SETJMP_VFP 0x4278f503 69129198Scognet 70129198Scognet/* Valid for all jmp_buf's */ 71129198Scognet 72129198Scognet#define _JB_MAGIC 0 73251517Sandrew#define _JB_REG_FPSCR 13 74129198Scognet#define _JB_REG_R4 14 75129198Scognet#define _JB_REG_R5 15 76129198Scognet#define _JB_REG_R6 16 77129198Scognet#define _JB_REG_R7 17 78129198Scognet#define _JB_REG_R8 18 79129198Scognet#define _JB_REG_R9 19 80129198Scognet#define _JB_REG_R10 20 81129198Scognet#define _JB_REG_R11 21 82129198Scognet#define _JB_REG_R12 22 83129198Scognet#define _JB_REG_R13 23 84129198Scognet#define _JB_REG_R14 24 85129198Scognet 86129198Scognet/* Only valid with the _JB_MAGIC_SETJMP magic */ 87129198Scognet 88129198Scognet#define _JB_SIGMASK 25 89249180Sandrew 90251517Sandrew#define _JB_REG_D8 32 91251517Sandrew#define _JB_REG_D9 34 92251517Sandrew#define _JB_REG_D10 36 93251517Sandrew#define _JB_REG_D11 38 94251517Sandrew#define _JB_REG_D12 40 95251517Sandrew#define _JB_REG_D13 42 96251517Sandrew#define _JB_REG_D14 44 97251517Sandrew#define _JB_REG_D15 46 98251517Sandrew 99249180Sandrew#ifndef __ASSEMBLER__ 100129198Scognet#if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE 101129198Scognettypedef struct _sigjmp_buf { int _sjb[_JBLEN + 1]; } sigjmp_buf[1]; 102129198Scognet#endif 103129198Scognet 104129198Scognettypedef struct _jmp_buf { int _jb[_JBLEN + 1]; } jmp_buf[1]; 105249180Sandrew#endif 106129198Scognet 107132057Scognet#endif /* !_MACHINE_SETJMP_H_ */ 108