2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
33 * C library -- _setjmp, _longjmp
36 * will generate a "return(v)" from
39 * by restoring registers from the stack,
40 * The previous signal state is NOT restored.
42 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
43 * (which needs to know where to find the destination address)
46 #include <mach/machine/asm.h>
48 .private_extern _longjmp
49 .private_extern _setjmp
52 * setjmp : ARG0 (r3) contains the address of
53 * the structure where we are to
55 * Uses r0 as scratch register
57 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
58 * (which needs to know where to find the destination address)
61 ENTRY(setjmp,TAG_NO_FRAME_USED)
62 /* first entry is used for r1 - stack ptr */
63 stw r13, 4(ARG0) /* GPR context. We avoid multiple-word */
64 stw r14, 8(ARG0) /* instructions as they're slower (?) */
84 stw r0, 80(ARG0) /* Condition register */
87 stw r0, 84(ARG0) /* Link register */
90 stw r0, 88(ARG0) /* Fixed point exception register */
92 #if FLOATING_POINT_SUPPORT /* TODO NMGS probably not needed for kern */
93 mffs f0 /* get FPSCR in low 32 bits of f0 */
94 stfiwx f0, 92(ARG0) /* Floating point status register */
96 stfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
117 stw r1, 0(ARG0) /* finally, save the stack pointer */
118 li ARG0, 0 /* setjmp must return zero */
122 * longjmp : ARG0 (r3) contains the address of
123 * the structure from where we are to
124 * restore the context.
125 * ARG1 (r4) contains the non-zero
126 * value that we must return to
128 * Uses r0 as scratch register
130 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
131 * (which needs to know where to find the destination address)
134 ENTRY(longjmp, TAG_NO_FRAME_USED) /* TODO NMGS - need correct tag */
135 lwz r13, 4(ARG0) /* GPR context. We avoid multiple-word */
136 lwz r14, 8(ARG0) /* instructions as they're slower (?) */
155 lwz r0, 80(ARG0) /* Condition register */
156 mtcr r0 /* Use r5 as scratch register */
158 lwz r0, 84(ARG0) /* Link register */
161 lwz r0, 88(ARG0) /* Fixed point exception register */
164 #ifdef FLOATING_POINT_SUPPORT
165 lfd f0, 92-4(ARG0) /* get Floating point status register in low 32 bits of f0 */
166 mtfsf 0xFF,f0 /* restore FPSCR */
168 lfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
187 #endif /* FLOATING_POINT_SUPPORT */
190 lwz r1, 0(ARG0) /* finally, restore the stack pointer */
192 mr. ARG0, ARG1 /* set the return value */
193 bnelr /* return if non-zero */
196 blr /* never return 0, return 1 instead */