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)
49 * setjmp : ARG0 (r3) contains the address of
50 * the structure where we are to
52 * Uses r0 as scratch register
54 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
55 * (which needs to know where to find the destination address)
58 ENTRY(_setjmp,TAG_NO_FRAME_USED)
59 /* first entry is used for r1 - stack ptr */
60 stw r13, 4(ARG0) /* GPR context. We avoid multiple-word */
61 stw r14, 8(ARG0) /* instructions as they're slower (?) */
81 stw r0, 80(ARG0) /* Condition register */
84 stw r0, 84(ARG0) /* Link register */
87 stw r0, 88(ARG0) /* Fixed point exception register */
89 #if FLOATING_POINT_SUPPORT /* TODO NMGS probably not needed for kern */
90 mffs f0 /* get FPSCR in low 32 bits of f0 */
91 stfiwx f0, 92(ARG0) /* Floating point status register */
93 stfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
114 stw r1, 0(ARG0) /* finally, save the stack pointer */
115 li ARG0, 0 /* setjmp must return zero */
119 * longjmp : ARG0 (r3) contains the address of
120 * the structure from where we are to
121 * restore the context.
122 * ARG1 (r4) contains the non-zero
123 * value that we must return to
125 * Uses r0 as scratch register
127 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
128 * (which needs to know where to find the destination address)
131 ENTRY(_longjmp, TAG_NO_FRAME_USED) /* TODO NMGS - need correct tag */
132 lwz r13, 4(ARG0) /* GPR context. We avoid multiple-word */
133 lwz r14, 8(ARG0) /* instructions as they're slower (?) */
152 lwz r0, 80(ARG0) /* Condition register */
153 mtcr r0 /* Use r5 as scratch register */
155 lwz r0, 84(ARG0) /* Link register */
158 lwz r0, 88(ARG0) /* Fixed point exception register */
161 #ifdef FLOATING_POINT_SUPPORT
162 lfd f0, 92-4(ARG0) /* get Floating point status register in low 32 bits of f0 */
163 mtfsf 0xFF,f0 /* restore FPSCR */
165 lfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
184 #endif /* FLOATING_POINT_SUPPORT */
187 lwz r1, 0(ARG0) /* finally, restore the stack pointer */
189 mr. ARG0, ARG1 /* set the return value */
190 bnelr /* return if non-zero */
193 blr /* never return 0, return 1 instead */