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
37 /* We use mode-independent "g" opcodes such as "stg", and/or
38 * mode-independent macros such as MI_GET_ADDRESS. These expand
39 * into word operations when targeting __ppc__, and into doubleword
40 * operations when targeting __ppc64__.
42 #include <architecture/ppc/mode_independent_asm.h>
44 #define __APPLE_API_PRIVATE
45 #include <machine/cpu_capabilities.h>
46 #undef __APPLE_API_PRIVATE
53 MI_ENTRY_POINT(__setjmp)
54 lbz r7, _COMM_PAGE_ALTIVEC(0) ; get "AltiVec available" flag
65 mfcr r0 ; we only need to save cr2-cr4
82 addi r6,r3,JMP_fp_base_addr ; point to base of FPR save area
83 stg r3,JMP_addr_at_setjmp(r3) ; remember original address of jmpbuf
84 clrrgi r6,r6,4 ; mask off low 4 bits to qw align
104 stfd f0,JMP_fpscr(r3) ; save fpscr in non-sliding region of jmpbuf
106 cmpwi r7,0 ; is AltiVec available? (test _COMM_PAGE_ALTIVEC)
107 addi r6,r3,JMP_vr_base_addr ; get base address of VR save area
108 addi r8,r3,JMP_vrsave ; we'll need this address below
109 li r3,0 ; set return value (always 0 on setjmp)
110 beqlr-- ; exit if no Altivec
112 mfspr r4,VRSave ; AltiVec available, so get VRSAVE mask
113 andi. r0,r4,0xFFF ; we only care about v20-v31
114 stg r0,0(r8) ; save effective VRSAVE in JMP_vrsave
115 beqlr++ ; if no live non-volatile VRs, we're done