2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
27 * C library -- _setjmp, _longjmp
30 * will generate a "return(v)" from
33 * by restoring registers from the stack,
34 * The previous signal state is NOT restored.
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)
40 #include <mach/machine/asm.h>
42 .private_extern _longjmp
43 .private_extern _setjmp
46 * setjmp : ARG0 (r3) contains the address of
47 * the structure where we are to
49 * Uses r0 as scratch register
51 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
52 * (which needs to know where to find the destination address)
55 ENTRY(setjmp,TAG_NO_FRAME_USED)
56 /* first entry is used for r1 - stack ptr */
57 stw r13, 4(ARG0) /* GPR context. We avoid multiple-word */
58 stw r14, 8(ARG0) /* instructions as they're slower (?) */
78 stw r0, 80(ARG0) /* Condition register */
81 stw r0, 84(ARG0) /* Link register */
84 stw r0, 88(ARG0) /* Fixed point exception register */
86 #if FLOATING_POINT_SUPPORT /* TODO NMGS probably not needed for kern */
88 stw r0, 92(ARG0) /* Floating point status register */
90 stfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
111 stw r1, 0(ARG0) /* finally, save the stack pointer */
112 li ARG0, 0 /* setjmp must return zero */
116 * longjmp : ARG0 (r3) contains the address of
117 * the structure from where we are to
118 * restore the context.
119 * ARG1 (r4) contains the non-zero
120 * value that we must return to
122 * Uses r0 as scratch register
124 * NOTE : MUST BE KEPT CONSISTENT WITH gdb/config/powerpc/tm-ppc-eabi.h
125 * (which needs to know where to find the destination address)
128 ENTRY(longjmp, TAG_NO_FRAME_USED) /* TODO NMGS - need correct tag */
129 lwz r13, 4(ARG0) /* GPR context. We avoid multiple-word */
130 lwz r14, 8(ARG0) /* instructions as they're slower (?) */
149 lwz r0, 80(ARG0) /* Condition register */
150 mtcr r0 /* Use r5 as scratch register */
152 lwz r0, 84(ARG0) /* Link register */
155 lwz r0, 88(ARG0) /* Fixed point exception register */
158 #ifdef FLOATING_POINT_SUPPORT
159 lwz r0, 92(ARG0) /* Floating point status register */
162 lfd f14, 96(ARG0) /* Floating point context - 8 byte aligned */
181 #endif /* FLOATING_POINT_SUPPORT */
184 lwz r1, 0(ARG0) /* finally, restore the stack pointer */
186 mr. ARG0, ARG1 /* set the return value */
187 bnelr /* return if non-zero */
190 blr /* never return 0, return 1 instead */