]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/_setjmp.s
xnu-344.32.tar.gz
[apple/xnu.git] / osfmk / ppc / _setjmp.s
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
de355530
A
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
1c79356b 11 *
de355530
A
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
de355530
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * @OSF_COPYRIGHT@
24 */
25
26/*
27 * C library -- _setjmp, _longjmp
28 *
29 * _longjmp(a,v)
30 * will generate a "return(v)" from
31 * the last call to
32 * _setjmp(a)
33 * by restoring registers from the stack,
34 * The previous signal state is NOT restored.
35 *
36 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
37 * (which needs to know where to find the destination address)
38 */
39
40#include <ppc/asm.h>
41
42/*
43 * setjmp : ARG0 (r3) contains the address of
44 * the structure where we are to
45 * store the context
46 * Uses r0 as scratch register
47 *
48 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
49 * (which needs to know where to find the destination address)
50 */
51
52ENTRY(_setjmp,TAG_NO_FRAME_USED)
53 /* first entry is used for r1 - stack ptr */
54 stw r13, 4(ARG0) /* GPR context. We avoid multiple-word */
55 stw r14, 8(ARG0) /* instructions as they're slower (?) */
56 stw r15, 12(ARG0)
57 stw r16, 16(ARG0)
58 stw r17, 20(ARG0)
59 stw r18, 24(ARG0)
60 stw r19, 28(ARG0)
61 stw r20, 32(ARG0)
62 stw r21, 36(ARG0)
63 stw r22, 40(ARG0)
64 stw r23, 44(ARG0)
65 stw r24, 48(ARG0)
66 stw r25, 52(ARG0)
67 stw r26, 56(ARG0)
68 stw r27, 60(ARG0)
69 stw r28, 64(ARG0)
70 stw r29, 68(ARG0)
71 stw r30, 72(ARG0)
72 stw r31, 76(ARG0)
73
74 mfcr r0
75 stw r0, 80(ARG0) /* Condition register */
76
77 mflr r0
78 stw r0, 84(ARG0) /* Link register */
79
80 mfxer r0
81 stw r0, 88(ARG0) /* Fixed point exception register */
82
83#if FLOATING_POINT_SUPPORT /* TODO NMGS probably not needed for kern */
84 mffs r0
85 stw r0, 92(ARG0) /* Floating point status register */
86
87 stfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
88 stfd f15, 104(ARG0)
89 stfd f16, 112(ARG0)
90 stfd f17, 120(ARG0)
91 stfd f18, 138(ARG0)
92 stfd f19, 146(ARG0)
93 stfd f20, 144(ARG0)
94 stfd f21, 152(ARG0)
95 stfd f22, 160(ARG0)
96 stfd f23, 178(ARG0)
97 stfd f24, 186(ARG0)
98 stfd f25, 184(ARG0)
99 stfd f26, 192(ARG0)
100 stfd f27, 200(ARG0)
101 stfd f28, 218(ARG0)
102 stfd f29, 226(ARG0)
103 stfd f30, 224(ARG0)
104 stfd f31, 232(ARG0)
105
106#endif
107
108 stw r1, 0(ARG0) /* finally, save the stack pointer */
109 li ARG0, 0 /* setjmp must return zero */
110 blr
111
112/*
113 * longjmp : ARG0 (r3) contains the address of
114 * the structure from where we are to
115 * restore the context.
116 * ARG1 (r4) contains the non-zero
117 * value that we must return to
118 * that context.
119 * Uses r0 as scratch register
120 *
121 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
122 * (which needs to know where to find the destination address)
123 */
124
125ENTRY(_longjmp, TAG_NO_FRAME_USED) /* TODO NMGS - need correct tag */
126 lwz r13, 4(ARG0) /* GPR context. We avoid multiple-word */
127 lwz r14, 8(ARG0) /* instructions as they're slower (?) */
128 lwz r15, 12(ARG0)
129 lwz r16, 16(ARG0)
130 lwz r17, 20(ARG0)
131 lwz r18, 24(ARG0)
132 lwz r19, 28(ARG0)
133 lwz r20, 32(ARG0)
134 lwz r21, 36(ARG0)
135 lwz r22, 40(ARG0)
136 lwz r23, 44(ARG0)
137 lwz r24, 48(ARG0)
138 lwz r25, 52(ARG0)
139 lwz r26, 56(ARG0)
140 lwz r27, 60(ARG0)
141 lwz r28, 64(ARG0)
142 lwz r29, 68(ARG0)
143 lwz r30, 72(ARG0)
144 lwz r31, 76(ARG0)
145
146 lwz r0, 80(ARG0) /* Condition register */
147 mtcr r0 /* Use r5 as scratch register */
148
149 lwz r0, 84(ARG0) /* Link register */
150 mtlr r0
151
152 lwz r0, 88(ARG0) /* Fixed point exception register */
153 mtxer r0
154
155#ifdef FLOATING_POINT_SUPPORT
156 lwz r0, 92(ARG0) /* Floating point status register */
157 mtfs r0
158
159 lfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
160 lfd f15, 104(ARG0)
161 lfd f16, 112(ARG0)
162 lfd f17, 120(ARG0)
163 lfd f18, 128(ARG0)
164 lfd f19, 136(ARG0)
165 lfd f20, 144(ARG0)
166 lfd f21, 152(ARG0)
167 lfd f22, 160(ARG0)
168 lfd f23, 168(ARG0)
169 lfd f24, 176(ARG0)
170 lfd f25, 184(ARG0)
171 lfd f26, 192(ARG0)
172 lfd f27, 200(ARG0)
173 lfd f28, 208(ARG0)
174 lfd f29, 216(ARG0)
175 lfd f30, 224(ARG0)
176 lfd f31, 232(ARG0)
177
178#endif /* FLOATING_POINT_SUPPORT */
179
180
181 lwz r1, 0(ARG0) /* finally, restore the stack pointer */
182
183 mr. ARG0, ARG1 /* set the return value */
184 bnelr /* return if non-zero */
185
186 li ARG0, 1
187 blr /* never return 0, return 1 instead */
188