xref: /freebsd/sys/arm/include/setjmp.h (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1 /*	$NetBSD: setjmp.h,v 1.5 2013/01/11 13:56:32 matt Exp $	*/
2 
3 /*
4  * machine/setjmp.h: machine dependent setjmp-related information.
5  */
6 
7 #ifndef _MACHINE_SETJMP_H_
8 #define _MACHINE_SETJMP_H_
9 
10 #define	_JBLEN	64		/* size, in longs, of a jmp_buf */
11 
12 /*
13  * NOTE: The internal structure of a jmp_buf is *PRIVATE*
14  *       This information is provided as there is software
15  *       that fiddles with this with obtain the stack pointer
16  *	 (yes really ! and its commercial !).
17  *
18  * Description of the setjmp buffer
19  *
20  * word  0	magic number	(dependent on creator)
21  *	13	fpscr		vfp status control register
22  *	14	r4		register 4
23  *	15	r5		register 5
24  *	16	r6		register 6
25  *	17	r7		register 7
26  *	18	r8		register 8
27  *	19	r9		register 9
28  *	20	r10		register 10 (sl)
29  *	21	r11		register 11 (fp)
30  *	22	r12		register 12 (ip)
31  *	23	r13		register 13 (sp)
32  *	24	r14		register 14 (lr)
33  *	25	signal mask	(dependent on magic)
34  *	26	(con't)
35  *	27	(con't)
36  *	28	(con't)
37  *	32-33	d8		(vfp register d8)
38  *	34-35	d9		(vfp register d9)
39  *	36-37	d10		(vfp register d10)
40  *	38-39	d11		(vfp register d11)
41  *	40-41	d12		(vfp register d12)
42  *	42-43	d13		(vfp register d13)
43  *	44-45	d14		(vfp register d14)
44  *	46-47	d15		(vfp register d15)
45  *
46  * The magic number identifies the jmp_buf and
47  * how the buffer was created as well as providing
48  * a sanity check
49  *
50  * A side note I should mention - Please do not tamper
51  * with the floating point fields. While they are
52  * always saved and restored at the moment this cannot
53  * be garenteed especially if the compiler happens
54  * to be generating soft-float code so no fp
55  * registers will be used.
56  *
57  * Whilst this can be seen an encouraging people to
58  * use the setjmp buffer in this way I think that it
59  * is for the best then if changes occur compiles will
60  * break rather than just having new builds falling over
61  * mysteriously.
62  */
63 
64 #define _JB_MAGIC__SETJMP	0x4278f500
65 #define _JB_MAGIC_SETJMP	0x4278f501
66 #define _JB_MAGIC__SETJMP_VFP	0x4278f502
67 #define _JB_MAGIC_SETJMP_VFP	0x4278f503
68 
69 /* Valid for all jmp_buf's */
70 
71 #define _JB_MAGIC		 0
72 #define _JB_REG_FPSCR		13
73 #define _JB_REG_R4		14
74 #define _JB_REG_R5		15
75 #define _JB_REG_R6		16
76 #define _JB_REG_R7		17
77 #define _JB_REG_R8		18
78 #define _JB_REG_R9		19
79 #define _JB_REG_R10		20
80 #define _JB_REG_R11		21
81 #define _JB_REG_R12		22
82 #define _JB_REG_R13		23
83 #define _JB_REG_R14		24
84 
85 /* Only valid with the _JB_MAGIC_SETJMP magic */
86 
87 #define _JB_SIGMASK		25
88 
89 #define	_JB_REG_D8		32
90 #define	_JB_REG_D9		34
91 #define	_JB_REG_D10		36
92 #define	_JB_REG_D11		38
93 #define	_JB_REG_D12		40
94 #define	_JB_REG_D13		42
95 #define	_JB_REG_D14		44
96 #define	_JB_REG_D15		46
97 
98 #ifndef __ASSEMBLER__
99 #if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE
100 typedef struct _sigjmp_buf { int _sjb[_JBLEN + 1]; } sigjmp_buf[1];
101 #endif
102 
103 typedef struct _jmp_buf { int _jb[_JBLEN + 1]; } jmp_buf[1];
104 #endif
105 
106 #endif /* !_MACHINE_SETJMP_H_ */
107