]> git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/syscall_sw.c
xnu-1504.15.3.tar.gz
[apple/xnu.git] / osfmk / kern / syscall_sw.c
1 /*
2 * Copyright (c) 2000-2005 Apple Computer, 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 /*
29 * @OSF_COPYRIGHT@
30 */
31 /*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34 * All Rights Reserved.
35 *
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.
41 *
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.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56 /*
57 */
58
59 #include <mach/mach_types.h>
60 #include <mach/mach_traps.h>
61
62 #include <kern/syscall_sw.h>
63
64 /* Forwards */
65
66
67 /*
68 * To add a new entry:
69 * Add an "MACH_TRAP(routine, arg count)" to the table below.
70 *
71 * Add trap definition to mach/syscall_sw.h and
72 * recompile user library.
73 *
74 * WARNING: If you add a trap which requires more than 7
75 * parameters, mach/{machine}/syscall_sw.h and {machine}/trap.c
76 * and/or {machine}/locore.s may need to be modified for it
77 * to work successfully.
78 *
79 * WARNING: Don't use numbers 0 through -9. They (along with
80 * the positive numbers) are reserved for Unix.
81 */
82
83 int kern_invalid_debug = 0;
84
85 /* Include declarations of the trap functions. */
86
87 #include <mach/mach_traps.h>
88 #include <mach/mach_syscalls.h>
89 #include <kern/syscall_subr.h>
90
91 #include <kern/clock.h>
92 #include <mach/mk_timer.h>
93
94 mach_trap_t mach_trap_table[MACH_TRAP_TABLE_COUNT] = {
95 /* 0 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
96 /* 1 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
97 /* 2 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
98 /* 3 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
99 /* 4 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
100 /* 5 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
101 /* 6 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
102 /* 7 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
103 /* 8 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
104 /* 9 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
105 /* 10 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
106 /* 11 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
107 /* 12 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
108 /* 13 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
109 /* 14 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
110 /* 15 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
111 /* 16 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
112 /* 17 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
113 /* 18 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
114 /* 19 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
115 /* 20 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
116 /* 21 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
117 /* 22 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
118 /* 23 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
119 /* 24 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
120 /* 25 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
121 /* 26 */ MACH_TRAP(mach_reply_port, 0, NULL, NULL),
122 /* 27 */ MACH_TRAP(thread_self_trap, 0, NULL, NULL),
123 /* 28 */ MACH_TRAP(task_self_trap, 0, NULL, NULL),
124 /* 29 */ MACH_TRAP(host_self_trap, 0, NULL, NULL),
125 /* 30 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
126 /* 31 */ MACH_TRAP(mach_msg_trap, 7, munge_wwwwwww, munge_ddddddd),
127 /* 32 */ MACH_TRAP(mach_msg_overwrite_trap, 8, munge_wwwwwwww, munge_dddddddd),
128 /* 33 */ MACH_TRAP(semaphore_signal_trap, 1, munge_w, munge_d),
129 /* 34 */ MACH_TRAP(semaphore_signal_all_trap, 1, munge_w, munge_d),
130 /* 35 */ MACH_TRAP(semaphore_signal_thread_trap, 2, munge_ww, munge_dd),
131 /* 36 */ MACH_TRAP(semaphore_wait_trap, 1, munge_w, munge_d),
132 /* 37 */ MACH_TRAP(semaphore_wait_signal_trap, 2, munge_ww, munge_dd),
133 /* 38 */ MACH_TRAP(semaphore_timedwait_trap, 3, munge_www, munge_ddd),
134 /* 39 */ MACH_TRAP(semaphore_timedwait_signal_trap, 4, munge_wwww, munge_dddd),
135 /* 40 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
136 /* 41 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
137 /* 42 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
138 /* 43 */ MACH_TRAP(map_fd, 5, munge_wwwww, munge_ddddd),
139 /* 44 */ MACH_TRAP(task_name_for_pid, 3, munge_www, munge_ddd),
140 /* 45 */ MACH_TRAP(task_for_pid, 3, munge_www, munge_ddd),
141 /* 46 */ MACH_TRAP(pid_for_task, 2, munge_ww,munge_dd),
142 /* 47 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
143 /* 48 */ MACH_TRAP(macx_swapon, 5, munge_lwww, munge_dddd),
144 /* 49 */ MACH_TRAP(macx_swapoff, 3, munge_lw, munge_dd),
145 /* 50 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
146 /* 51 */ MACH_TRAP(macx_triggers, 4, munge_wwww, munge_dddd),
147 /* 52 */ MACH_TRAP(macx_backing_store_suspend, 1, munge_w, munge_d),
148 /* 53 */ MACH_TRAP(macx_backing_store_recovery, 1, munge_w, munge_d),
149 /* 54 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
150 /* 55 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
151 /* 56 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
152 /* 57 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
153 /* 58 */ MACH_TRAP(pfz_exit, 0, NULL, NULL),
154 /* 59 */ MACH_TRAP(swtch_pri, 0, NULL, NULL),
155 /* 60 */ MACH_TRAP(swtch, 0, NULL, NULL),
156 /* 61 */ MACH_TRAP(thread_switch, 3, munge_www, munge_ddd),
157 /* 62 */ MACH_TRAP(clock_sleep_trap, 5, munge_wwwww, munge_ddddd),
158 /* 63 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
159 /* traps 64 - 95 reserved (debo) */
160 /* 64 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
161 /* 65 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
162 /* 66 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
163 /* 67 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
164 /* 68 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
165 /* 69 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
166 /* 70 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
167 /* 71 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
168 /* 72 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
169 /* 73 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
170 /* 74 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
171 /* 75 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
172 /* 76 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
173 /* 77 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
174 /* 78 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
175 /* 79 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
176 /* 80 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
177 /* 81 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
178 /* 82 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
179 /* 83 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
180 /* 84 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
181 /* 85 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
182 /* 86 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
183 /* 87 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
184 /* 88 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
185 /* 89 */ MACH_TRAP(mach_timebase_info_trap, 1, munge_w, munge_d),
186 /* 90 */ MACH_TRAP(mach_wait_until_trap, 2, munge_l, munge_d),
187 /* 91 */ MACH_TRAP(mk_timer_create_trap, 0, NULL, NULL),
188 /* 92 */ MACH_TRAP(mk_timer_destroy_trap, 1, munge_w, munge_d),
189 /* 93 */ MACH_TRAP(mk_timer_arm_trap, 3, munge_wl, munge_dd),
190 /* 94 */ MACH_TRAP(mk_timer_cancel_trap, 2, munge_ww, munge_dd),
191 /* 95 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
192 /* traps 64 - 95 reserved (debo) */
193 /* 96 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
194 /* 97 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
195 /* 98 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
196 /* 99 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
197 /* traps 100-107 reserved for iokit (esb) */
198 /* 100 */ MACH_TRAP(iokit_user_client_trap, 8, munge_wwwwwwww, munge_dddddddd),
199 /* 101 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
200 /* 102 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
201 /* 103 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
202 /* 104 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
203 /* 105 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
204 /* 106 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
205 /* 107 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
206 /* traps 108-127 unused */
207 /* 108 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
208 /* 109 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
209 /* 110 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
210 /* 111 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
211 /* 112 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
212 /* 113 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
213 /* 114 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
214 /* 115 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
215 /* 116 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
216 /* 117 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
217 /* 118 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
218 /* 119 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
219 /* 120 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
220 /* 121 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
221 /* 122 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
222 /* 123 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
223 /* 124 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
224 /* 125 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
225 /* 126 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
226 /* 127 */ MACH_TRAP(kern_invalid, 0, NULL, NULL),
227 };
228
229 const char * mach_syscall_name_table[MACH_TRAP_TABLE_COUNT] = {
230 /* 0 */ "kern_invalid",
231 /* 1 */ "kern_invalid",
232 /* 2 */ "kern_invalid",
233 /* 3 */ "kern_invalid",
234 /* 4 */ "kern_invalid",
235 /* 5 */ "kern_invalid",
236 /* 6 */ "kern_invalid",
237 /* 7 */ "kern_invalid",
238 /* 8 */ "kern_invalid",
239 /* 9 */ "kern_invalid",
240 /* 10 */ "kern_invalid",
241 /* 11 */ "kern_invalid",
242 /* 12 */ "kern_invalid",
243 /* 13 */ "kern_invalid",
244 /* 14 */ "kern_invalid",
245 /* 15 */ "kern_invalid",
246 /* 16 */ "kern_invalid",
247 /* 17 */ "kern_invalid",
248 /* 18 */ "kern_invalid",
249 /* 19 */ "kern_invalid",
250 /* 20 */ "kern_invalid",
251 /* 21 */ "kern_invalid",
252 /* 22 */ "kern_invalid",
253 /* 23 */ "kern_invalid",
254 /* 24 */ "kern_invalid",
255 /* 25 */ "kern_invalid",
256 /* 26 */ "mach_reply_port",
257 /* 27 */ "thread_self_trap",
258 /* 28 */ "task_self_trap",
259 /* 29 */ "host_self_trap",
260 /* 30 */ "kern_invalid",
261 /* 31 */ "mach_msg_trap",
262 /* 32 */ "mach_msg_overwrite_trap",
263 /* 33 */ "semaphore_signal_trap",
264 /* 34 */ "semaphore_signal_all_trap",
265 /* 35 */ "semaphore_signal_thread_trap",
266 /* 36 */ "semaphore_wait_trap",
267 /* 37 */ "semaphore_wait_signal_trap",
268 /* 38 */ "semaphore_timedwait_trap",
269 /* 39 */ "semaphore_timedwait_signal_trap",
270 /* 40 */ "kern_invalid",
271 /* 41 */ "kern_invalid",
272 /* 42 */ "kern_invalid",
273 /* 43 */ "map_fd",
274 /* 44 */ "task_name_for_pid",
275 /* 45 */ "task_for_pid",
276 /* 46 */ "pid_for_task",
277 /* 47 */ "kern_invalid",
278 /* 48 */ "macx_swapon",
279 /* 49 */ "macx_swapoff",
280 /* 50 */ "kern_invalid",
281 /* 51 */ "macx_triggers",
282 /* 52 */ "macx_backing_store_suspend",
283 /* 53 */ "macx_backing_store_recovery",
284 /* 54 */ "kern_invalid",
285 /* 55 */ "kern_invalid",
286 /* 56 */ "kern_invalid",
287 /* 57 */ "kern_invalid",
288 /* 58 */ "pfz_exit",
289 /* 59 */ "swtch_pri",
290 /* 60 */ "swtch",
291 /* 61 */ "thread_switch",
292 /* 62 */ "clock_sleep_trap",
293 /* 63 */ "kern_invalid",
294 /* traps 64 - 95 reserved (debo) */
295 /* 64 */ "kern_invalid",
296 /* 65 */ "kern_invalid",
297 /* 66 */ "kern_invalid",
298 /* 67 */ "kern_invalid",
299 /* 68 */ "kern_invalid",
300 /* 69 */ "kern_invalid",
301 /* 70 */ "kern_invalid",
302 /* 71 */ "kern_invalid",
303 /* 72 */ "kern_invalid",
304 /* 73 */ "kern_invalid",
305 /* 74 */ "kern_invalid",
306 /* 75 */ "kern_invalid",
307 /* 76 */ "kern_invalid",
308 /* 77 */ "kern_invalid",
309 /* 78 */ "kern_invalid",
310 /* 79 */ "kern_invalid",
311 /* 80 */ "kern_invalid",
312 /* 81 */ "kern_invalid",
313 /* 82 */ "kern_invalid",
314 /* 83 */ "kern_invalid",
315 /* 84 */ "kern_invalid",
316 /* 85 */ "kern_invalid",
317 /* 86 */ "kern_invalid",
318 /* 87 */ "kern_invalid",
319 /* 88 */ "kern_invalid",
320 /* 89 */ "mach_timebase_info_trap",
321 /* 90 */ "mach_wait_until_trap",
322 /* 91 */ "mk_timer_create_trap",
323 /* 92 */ "mk_timer_destroy_trap",
324 /* 93 */ "mk_timer_arm_trap",
325 /* 94 */ "mk_timer_cancel_trap",
326 /* 95 */ "kern_invalid",
327 /* traps 64 - 95 reserved (debo) */
328 /* 96 */ "kern_invalid",
329 /* 97 */ "kern_invalid",
330 /* 98 */ "kern_invalid",
331 /* 99 */ "kern_invalid",
332 /* traps 100-107 reserved for iokit (esb) */
333 /* 100 */ "kern_invalid",
334 /* 100 */ //"iokit_user_client_trap",
335 /* 101 */ "kern_invalid",
336 /* 102 */ "kern_invalid",
337 /* 103 */ "kern_invalid",
338 /* 104 */ "kern_invalid",
339 /* 105 */ "kern_invalid",
340 /* 106 */ "kern_invalid",
341 /* 107 */ "kern_invalid",
342 /* traps 108-127 unused */
343 /* 108 */ "kern_invalid",
344 /* 109 */ "kern_invalid",
345 /* 110 */ "kern_invalid",
346 /* 111 */ "kern_invalid",
347 /* 112 */ "kern_invalid",
348 /* 113 */ "kern_invalid",
349 /* 114 */ "kern_invalid",
350 /* 115 */ "kern_invalid",
351 /* 116 */ "kern_invalid",
352 /* 117 */ "kern_invalid",
353 /* 118 */ "kern_invalid",
354 /* 119 */ "kern_invalid",
355 /* 120 */ "kern_invalid",
356 /* 121 */ "kern_invalid",
357 /* 122 */ "kern_invalid",
358 /* 123 */ "kern_invalid",
359 /* 124 */ "kern_invalid",
360 /* 125 */ "kern_invalid",
361 /* 126 */ "kern_invalid",
362 /* 127 */ "kern_invalid",
363 };
364
365 int mach_trap_count = (sizeof(mach_trap_table) / sizeof(mach_trap_table[0]));
366
367 kern_return_t
368 kern_invalid(
369 __unused struct kern_invalid_args *args)
370 {
371 if (kern_invalid_debug) Debugger("kern_invalid mach trap");
372 return(KERN_INVALID_ARGUMENT);
373 }
374