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