xref: /xnu-10002.1.13/libsyscall/wrappers/varargs_wrappers.s (revision 1031c584a5e37aff177559b9f69dbd3c8c3fd30a)
1*1031c584SApple OSS Distributions/*
2*1031c584SApple OSS Distributions * Copyright (c) 2011-2013 Apple Inc. All rights reserved.
3*1031c584SApple OSS Distributions *
4*1031c584SApple OSS Distributions * @APPLE_LICENSE_HEADER_START@
5*1031c584SApple OSS Distributions *
6*1031c584SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code
7*1031c584SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License
8*1031c584SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in
9*1031c584SApple OSS Distributions * compliance with the License. Please obtain a copy of the License at
10*1031c584SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this
11*1031c584SApple OSS Distributions * file.
12*1031c584SApple OSS Distributions *
13*1031c584SApple OSS Distributions * The Original Code and all software distributed under the License are
14*1031c584SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15*1031c584SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16*1031c584SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17*1031c584SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18*1031c584SApple OSS Distributions * Please see the License for the specific language governing rights and
19*1031c584SApple OSS Distributions * limitations under the License.
20*1031c584SApple OSS Distributions *
21*1031c584SApple OSS Distributions * @APPLE_LICENSE_HEADER_END@
22*1031c584SApple OSS Distributions */
23*1031c584SApple OSS Distributions
24*1031c584SApple OSS Distributions#ifdef __arm64__
25*1031c584SApple OSS Distributions
26*1031c584SApple OSS Distributions#include "../custom/SYS.h"
27*1031c584SApple OSS Distributions#include <mach/arm64/asm.h>
28*1031c584SApple OSS Distributions
29*1031c584SApple OSS Distributions/*
30*1031c584SApple OSS Distributions * Stubs are to handle the ARM64 ABI for variadic functions'
31*1031c584SApple OSS Distributions * not matching the ABI used by the system call handler.
32*1031c584SApple OSS Distributions */
33*1031c584SApple OSS Distributions
34*1031c584SApple OSS Distributions/*
35*1031c584SApple OSS Distributions *	sem_t* sem_open(const char *name, int oflag, ...);
36*1031c584SApple OSS Distributions *	sem_t* __sem_open(const char *name, int oflag, int mode, int value);
37*1031c584SApple OSS Distributions */
38*1031c584SApple OSS DistributionsMI_ENTRY_POINT(_sem_open)
39*1031c584SApple OSS Distributions	ARM64_STACK_PROLOG
40*1031c584SApple OSS Distributions	PUSH_FRAME
41*1031c584SApple OSS Distributions#if __LP64__
42*1031c584SApple OSS Distributions	ldp	x2, x3, [fp, #16]
43*1031c584SApple OSS Distributions#else
44*1031c584SApple OSS Distributions	ldp	w2, w3, [fp, #16]
45*1031c584SApple OSS Distributions#endif
46*1031c584SApple OSS Distributions	MI_CALL_EXTERNAL(___sem_open)
47*1031c584SApple OSS Distributions#if !__LP64__
48*1031c584SApple OSS Distributions	/* xnu returns a 64-bit '-1' on failure, but pointers must have the high
49*1031c584SApple OSS Distributions	 * 32-bits set to zero. The following instruction is equivalent to
50*1031c584SApple OSS Distributions	 * masking off the top 32-bits.
51*1031c584SApple OSS Distributions	 */
52*1031c584SApple OSS Distributions	mov w0, w0
53*1031c584SApple OSS Distributions#endif
54*1031c584SApple OSS Distributions	POP_FRAME
55*1031c584SApple OSS Distributions	ARM64_STACK_EPILOG
56*1031c584SApple OSS Distributions
57*1031c584SApple OSS Distributions/*
58*1031c584SApple OSS Distributions * int shm_open(const char *, int, ...);
59*1031c584SApple OSS Distributions * int __shm_open(const char*, int oflag, int mode);
60*1031c584SApple OSS Distributions */
61*1031c584SApple OSS DistributionsMI_ENTRY_POINT(_shm_open)
62*1031c584SApple OSS Distributions	ARM64_STACK_PROLOG
63*1031c584SApple OSS Distributions	PUSH_FRAME
64*1031c584SApple OSS Distributions#if __LP64__
65*1031c584SApple OSS Distributions	ldr	x2, [fp, #16]
66*1031c584SApple OSS Distributions#else
67*1031c584SApple OSS Distributions	ldr	w2, [fp, #16]
68*1031c584SApple OSS Distributions#endif
69*1031c584SApple OSS Distributions	MI_CALL_EXTERNAL(___shm_open)
70*1031c584SApple OSS Distributions	POP_FRAME
71*1031c584SApple OSS Distributions	ARM64_STACK_EPILOG
72*1031c584SApple OSS Distributions
73*1031c584SApple OSS Distributions/*
74*1031c584SApple OSS Distributions * int msgsys(int, ...);
75*1031c584SApple OSS Distributions * int __msgsys(int which, int a2, int a3, int a4, int a5);
76*1031c584SApple OSS Distributions */
77*1031c584SApple OSS DistributionsMI_ENTRY_POINT(_msgsys)
78*1031c584SApple OSS Distributions	ARM64_STACK_PROLOG
79*1031c584SApple OSS Distributions	PUSH_FRAME
80*1031c584SApple OSS Distributions#if __LP64__
81*1031c584SApple OSS Distributions	ldp	x1, x2, [fp, #16]
82*1031c584SApple OSS Distributions	ldp	x3, x4, [fp, #32]
83*1031c584SApple OSS Distributions#else
84*1031c584SApple OSS Distributions	ldp	w1, w2, [fp, #16]
85*1031c584SApple OSS Distributions	ldp	w3, w4, [fp, #24]
86*1031c584SApple OSS Distributions#endif
87*1031c584SApple OSS Distributions	MI_CALL_EXTERNAL(___msgsys)
88*1031c584SApple OSS Distributions	POP_FRAME
89*1031c584SApple OSS Distributions
90*1031c584SApple OSS Distributions/*
91*1031c584SApple OSS Distributions * int semsys(int, ...);
92*1031c584SApple OSS Distributions * int __semsys(int which, int a2, int a3, int a4, int a5);
93*1031c584SApple OSS Distributions */
94*1031c584SApple OSS DistributionsMI_ENTRY_POINT(_semsys)
95*1031c584SApple OSS Distributions	ARM64_STACK_PROLOG
96*1031c584SApple OSS Distributions	PUSH_FRAME
97*1031c584SApple OSS Distributions#if __LP64__
98*1031c584SApple OSS Distributions	ldp	x1, x2, [fp, #16]
99*1031c584SApple OSS Distributions	ldp	x3, x4, [fp, #32]
100*1031c584SApple OSS Distributions#else
101*1031c584SApple OSS Distributions	ldp	w1, w2, [fp, #16]
102*1031c584SApple OSS Distributions	ldp	w3, w4, [fp, #24]
103*1031c584SApple OSS Distributions#endif
104*1031c584SApple OSS Distributions	MI_CALL_EXTERNAL(___semsys)
105*1031c584SApple OSS Distributions	POP_FRAME
106*1031c584SApple OSS Distributions	ARM64_STACK_EPILOG
107*1031c584SApple OSS Distributions
108*1031c584SApple OSS Distributions/*
109*1031c584SApple OSS Distributions * int	semctl(int, int, int, ...);
110*1031c584SApple OSS Distributions * int __semctl(int semid, int semnum, int cmd, semun_t arg);
111*1031c584SApple OSS Distributions */
112*1031c584SApple OSS Distributions MI_ENTRY_POINT(_semctl)
113*1031c584SApple OSS Distributions	ARM64_STACK_PROLOG
114*1031c584SApple OSS Distributions	PUSH_FRAME
115*1031c584SApple OSS Distributions#if __LP64__
116*1031c584SApple OSS Distributions	ldr	x3, [fp, #16]
117*1031c584SApple OSS Distributions#else
118*1031c584SApple OSS Distributions	ldr	w3, [fp, #16]
119*1031c584SApple OSS Distributions#endif
120*1031c584SApple OSS Distributions	MI_CALL_EXTERNAL(___semctl)
121*1031c584SApple OSS Distributions	POP_FRAME
122*1031c584SApple OSS Distributions	ARM64_STACK_EPILOG
123*1031c584SApple OSS Distributions
124*1031c584SApple OSS Distributions/*
125*1031c584SApple OSS Distributions * int	shmsys(int, ...);
126*1031c584SApple OSS Distributions * int __shmsys(int which, int a2, int a3, int a4);
127*1031c584SApple OSS Distributions */
128*1031c584SApple OSS Distributions MI_ENTRY_POINT(_shmsys)
129*1031c584SApple OSS Distributions	ARM64_STACK_PROLOG
130*1031c584SApple OSS Distributions	PUSH_FRAME
131*1031c584SApple OSS Distributions#if __LP64__
132*1031c584SApple OSS Distributions	ldp	x1, x2, [fp, #16]
133*1031c584SApple OSS Distributions	ldr	x3, [fp, #32]
134*1031c584SApple OSS Distributions#else
135*1031c584SApple OSS Distributions	ldp	w1, w2, [fp, #16]
136*1031c584SApple OSS Distributions	ldr	w3, [fp, #24]
137*1031c584SApple OSS Distributions#endif
138*1031c584SApple OSS Distributions	MI_CALL_EXTERNAL(___shmsys)
139*1031c584SApple OSS Distributions	POP_FRAME
140*1031c584SApple OSS Distributions	ARM64_STACK_EPILOG
141*1031c584SApple OSS Distributions
142*1031c584SApple OSS Distributions#endif /* defined(__arm64__) */
143