]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/syscall_sw.c
xnu-201.tar.gz
[apple/xnu.git] / osfmk / kern / syscall_sw.c
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * @OSF_COPYRIGHT@
24 */
25/*
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
29 *
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
35 *
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
39 *
40 * Carnegie Mellon requests users of this software to return to
41 *
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
46 *
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
49 */
50/*
51 */
52
53#include <mach/mach_types.h>
54
55#include <kern/syscall_sw.h>
56
57/* Forwards */
58extern kern_return_t kern_invalid(void);
59extern mach_port_name_t null_port(void);
60extern kern_return_t not_implemented(void);
61
62/*
63 * To add a new entry:
64 * Add an "MACH_TRAP(routine, arg count)" to the table below.
65 *
66 * Add trap definition to mach/syscall_sw.h and
67 * recompile user library.
68 *
69 * WARNING: If you add a trap which requires more than 7
70 * parameters, mach/{machine}/syscall_sw.h and {machine}/trap.c
71 * and/or {machine}/locore.s may need to be modified for it
72 * to work successfully.
73 *
74 * WARNING: Don't use numbers 0 through -9. They (along with
75 * the positive numbers) are reserved for Unix.
76 */
77
78int kern_invalid_debug = 0;
79
80/* Include declarations of the trap functions. */
81
82#include <mach/mach_traps.h>
83#include <mach/mach_syscalls.h>
84#include <kern/syscall_subr.h>
85
86#include <kern/clock.h>
87#include <mach/mk_timer.h>
88
89extern kern_return_t iokit_user_client_trap();
90
91mach_trap_t mach_trap_table[] = {
92 MACH_TRAP(kern_invalid, 0), /* 0 */ /* Unix */
93 MACH_TRAP(kern_invalid, 0), /* 1 */ /* Unix */
94 MACH_TRAP(kern_invalid, 0), /* 2 */ /* Unix */
95 MACH_TRAP(kern_invalid, 0), /* 3 */ /* Unix */
96 MACH_TRAP(kern_invalid, 0), /* 4 */ /* Unix */
97 MACH_TRAP(kern_invalid, 0), /* 5 */ /* Unix */
98 MACH_TRAP(kern_invalid, 0), /* 6 */ /* Unix */
99 MACH_TRAP(kern_invalid, 0), /* 7 */ /* Unix */
100 MACH_TRAP(kern_invalid, 0), /* 8 */ /* Unix */
101 MACH_TRAP(kern_invalid, 0), /* 9 */ /* Unix */
102 MACH_TRAP(kern_invalid, 0), /* 10 */
103 MACH_TRAP(kern_invalid, 0), /* 11 */
104 MACH_TRAP(kern_invalid, 0), /* 12 */
105 MACH_TRAP(kern_invalid, 0), /* 13 */
106 MACH_TRAP(kern_invalid, 0), /* 14 */
107 MACH_TRAP(kern_invalid, 0), /* 15 */
108 MACH_TRAP(kern_invalid, 0), /* 16 */
109 MACH_TRAP(kern_invalid, 0), /* 17 */
110 MACH_TRAP(kern_invalid, 0), /* 18 */
111 MACH_TRAP(kern_invalid, 0), /* 19 */
112 MACH_TRAP(kern_invalid, 0), /* 20 */
113 MACH_TRAP(kern_invalid, 0), /* 21 */
114 MACH_TRAP(kern_invalid, 0), /* 22 */
115 MACH_TRAP(kern_invalid, 0), /* 23 */
116 MACH_TRAP(kern_invalid, 0), /* 24 */
117 MACH_TRAP(kern_invalid, 0), /* 25 */
118 MACH_TRAP(mach_reply_port, 0), /* 26 */
119 MACH_TRAP(thread_self_trap, 0), /* 27 */
120 MACH_TRAP(task_self_trap, 0), /* 28 */
121 MACH_TRAP(host_self_trap, 0), /* 29 */
122 MACH_TRAP(kern_invalid, 0), /* 30 */
123 MACH_TRAP(kern_invalid, 0), /* 31 */
124 MACH_TRAP(mach_msg_overwrite_trap, 9), /* 32 */
125 MACH_TRAP(semaphore_signal_trap, 1), /* 33 */
126 MACH_TRAP(semaphore_signal_all_trap, 1), /* 34 */
127 MACH_TRAP(semaphore_signal_thread_trap, 2), /* 35 */
128 MACH_TRAP(semaphore_wait_trap, 1), /* 36 */
129 MACH_TRAP(semaphore_wait_signal_trap, 2), /* 37 */
130 MACH_TRAP(semaphore_timedwait_trap, 3), /* 38 */
131 MACH_TRAP(semaphore_timedwait_signal_trap, 4), /* 39 */
132 MACH_TRAP(kern_invalid, 0), /* 40 */
133 MACH_TRAP(init_process, 0), /* 41 */
134 MACH_TRAP(kern_invalid, 0), /* 42 */
135 MACH_TRAP(map_fd, 5), /* 43 */
136 MACH_TRAP(kern_invalid, 0), /* 44 */
137 MACH_TRAP(task_for_pid, 3), /* 45 */
138 MACH_TRAP(pid_for_task, 2), /* 46 */
139 MACH_TRAP(kern_invalid, 0), /* 47 */
140 MACH_TRAP(macx_swapon, 4), /* 48 */
141 MACH_TRAP(macx_swapoff, 2), /* 49 */
142 MACH_TRAP(kern_invalid, 0), /* 50 */
143 MACH_TRAP(macx_triggers, 4), /* 51 */
144 MACH_TRAP(kern_invalid, 0), /* 52 */
145 MACH_TRAP(kern_invalid, 0), /* 53 */
146 MACH_TRAP(kern_invalid, 0), /* 54 */
147 MACH_TRAP(kern_invalid, 0), /* 55 */
148 MACH_TRAP(kern_invalid, 0), /* 56 */
149 MACH_TRAP(kern_invalid, 0), /* 57 */
150 MACH_TRAP(kern_invalid, 0), /* 58 */
151 MACH_TRAP(swtch_pri, 1), /* 59 */
152 MACH_TRAP(swtch, 0), /* 60 */
153 MACH_TRAP(thread_switch, 3), /* 61 */
154 MACH_TRAP(clock_sleep_trap, 5), /* 62 */
155 MACH_TRAP(kern_invalid,0), /* 63 */
156/* traps 64 - 95 reserved (debo) */
157 MACH_TRAP(kern_invalid,0), /* 64 */
158 MACH_TRAP(kern_invalid,0), /* 65 */
159 MACH_TRAP(kern_invalid,0), /* 66 */
160 MACH_TRAP(kern_invalid,0), /* 67 */
161 MACH_TRAP(kern_invalid,0), /* 68 */
162 MACH_TRAP(kern_invalid,0), /* 69 */
163 MACH_TRAP(kern_invalid,0), /* 70 */
164 MACH_TRAP(kern_invalid,0), /* 71 */
165 MACH_TRAP(kern_invalid,0), /* 72 */
166 MACH_TRAP(kern_invalid,0), /* 73 */
167 MACH_TRAP(kern_invalid,0), /* 74 */
168 MACH_TRAP(kern_invalid,0), /* 75 */
169 MACH_TRAP(kern_invalid,0), /* 76 */
170 MACH_TRAP(kern_invalid,0), /* 77 */
171 MACH_TRAP(kern_invalid,0), /* 78 */
172 MACH_TRAP(kern_invalid,0), /* 79 */
173 MACH_TRAP(kern_invalid,0), /* 80 */
174 MACH_TRAP(kern_invalid,0), /* 81 */
175 MACH_TRAP(kern_invalid,0), /* 82 */
176 MACH_TRAP(kern_invalid,0), /* 83 */
177 MACH_TRAP(kern_invalid,0), /* 84 */
178 MACH_TRAP(kern_invalid,0), /* 85 */
179 MACH_TRAP(kern_invalid,0), /* 86 */
180 MACH_TRAP(kern_invalid,0), /* 87 */
181 MACH_TRAP(kern_invalid,0), /* 88 */
182 MACH_TRAP(mach_timebase_info, 1), /* 89 */
183 MACH_TRAP(mach_wait_until, 2), /* 90 */
184 MACH_TRAP(mk_timer_create, 0), /* 91 */
185 MACH_TRAP(mk_timer_destroy, 1), /* 92 */
186 MACH_TRAP(mk_timer_arm, 3), /* 93 */
187 MACH_TRAP(mk_timer_cancel, 2), /* 94 */
188 MACH_TRAP(mk_timebase_info, 5), /* 95 */
189/* traps 64 - 95 reserved (debo) */
190 MACH_TRAP(kern_invalid,0), /* 96 */
191 MACH_TRAP(kern_invalid,0), /* 97 */
192 MACH_TRAP(kern_invalid,0), /* 98 */
193 MACH_TRAP(kern_invalid,0), /* 99 */
194/* traps 100-107 reserved for iokit (esb) */
195 MACH_TRAP(iokit_user_client_trap, 8),
196 /* 100 */ /* IOKit */
197 MACH_TRAP(kern_invalid,0), /* 101 */ /* IOKit */
198 MACH_TRAP(kern_invalid,0), /* 102 */ /* IOKit */
199 MACH_TRAP(kern_invalid,0), /* 103 */ /* IOKit */
200 MACH_TRAP(kern_invalid,0), /* 104 */ /* IOKit */
201 MACH_TRAP(kern_invalid,0), /* 105 */ /* IOKit */
202 MACH_TRAP(kern_invalid,0), /* 106 */ /* IOKit */
203 MACH_TRAP(kern_invalid,0), /* 107 */ /* IOKit */
204 MACH_TRAP(kern_invalid,0), /* 108 */
205 MACH_TRAP(kern_invalid,0), /* 109 */
206 MACH_TRAP(kern_invalid,0), /* 110 */
207 MACH_TRAP(kern_invalid,0), /* 111 */
208 MACH_TRAP(kern_invalid,0), /* 112 */
209 MACH_TRAP(kern_invalid,0), /* 113 */
210 MACH_TRAP(kern_invalid,0), /* 114 */
211 MACH_TRAP(kern_invalid,0), /* 115 */
212 MACH_TRAP(kern_invalid,0), /* 116 */
213 MACH_TRAP(kern_invalid,0), /* 117 */
214 MACH_TRAP(kern_invalid,0), /* 118 */
215 MACH_TRAP(kern_invalid,0), /* 119 */
216 MACH_TRAP(kern_invalid,0), /* 120 */
217 MACH_TRAP(kern_invalid,0), /* 121 */
218 MACH_TRAP(kern_invalid,0), /* 122 */
219 MACH_TRAP(kern_invalid,0), /* 123 */
220 MACH_TRAP(kern_invalid,0), /* 124 */
221 MACH_TRAP(kern_invalid,0), /* 125 */
222 MACH_TRAP(kern_invalid,0), /* 126 */
223 MACH_TRAP(kern_invalid,0), /* 127 */
224};
225
226int mach_trap_count = (sizeof(mach_trap_table) / sizeof(mach_trap_table[0]));
227
228mach_port_name_t
229null_port(void)
230{
231 if (kern_invalid_debug) Debugger("null_port mach trap");
232 return(MACH_PORT_NULL);
233}
234
235kern_return_t
236kern_invalid(void)
237{
238 if (kern_invalid_debug) Debugger("kern_invalid mach trap");
239 return(KERN_INVALID_ARGUMENT);
240}
241
242kern_return_t
243not_implemented(void)
244{
245 return(MACH_SEND_INTERRUPTED);
246}