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