2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
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.
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.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
53 #include <mach/mach_types.h>
55 #include <kern/syscall_sw.h>
58 extern kern_return_t
kern_invalid(void);
59 extern mach_port_name_t
null_port(void);
60 extern kern_return_t
not_implemented(void);
64 * Add an "MACH_TRAP(routine, arg count)" to the table below.
66 * Add trap definition to mach/syscall_sw.h and
67 * recompile user library.
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.
74 * WARNING: Don't use numbers 0 through -9. They (along with
75 * the positive numbers) are reserved for Unix.
78 int kern_invalid_debug
= 0;
80 /* Include declarations of the trap functions. */
82 #include <mach/mach_traps.h>
83 #include <mach/mach_syscalls.h>
84 #include <kern/syscall_subr.h>
86 #include <kern/clock.h>
87 #include <mach/mk_timer.h>
89 extern kern_return_t
iokit_user_client_trap();
91 mach_trap_t mach_trap_table
[MACH_TRAP_TABLE_COUNT
] = {
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(mach_msg_trap
, 7), /* 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(macx_backing_store_suspend
, 1), /* 52 */
145 MACH_TRAP(macx_backing_store_recovery
, 1), /* 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 */
226 int mach_trap_count
= (sizeof(mach_trap_table
) / sizeof(mach_trap_table
[0]));
231 if (kern_invalid_debug
) Debugger("null_port mach trap");
232 return(MACH_PORT_NULL
);
238 if (kern_invalid_debug
) Debugger("kern_invalid mach trap");
239 return(KERN_INVALID_ARGUMENT
);
243 not_implemented(void)
245 return(MACH_SEND_INTERRUPTED
);