2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
35 * C library -- _setjmp, _longjmp
38 * will generate a "return(v)" from
41 * by restoring registers from the stack,
42 * The previous signal state is NOT restored.
44 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
45 * (which needs to know where to find the destination address)
48 #include <mach/machine/asm.h>
50 .private_extern _longjmp
51 .private_extern _setjmp
54 * setjmp : ARG0 (r3) contains the address of
55 * the structure where we are to
57 * Uses r0 as scratch register
59 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
60 * (which needs to know where to find the destination address)
63 ENTRY(setjmp,TAG_NO_FRAME_USED)
64 /* first entry is used for r1 - stack ptr */
65 stw r13, 4(ARG0) /* GPR context. We avoid multiple-word */
66 stw r14, 8(ARG0) /* instructions as they're slower (?) */
86 stw r0, 80(ARG0) /* Condition register */
89 stw r0, 84(ARG0) /* Link register */
92 stw r0, 88(ARG0) /* Fixed point exception register */
94 #if FLOATING_POINT_SUPPORT /* TODO NMGS probably not needed for kern */
95 mffs f0 /* get FPSCR in low 32 bits of f0 */
96 stfiwx f0, 92(ARG0) /* Floating point status register */
98 stfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
119 stw r1, 0(ARG0) /* finally, save the stack pointer */
120 li ARG0, 0 /* setjmp must return zero */
124 * longjmp : ARG0 (r3) contains the address of
125 * the structure from where we are to
126 * restore the context.
127 * ARG1 (r4) contains the non-zero
128 * value that we must return to
130 * Uses r0 as scratch register
132 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
133 * (which needs to know where to find the destination address)
136 ENTRY(longjmp, TAG_NO_FRAME_USED) /* TODO NMGS - need correct tag */
137 lwz r13, 4(ARG0) /* GPR context. We avoid multiple-word */
138 lwz r14, 8(ARG0) /* instructions as they're slower (?) */
157 lwz r0, 80(ARG0) /* Condition register */
158 mtcr r0 /* Use r5 as scratch register */
160 lwz r0, 84(ARG0) /* Link register */
163 lwz r0, 88(ARG0) /* Fixed point exception register */
166 #ifdef FLOATING_POINT_SUPPORT
167 lfd f0, 92-4(ARG0) /* get Floating point status register in low 32 bits of f0 */
168 mtfsf 0xFF,f0 /* restore FPSCR */
170 lfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
189 #endif /* FLOATING_POINT_SUPPORT */
192 lwz r1, 0(ARG0) /* finally, restore the stack pointer */
194 mr. ARG0, ARG1 /* set the return value */
195 bnelr /* return if non-zero */
198 blr /* never return 0, return 1 instead */