2 * Copyright (c) 1999 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@
24 /* int _setjmp(jmp_buf env); */
26 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
28 * File: sys/ppc/_setjmp.s
30 * Implements _setjmp()
33 * 8 September 1998 Matt Watson (mwatson@apple.com)
34 * Created. Derived from setjmp.s
38 #include <architecture/ppc/asm_help.h>
43 /* special flag bit definitions copied from /osfmk/ppc/thread_act.h */
45 #define floatUsedbit 1
46 #define vectorUsedbit 2
48 #define FlagsFastTrap 0x7FF3
72 mfctr r6 ; XXX ctr is volatile
75 mfxer r7 ; XXX xer is volatile
83 mr r31,r3 ; save jmp_buf ptr
85 sc ; get FPR-inuse and VR-inuse flags from kernel
86 rlwinm r4,r3,0,floatUsedbit,floatUsedbit
87 rlwinm. r5,r3,0,vectorUsedbit,vectorUsedbit
88 cmpwi cr1,r4,0 ; set CR1 bne iff FPRs in use
90 stw r31,JMP_addr_at_setjmp(r31)
91 mr r3,r31 ; restore jmp_buf ptr
93 beq LSaveFPRsIfNecessary ; skip if vectorUsedbit was 0
95 ; must save VRs and VRSAVE
98 andi. r0,r4,0xFFF ; we only care about v20-v31
99 stw r0,JMP_vrsave(r3) ; set up effective VRSAVE
100 beq LSaveFPRsIfNecessary ; no live non-volatile VRs
101 addi r6,r3,JMP_vr_base_addr
126 ; must save FPRs if they are live in this thread
127 ; CR1 = bne iff FPRs are in use
129 LSaveFPRsIfNecessary:
130 beq cr1,LExit ; FPRs not in use
131 addi r6,r3,JMP_fp_base_addr
132 rlwinm r6,r6,0,0,27 ; mask off low 4 bits to qw align