]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/i386/syscall_sw.h
2 * Copyright (c) 2000-2006 Apple Computer, 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@
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
34 * All Rights Reserved.
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
46 * Carnegie Mellon requests users of this software to return to
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
58 #ifndef _MACH_I386_SYSCALL_SW_H_
59 #define _MACH_I386_SYSCALL_SW_H_
61 #include <architecture/i386/asm_help.h>
64 * Software interrupt codes for 32-bit system call entry:
68 #define MACHDEP_INT 0x82
75 * Syscall entry macros for use in libc:
77 #define UNIX_SYSCALL_TRAP \
79 #define MACHDEP_SYSCALL_TRAP \
83 * Macro to generate Mach call stubs in libc:
86 #define kernel_trap(trap_name,trap_number,number_args) \
87 LEAF(_##trap_name,0) ;\
88 movl $##trap_number, %eax ;\
89 call __sysenter_trap ;\
94 #endif /* defined(__i386__) */
96 #if defined(__x86_64__)
100 #define UNIX_SYSCALL_TRAP \
102 #define MACHDEP_SYSCALL_TRAP \
106 * Macro to generate Mach call stubs in Libc.
107 * Existing calls use negative numbers for Mach traps, so
108 * until we change those and change the 32-bit kernel_trap
109 * macro above, we negate those numbers here for the 64-bit
112 #define kernel_trap(trap_name,trap_number,number_args) \
113 LEAF(_##trap_name,0) ;\
115 movl $ SYSCALL_CONSTRUCT_MACH(-##trap_number), %eax ;\
121 #endif /* defined(__x86_64__) */
124 * Syscall classes for 64-bit system call entry.
125 * For 64-bit users, the 32-bit syscall number is partitioned
126 * with the high-order bits representing the class and low-order
127 * bits being the syscall number within that class.
128 * The high-order 32-bits of the 64-bit syscall number are unused.
129 * All system classes enter the kernel via the syscall instruction.
131 * These are not #ifdef'd for x86-64 because they might be used for
132 * 32-bit someday and so the 64-bit comm page in a 32-bit kernel
135 #define SYSCALL_CLASS_SHIFT 24
136 #define SYSCALL_CLASS_MASK (0xFF << SYSCALL_CLASS_SHIFT)
137 #define SYSCALL_NUMBER_MASK (~SYSCALL_CLASS_MASK)
139 #define I386_SYSCALL_CLASS_MASK SYSCALL_CLASS_MASK
140 #define I386_SYSCALL_ARG_BYTES_SHIFT (16)
141 #define I386_SYSCALL_ARG_DWORDS_SHIFT (I386_SYSCALL_ARG_BYTES_SHIFT + 2)
142 #define I386_SYSCALL_ARG_BYTES_NUM (64) /* Must be <= sizeof(uu_arg) */
143 #define I386_SYSCALL_ARG_DWORDS_MASK ((I386_SYSCALL_ARG_BYTES_NUM >> 2) -1)
144 #define I386_SYSCALL_ARG_BYTES_MASK (((I386_SYSCALL_ARG_BYTES_NUM -1)&~0x3) << I386_SYSCALL_ARG_BYTES_SHIFT)
145 #define I386_SYSCALL_NUMBER_MASK (0xFFFF)
147 #define SYSCALL_CLASS_NONE 0 /* Invalid */
148 #define SYSCALL_CLASS_MACH 1 /* Mach */
149 #define SYSCALL_CLASS_UNIX 2 /* Unix/BSD */
150 #define SYSCALL_CLASS_MDEP 3 /* Machine-dependent */
151 #define SYSCALL_CLASS_DIAG 4 /* Diagnostics */
152 #define SYSCALL_CLASS_IPC 5 /* Mach IPC */
154 /* Macros to simpllfy constructing syscall numbers. */
155 #define SYSCALL_CONSTRUCT_MACH(syscall_number) \
156 ((SYSCALL_CLASS_MACH << SYSCALL_CLASS_SHIFT) | \
157 (SYSCALL_NUMBER_MASK & (syscall_number)))
158 #define SYSCALL_CONSTRUCT_UNIX(syscall_number) \
159 ((SYSCALL_CLASS_UNIX << SYSCALL_CLASS_SHIFT) | \
160 (SYSCALL_NUMBER_MASK & (syscall_number)))
161 #define SYSCALL_CONSTRUCT_MDEP(syscall_number) \
162 ((SYSCALL_CLASS_MDEP << SYSCALL_CLASS_SHIFT) | \
163 (SYSCALL_NUMBER_MASK & (syscall_number)))
164 #define SYSCALL_CONSTRUCT_DIAG(syscall_number) \
165 ((SYSCALL_CLASS_DIAG << SYSCALL_CLASS_SHIFT) | \
166 (SYSCALL_NUMBER_MASK & (syscall_number)))
168 #endif /* _MACH_I386_SYSCALL_SW_H_ */