2 * Copyright (c) 2020 Apple 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@
26 #include <TargetConditionals.h>
30 #if TARGET_OS_OSX || TARGET_OS_DRIVERKIT
32 /* Helper macro for unmunging pointers in place */
33 .macro PTR_UNMUNGE addr
35 _OS_PTR_MUNGE_TOKEN(x16, x16)
37 _OS_PTR_MUNGE_TOKEN(x16, w16)
39 _OS_PTR_UNMUNGE(\addr, \addr, x16)
42 .macro CALL_USER_FUNC func
43 // Populate the first 8 arguments in registers from the stack. Coordinated
44 // with makecontext which populates the arguments on the stack
46 ldp w2, w3, [sp, #-24]
47 ldp w4, w5, [sp, #-16]
52 #if defined(__arm64e__)
59 .private_extern __ctx_start
62 /* x20 = munged signed user func,
65 * sp = where args end */
68 /* user function returned, set up stack for _ctx_done */
70 /* Reset to top of stack */
73 mov x0, x19 /* x0 = uctx */
76 brk #666 /* Should not get here */