]> git.saurik.com Git - apple/xnu.git/blame_incremental - libsyscall/custom/SYS.h
xnu-1228.7.58.tar.gz
[apple/xnu.git] / libsyscall / custom / SYS.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 1999-2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
29 *
30 * File: SYS.h
31 *
32 * Definition of the user side of the UNIX system call interface
33 * for M98K.
34 *
35 * Errors are flagged by the location of the trap return (ie., which
36 * instruction is executed upon rfi):
37 *
38 * SC PC + 4: Error (typically branch to cerror())
39 * SC PC + 8: Success
40 *
41 * HISTORY
42 * 18-Nov-92 Ben Fathi (benf@next.com)
43 * Ported to m98k.
44 *
45 * 9-Jan-92 Peter King (king@next.com)
46 * Created.
47 */
48
49#include <sys/syscall.h>
50
51#ifndef SYS_setquota
52#define SYS_setquota 148
53#endif
54#ifndef SYS_quota
55#define SYS_quota 149
56#endif
57
58#if defined(__ppc__) || defined(__ppc64__)
59
60#include <architecture/ppc/mode_independent_asm.h>
61
62/* From rhapsody kernel mach/ppc/syscall_sw.h */
63#define kernel_trap_args_0
64#define kernel_trap_args_1
65#define kernel_trap_args_2
66#define kernel_trap_args_3
67#define kernel_trap_args_4
68#define kernel_trap_args_5
69#define kernel_trap_args_6
70#define kernel_trap_args_7
71#define kernel_trap_args_8
72/* End of rhapsody kernel mach/ppc/syscall_sw.h */
73
74/*
75 * Macros.
76 */
77
78#define SYSCALL(name, nargs) \
79 .globl cerror @\
80 MI_ENTRY_POINT(_##name) @\
81 kernel_trap_args_##nargs @\
82 li r0,SYS_##name @\
83 sc @\
84 b 1f @\
85 blr @\
861: MI_BRANCH_EXTERNAL(cerror)
87
88
89#define SYSCALL_NONAME(name, nargs) \
90 .globl cerror @\
91 kernel_trap_args_##nargs @\
92 li r0,SYS_##name @\
93 sc @\
94 b 1f @\
95 b 2f @\
961: MI_BRANCH_EXTERNAL(cerror) @\
972:
98
99
100#define PSEUDO(pseudo, name, nargs) \
101 .private_extern _##pseudo @\
102 .text @\
103 .align 2 @\
104_##pseudo: @\
105 SYSCALL_NONAME(name, nargs)
106
107#define __SYSCALL(pseudo, name, nargs) \
108 PSEUDO(pseudo, name, nargs) @\
109 blr
110
111#elif defined(__i386__)
112
113#include <architecture/i386/asm_help.h>
114#include <mach/i386/syscall_sw.h>
115
116/*
117 * We have two entry points. int's is used for syscalls which need to preserve
118 * %ecx across the call, or return a 64-bit value in %eax:%edx. sysenter is used
119 * for the majority of syscalls which just return a value in %eax.
120 */
121
122#define UNIX_SYSCALL_SYSENTER call __sysenter_trap
123#define UNIX_SYSCALL(name, nargs) \
124 .globl cerror ;\
125LEAF(_##name, 0) ;\
126 movl $ SYS_##name, %eax ;\
127 UNIX_SYSCALL_SYSENTER ;\
128 jnb 2f ;\
129 BRANCH_EXTERN(cerror) ;\
1302:
131
132#define UNIX_SYSCALL_INT(name, nargs) \
133 .globl cerror ;\
134LEAF(_##name, 0) ;\
135 movl $ SYS_##name, %eax ;\
136 UNIX_SYSCALL_TRAP ;\
137 jnb 2f ;\
138 BRANCH_EXTERN(cerror) ;\
1392:
140
141#if defined(__SYSCALL_32BIT_ARG_BYTES) && ((__SYSCALL_32BIT_ARG_BYTES >= 4) && (__SYSCALL_32BIT_ARG_BYTES <= 20))
142#define UNIX_SYSCALL_NONAME(name, nargs) \
143 movl $(SYS_##name | (__SYSCALL_32BIT_ARG_BYTES << I386_SYSCALL_ARG_BYTES_SHIFT)), %eax ;\
144 UNIX_SYSCALL_SYSENTER ;\
145 jnb 2f ;\
146 BRANCH_EXTERN(cerror) ;\
1472:
148#else /* __SYSCALL_32BIT_ARG_BYTES < 4 || > 20 */
149#define UNIX_SYSCALL_NONAME(name, nargs) \
150 .globl cerror ;\
151 movl $ SYS_##name, %eax ;\
152 UNIX_SYSCALL_SYSENTER ;\
153 jnb 2f ;\
154 BRANCH_EXTERN(cerror) ;\
1552:
156#endif
157
158#define UNIX_SYSCALL_INT_NONAME(name, nargs) \
159 .globl cerror ;\
160 movl $ SYS_##name, %eax ;\
161 UNIX_SYSCALL_TRAP ;\
162 jnb 2f ;\
163 BRANCH_EXTERN(cerror) ;\
1642:
165
166#define PSEUDO(pseudo, name, nargs) \
167LEAF(_##pseudo, 0) ;\
168 UNIX_SYSCALL_NONAME(name, nargs)
169
170#define PSEUDO_INT(pseudo, name, nargs) \
171LEAF(_##pseudo, 0) ;\
172 UNIX_SYSCALL_INT_NONAME(name, nargs)
173
174#define __SYSCALL(pseudo, name, nargs) \
175 PSEUDO(pseudo, name, nargs) ;\
176 ret
177
178#define __SYSCALL_INT(pseudo, name, nargs) \
179 PSEUDO_INT(pseudo, name, nargs) ;\
180 ret
181
182#elif defined(__x86_64__)
183
184#include <architecture/i386/asm_help.h>
185#include <mach/i386/syscall_sw.h>
186
187#define UNIX_SYSCALL_SYSCALL \
188 movq %rcx, %r10 ;\
189 syscall
190
191#define UNIX_SYSCALL(name, nargs) \
192 .globl cerror ;\
193LEAF(_##name, 0) ;\
194 movl $ SYSCALL_CONSTRUCT_UNIX(SYS_##name), %eax ;\
195 UNIX_SYSCALL_SYSCALL ;\
196 jnb 2f ;\
197 BRANCH_EXTERN(cerror) ;\
1982:
199
200#define UNIX_SYSCALL_NONAME(name, nargs) \
201 .globl cerror ;\
202 movl $ SYSCALL_CONSTRUCT_UNIX(SYS_##name), %eax ;\
203 UNIX_SYSCALL_SYSCALL ;\
204 jnb 2f ;\
205 BRANCH_EXTERN(cerror) ;\
2062:
207
208#define PSEUDO(pseudo, name, nargs) \
209LEAF(_##pseudo, 0) ;\
210 UNIX_SYSCALL_NONAME(name, nargs)
211
212#define __SYSCALL(pseudo, name, nargs) \
213 PSEUDO(pseudo, name, nargs) ;\
214 ret
215
216#else
217#error Unsupported architecture
218#endif