]>
git.saurik.com Git - apple/xnu.git/blob - libsyscall/custom/SYS.h
675fede15be647582815693e3d72f9ecb32091e6
2 * Copyright (c) 1999-2011 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
32 * Definition of the user side of the UNIX system call interface
35 * Errors are flagged by the location of the trap return (ie., which
36 * instruction is executed upon rfi):
38 * SC PC + 4: Error (typically branch to cerror())
42 * 18-Nov-92 Ben Fathi (benf@next.com)
45 * 9-Jan-92 Peter King (king@next.com)
49 #include <sys/syscall.h>
51 /* Binary compatibility stubs for syscalls that no longer exist */
54 #define SYS_setquota 148
62 #include <architecture/i386/asm_help.h>
63 #include <mach/i386/syscall_sw.h>
66 * We have two entry points. int's is used for syscalls which need to preserve
67 * %ecx across the call, or return a 64-bit value in %eax:%edx. sysenter is used
68 * for the majority of syscalls which just return a value in %eax.
71 #define UNIX_SYSCALL_SYSENTER call __sysenter_trap
72 #define UNIX_SYSCALL(name, nargs) \
75 movl $ SYS_##name, %eax ;\
76 UNIX_SYSCALL_SYSENTER ;\
78 BRANCH_EXTERN(cerror) ;\
81 #define UNIX_SYSCALL_INT(name, nargs) \
84 movl $ SYS_##name, %eax ;\
87 BRANCH_EXTERN(cerror) ;\
90 #if defined(__SYSCALL_32BIT_ARG_BYTES) && ((__SYSCALL_32BIT_ARG_BYTES >= 4) && (__SYSCALL_32BIT_ARG_BYTES <= 20))
91 #define UNIX_SYSCALL_NONAME(name, nargs, cerror) \
92 movl $(SYS_##name | (__SYSCALL_32BIT_ARG_BYTES << I386_SYSCALL_ARG_BYTES_SHIFT)), %eax ;\
93 UNIX_SYSCALL_SYSENTER ;\
95 BRANCH_EXTERN(cerror) ;\
97 #else /* __SYSCALL_32BIT_ARG_BYTES < 4 || > 20 */
98 #define UNIX_SYSCALL_NONAME(name, nargs, cerror) \
100 movl $ SYS_##name, %eax ;\
101 UNIX_SYSCALL_SYSENTER ;\
103 BRANCH_EXTERN(cerror) ;\
107 #define UNIX_SYSCALL_INT_NONAME(name, nargs) \
109 movl $ SYS_##name, %eax ;\
112 BRANCH_EXTERN(cerror_nocancel) ;\
115 #define PSEUDO(pseudo, name, nargs, cerror) \
117 UNIX_SYSCALL_NONAME(name, nargs, cerror)
119 #define PSEUDO_INT(pseudo, name, nargs) \
121 UNIX_SYSCALL_INT_NONAME(name, nargs)
123 #define __SYSCALL2(pseudo, name, nargs, cerror) \
124 PSEUDO(pseudo, name, nargs, cerror) ;\
127 #define __SYSCALL(pseudo, name, nargs) \
128 PSEUDO(pseudo, name, nargs, cerror) ;\
131 #define __SYSCALL_INT(pseudo, name, nargs) \
132 PSEUDO_INT(pseudo, name, nargs) ;\
135 #elif defined(__x86_64__)
137 #include <architecture/i386/asm_help.h>
138 #include <mach/i386/syscall_sw.h>
140 #define UNIX_SYSCALL_SYSCALL \
144 #define UNIX_SYSCALL(name, nargs) \
147 movl $ SYSCALL_CONSTRUCT_UNIX(SYS_##name), %eax ;\
148 UNIX_SYSCALL_SYSCALL ;\
150 BRANCH_EXTERN(cerror) ;\
153 #define UNIX_SYSCALL_NONAME(name, nargs, cerror) \
155 movl $ SYSCALL_CONSTRUCT_UNIX(SYS_##name), %eax ;\
156 UNIX_SYSCALL_SYSCALL ;\
158 BRANCH_EXTERN(cerror) ;\
161 #define PSEUDO(pseudo, name, nargs, cerror) \
163 UNIX_SYSCALL_NONAME(name, nargs, cerror)
165 #define __SYSCALL2(pseudo, name, nargs, cerror) \
166 PSEUDO(pseudo, name, nargs, cerror) ;\
169 #define __SYSCALL(pseudo, name, nargs) \
170 PSEUDO(pseudo, name, nargs, cerror) ;\
174 #error Unsupported architecture