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