2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
28 * C library -- _setjmp, _longjmp
31 * will generate a "return(v)" from
34 * by restoring registers from the stack,
35 * The previous signal state is NOT restored.
37 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
38 * (which needs to know where to find the destination address)
41 #include <mach/machine/asm.h>
43 .private_extern _longjmp
44 .private_extern _setjmp
47 * setjmp : ARG0 (r3) contains the address of
48 * the structure where we are to
50 * Uses r0 as scratch register
52 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
53 * (which needs to know where to find the destination address)
56 ENTRY(setjmp,TAG_NO_FRAME_USED)
57 /* first entry is used for r1 - stack ptr */
58 stw r13, 4(ARG0) /* GPR context. We avoid multiple-word */
59 stw r14, 8(ARG0) /* instructions as they're slower (?) */
79 stw r0, 80(ARG0) /* Condition register */
82 stw r0, 84(ARG0) /* Link register */
85 stw r0, 88(ARG0) /* Fixed point exception register */
87 #if FLOATING_POINT_SUPPORT /* TODO NMGS probably not needed for kern */
88 mffs f0 /* get FPSCR in low 32 bits of f0 */
89 stfiwx f0, 92(ARG0) /* Floating point status register */
91 stfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
112 stw r1, 0(ARG0) /* finally, save the stack pointer */
113 li ARG0, 0 /* setjmp must return zero */
117 * longjmp : ARG0 (r3) contains the address of
118 * the structure from where we are to
119 * restore the context.
120 * ARG1 (r4) contains the non-zero
121 * value that we must return to
123 * Uses r0 as scratch register
125 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
126 * (which needs to know where to find the destination address)
129 ENTRY(longjmp, TAG_NO_FRAME_USED) /* TODO NMGS - need correct tag */
130 lwz r13, 4(ARG0) /* GPR context. We avoid multiple-word */
131 lwz r14, 8(ARG0) /* instructions as they're slower (?) */
150 lwz r0, 80(ARG0) /* Condition register */
151 mtcr r0 /* Use r5 as scratch register */
153 lwz r0, 84(ARG0) /* Link register */
156 lwz r0, 88(ARG0) /* Fixed point exception register */
159 #ifdef FLOATING_POINT_SUPPORT
160 lfd f0, 92-4(ARG0) /* get Floating point status register in low 32 bits of f0 */
161 mtfsf 0xFF,f0 /* restore FPSCR */
163 lfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
182 #endif /* FLOATING_POINT_SUPPORT */
185 lwz r1, 0(ARG0) /* finally, restore the stack pointer */
187 mr. ARG0, ARG1 /* set the return value */
188 bnelr /* return if non-zero */
191 blr /* never return 0, return 1 instead */