]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
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 | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b A |
29 | */ |
30 | /* | |
31 | * @OSF_COPYRIGHT@ | |
32 | */ | |
1c79356b A |
33 | /* |
34 | * Mach Operating System | |
35 | * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University | |
36 | * All Rights Reserved. | |
37 | * | |
38 | * Permission to use, copy, modify and distribute this software and its | |
39 | * documentation is hereby granted, provided that both the copyright | |
40 | * notice and this permission notice appear in all copies of the | |
41 | * software, derivative works or modified versions, and any portions | |
42 | * thereof, and that both notices appear in supporting documentation. | |
43 | * | |
44 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
45 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
46 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
47 | * | |
48 | * Carnegie Mellon requests users of this software to return to | |
49 | * | |
50 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
51 | * School of Computer Science | |
52 | * Carnegie Mellon University | |
53 | * Pittsburgh PA 15213-3890 | |
54 | * | |
55 | * any improvements or extensions that they make and grant Carnegie Mellon | |
56 | * the rights to redistribute these changes. | |
57 | */ | |
58 | /* | |
59 | */ | |
60 | ||
91447636 A |
61 | #ifdef PRIVATE |
62 | ||
1c79356b A |
63 | #ifndef _MACH_I386_SYSCALL_SW_H_ |
64 | #define _MACH_I386_SYSCALL_SW_H_ | |
65 | ||
66 | #include <architecture/i386/asm_help.h> | |
67 | ||
5d5c5d0d A |
68 | #if defined(__i386__) |
69 | /* | |
70 | * Software interrupt codes for 32-bit system call entry: | |
71 | */ | |
72 | #define UNIX_INT 0x80 | |
73 | #define MACH_INT 0x81 | |
74 | #define MACHDEP_INT 0x82 | |
75 | #define DIAG_INT 0x83 | |
76 | ||
77 | #ifndef KERNEL | |
78 | /* | |
79 | * Syscall entry macros for use in libc: | |
80 | * [Note that the nop padding is temporary during 4/4 transition.] | |
81 | */ | |
82 | #define SYSENTER_PAD nop;nop; | |
83 | #define SYSCALL_PAD nop;nop;nop;nop;nop; | |
84 | #define UNIX_SYSCALL_TRAP \ | |
85 | SYSCALL_PAD \ | |
86 | int $(UNIX_INT) | |
87 | #define MACHDEP_SYSCALL_TRAP \ | |
88 | SYSCALL_PAD \ | |
89 | int $(MACHDEP_INT) | |
90 | ||
91 | /* | |
92 | * Macro to generate Mach call stubs in libc: | |
93 | */ | |
94 | #define kernel_trap(trap_name,trap_number,number_args) \ | |
95 | LEAF(_##trap_name,0) ;\ | |
96 | movl $##trap_number,%eax ;\ | |
97 | int $(MACH_INT) ;\ | |
98 | END(_##trap_name) | |
99 | ||
100 | #endif | |
101 | #endif /* defined(__i386__) */ | |
c0fea474 | 102 | |
5d5c5d0d A |
103 | #if defined(__x86_64__) |
104 | ||
105 | #ifndef KERNEL | |
106 | ||
107 | #define UNIX_SYSCALL_TRAP \ | |
108 | syscall | |
109 | #define MACHDEP_SYSCALL_TRAP \ | |
110 | syscall | |
111 | ||
112 | /* | |
113 | * Macro to generate Mach call stubs in Libc. | |
114 | * Existing calls use negative numbers for Mach traps, so | |
115 | * until we change those and change the 32-bit kernel_trap | |
116 | * macro above, we negate those numbers here for the 64-bit | |
117 | * code path. | |
118 | */ | |
c0fea474 A |
119 | #define kernel_trap(trap_name,trap_number,number_args) \ |
120 | LEAF(_##trap_name,0) ;\ | |
5d5c5d0d A |
121 | movq %rcx, %r10 ;\ |
122 | movl $ SYSCALL_CONSTRUCT_MACH(-##trap_number), %eax ;\ | |
123 | syscall ;\ | |
c0fea474 A |
124 | END(_##trap_name) |
125 | ||
5d5c5d0d A |
126 | #endif |
127 | #endif /* defined(__x86_64__) */ | |
128 | ||
129 | /* | |
130 | * Syscall classes for 64-bit system call entry. | |
131 | * For 64-bit users, the 32-bit syscall number is partitioned | |
132 | * with the high-order bits representing the class and low-order | |
133 | * bits being the syscall number within that class. | |
134 | * The high-order 32-bits of the 64-bit syscall number are unused. | |
135 | * All system classes enter the kernel via the syscall instruction. | |
136 | * | |
137 | * These are not #ifdef'd for x86-64 because they might be used for | |
138 | * 32-bit someday and so the 64-bit comm page in a 32-bit kernel | |
139 | * can use them. | |
140 | */ | |
141 | #define SYSCALL_CLASS_SHIFT 24 | |
142 | #define SYSCALL_CLASS_MASK (0xFF << SYSCALL_CLASS_SHIFT) | |
143 | #define SYSCALL_NUMBER_MASK (~SYSCALL_CLASS_MASK) | |
144 | ||
145 | #define SYSCALL_CLASS_NONE 0 /* Invalid */ | |
146 | #define SYSCALL_CLASS_MACH 1 /* Mach */ | |
147 | #define SYSCALL_CLASS_UNIX 2 /* Unix/BSD */ | |
148 | #define SYSCALL_CLASS_MDEP 3 /* Machine-dependent */ | |
149 | #define SYSCALL_CLASS_DIAG 4 /* Diagnostics */ | |
150 | ||
151 | /* Macros to simpllfy constructing syscall numbers. */ | |
152 | #define SYSCALL_CONSTRUCT_MACH(syscall_number) \ | |
153 | ((SYSCALL_CLASS_MACH << SYSCALL_CLASS_SHIFT) | \ | |
154 | (SYSCALL_NUMBER_MASK & (syscall_number))) | |
155 | #define SYSCALL_CONSTRUCT_UNIX(syscall_number) \ | |
156 | ((SYSCALL_CLASS_UNIX << SYSCALL_CLASS_SHIFT) | \ | |
157 | (SYSCALL_NUMBER_MASK & (syscall_number))) | |
158 | #define SYSCALL_CONSTRUCT_MDEP(syscall_number) \ | |
159 | ((SYSCALL_CLASS_MDEP << SYSCALL_CLASS_SHIFT) | \ | |
160 | (SYSCALL_NUMBER_MASK & (syscall_number))) | |
161 | #define SYSCALL_CONSTRUCT_DIAG(syscall_number) \ | |
162 | ((SYSCALL_CLASS_DIAG << SYSCALL_CLASS_SHIFT) | \ | |
163 | (SYSCALL_NUMBER_MASK & (syscall_number))) | |
164 | ||
1c79356b | 165 | #endif /* _MACH_I386_SYSCALL_SW_H_ */ |
91447636 A |
166 | |
167 | #endif /* PRIVATE */ |