]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
9bccf70c | 2 | * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
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 | |
13 | * file. | |
14 | * | |
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 | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
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. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | */ | |
28 | /* | |
29 | * Mach Operating System | |
30 | * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University | |
31 | * All Rights Reserved. | |
32 | * | |
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. | |
38 | * | |
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. | |
42 | * | |
43 | * Carnegie Mellon requests users of this software to return to | |
44 | * | |
45 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
46 | * School of Computer Science | |
47 | * Carnegie Mellon University | |
48 | * Pittsburgh PA 15213-3890 | |
49 | * | |
50 | * any improvements or extensions that they make and grant Carnegie Mellon | |
51 | * the rights to redistribute these changes. | |
52 | */ | |
53 | /* | |
54 | */ | |
55 | /* | |
56 | * File: mach/message.h | |
57 | * | |
58 | * Mach IPC message and primitive function definitions. | |
59 | */ | |
60 | ||
61 | #ifndef _MACH_MESSAGE_H_ | |
62 | #define _MACH_MESSAGE_H_ | |
63 | ||
64 | #ifdef MACH_KERNEL | |
65 | /* Have to have MIG parameter check for kernel */ | |
66 | #define TypeCheck 1 | |
67 | #define _MIG_KERNEL_SPECIFIC_CODE_ 1 | |
68 | #endif /* MACH_KERNEL */ | |
69 | ||
0b4e3aa0 A |
70 | /* static templates are slower and bigger */ |
71 | /* #define UseStaticTemplates 0 */ | |
72 | ||
9bccf70c | 73 | #include <sys/appleapiopts.h> |
1c79356b | 74 | |
9bccf70c A |
75 | #include <stdint.h> |
76 | #include <mach/port.h> | |
77 | #include <mach/boolean.h> | |
78 | #include <mach/kern_return.h> | |
79 | #include <mach/machine/vm_types.h> | |
1c79356b A |
80 | |
81 | /* | |
82 | * The timeout mechanism uses mach_msg_timeout_t values, | |
83 | * passed by value. The timeout units are milliseconds. | |
84 | * It is controlled with the MACH_SEND_TIMEOUT | |
85 | * and MACH_RCV_TIMEOUT options. | |
86 | */ | |
87 | ||
88 | typedef natural_t mach_msg_timeout_t; | |
89 | ||
90 | /* | |
91 | * The value to be used when there is no timeout. | |
92 | * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.) | |
93 | */ | |
94 | ||
95 | #define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0) | |
96 | ||
97 | /* | |
98 | * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. It it isn't on, it | |
99 | * assumes the body of the message doesn't contain port rights or OOL | |
100 | * data. The field is set in received messages. A user task must | |
101 | * use caution in interpreting the body of a message if the bit isn't | |
102 | * on, because the mach_msg_type's in the body might "lie" about the | |
103 | * contents. If the bit isn't on, but the mach_msg_types | |
104 | * in the body specify rights or OOL data, the behavior is undefined. | |
105 | * (Ie, an error may or may not be produced.) | |
106 | * | |
107 | * The value of MACH_MSGH_BITS_REMOTE determines the interpretation | |
108 | * of the msgh_remote_port field. It is handled like a msgt_name. | |
109 | * | |
110 | * The value of MACH_MSGH_BITS_LOCAL determines the interpretation | |
111 | * of the msgh_local_port field. It is handled like a msgt_name. | |
112 | * | |
113 | * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote | |
114 | * and local fields, into a single value suitable for msgh_bits. | |
115 | * | |
116 | * MACH_MSGH_BITS_CIRCULAR should be zero; is is used internally. | |
117 | * | |
118 | * The unused bits should be zero and are reserved for the kernel | |
119 | * or for future interface expansion. | |
120 | */ | |
121 | ||
122 | #define MACH_MSGH_BITS_ZERO 0x00000000 | |
123 | #define MACH_MSGH_BITS_REMOTE_MASK 0x000000ff | |
124 | #define MACH_MSGH_BITS_LOCAL_MASK 0x0000ff00 | |
125 | #define MACH_MSGH_BITS_COMPLEX 0x80000000U | |
126 | #define MACH_MSGH_BITS_USER 0x8000ffffU | |
127 | ||
128 | #define MACH_MSGH_BITS_CIRCULAR 0x40000000 /* internal use only */ | |
129 | #define MACH_MSGH_BITS_USED 0xc000ffffU | |
130 | ||
131 | #define MACH_MSGH_BITS_PORTS_MASK \ | |
132 | (MACH_MSGH_BITS_REMOTE_MASK|MACH_MSGH_BITS_LOCAL_MASK) | |
133 | ||
134 | #define MACH_MSGH_BITS(remote, local) \ | |
135 | ((remote) | ((local) << 8)) | |
136 | #define MACH_MSGH_BITS_REMOTE(bits) \ | |
137 | ((bits) & MACH_MSGH_BITS_REMOTE_MASK) | |
138 | #define MACH_MSGH_BITS_LOCAL(bits) \ | |
139 | (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8) | |
140 | #define MACH_MSGH_BITS_PORTS(bits) \ | |
141 | ((bits) & MACH_MSGH_BITS_PORTS_MASK) | |
142 | #define MACH_MSGH_BITS_OTHER(bits) \ | |
143 | ((bits) &~ MACH_MSGH_BITS_PORTS_MASK) | |
144 | ||
145 | /* | |
146 | * Every message starts with a message header. | |
147 | * Following the message header are zero or more pairs of | |
148 | * type descriptors (mach_msg_type_t/mach_msg_type_long_t) and | |
149 | * data values. The size of the message must be specified in bytes, | |
150 | * and includes the message header, type descriptors, inline | |
151 | * data, and inline pointer for out-of-line data. | |
152 | * | |
153 | * The msgh_remote_port field specifies the destination of the message. | |
154 | * It must specify a valid send or send-once right for a port. | |
155 | * | |
156 | * The msgh_local_port field specifies a "reply port". Normally, | |
157 | * This field carries a send-once right that the receiver will use | |
158 | * to reply to the message. It may carry the values MACH_PORT_NULL, | |
159 | * MACH_PORT_DEAD, a send-once right, or a send right. | |
160 | * | |
161 | * The msgh_seqno field carries a sequence number associated with the | |
162 | * received-from port. A port's sequence number is incremented every | |
163 | * time a message is received from it. In sent messages, the field's | |
164 | * value is ignored. | |
165 | * | |
166 | * The msgh_id field is uninterpreted by the message primitives. | |
167 | * It normally carries information specifying the format | |
168 | * or meaning of the message. | |
169 | */ | |
170 | ||
171 | typedef unsigned int mach_msg_bits_t; | |
172 | typedef natural_t mach_msg_size_t; | |
173 | typedef integer_t mach_msg_id_t; | |
174 | ||
175 | ||
176 | #define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0 | |
177 | ||
178 | typedef unsigned int mach_msg_type_name_t; | |
179 | ||
180 | #define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive rights */ | |
181 | #define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send rights */ | |
182 | #define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce rights */ | |
183 | #define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send rights */ | |
184 | #define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive rights */ | |
185 | #define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive rights */ | |
186 | #define MACH_MSG_TYPE_COPY_RECEIVE 22 /* Must hold receive rights */ | |
187 | ||
188 | typedef unsigned int mach_msg_copy_options_t; | |
189 | ||
190 | #define MACH_MSG_PHYSICAL_COPY 0 | |
191 | #define MACH_MSG_VIRTUAL_COPY 1 | |
192 | #define MACH_MSG_ALLOCATE 2 | |
193 | #define MACH_MSG_OVERWRITE 3 | |
194 | #ifdef MACH_KERNEL | |
195 | #define MACH_MSG_KALLOC_COPY_T 4 | |
1c79356b A |
196 | #endif /* MACH_KERNEL */ |
197 | ||
198 | typedef unsigned int mach_msg_descriptor_type_t; | |
199 | ||
200 | #define MACH_MSG_PORT_DESCRIPTOR 0 | |
201 | #define MACH_MSG_OOL_DESCRIPTOR 1 | |
202 | #define MACH_MSG_OOL_PORTS_DESCRIPTOR 2 | |
203 | #define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3 | |
204 | ||
205 | ||
206 | typedef struct | |
207 | { | |
208 | void* pad1; | |
209 | mach_msg_size_t pad2; | |
210 | unsigned int pad3 : 24; | |
211 | mach_msg_descriptor_type_t type : 8; | |
212 | } mach_msg_type_descriptor_t; | |
213 | ||
214 | typedef struct | |
215 | { | |
216 | mach_port_t name; | |
217 | mach_msg_size_t pad1; | |
218 | unsigned int pad2 : 16; | |
219 | mach_msg_type_name_t disposition : 8; | |
220 | mach_msg_descriptor_type_t type : 8; | |
221 | } mach_msg_port_descriptor_t; | |
222 | ||
223 | typedef struct | |
224 | { | |
225 | void* address; | |
226 | mach_msg_size_t size; | |
227 | boolean_t deallocate: 8; | |
228 | mach_msg_copy_options_t copy: 8; | |
229 | unsigned int pad1: 8; | |
230 | mach_msg_descriptor_type_t type: 8; | |
231 | } mach_msg_ool_descriptor_t; | |
232 | ||
233 | typedef struct | |
234 | { | |
235 | void* address; | |
236 | mach_msg_size_t count; | |
237 | boolean_t deallocate: 8; | |
238 | mach_msg_copy_options_t copy: 8; | |
239 | mach_msg_type_name_t disposition : 8; | |
240 | mach_msg_descriptor_type_t type : 8; | |
241 | } mach_msg_ool_ports_descriptor_t; | |
242 | ||
243 | typedef union | |
244 | { | |
245 | mach_msg_port_descriptor_t port; | |
246 | mach_msg_ool_descriptor_t out_of_line; | |
247 | mach_msg_ool_ports_descriptor_t ool_ports; | |
248 | mach_msg_type_descriptor_t type; | |
249 | } mach_msg_descriptor_t; | |
250 | ||
251 | typedef struct | |
252 | { | |
253 | mach_msg_size_t msgh_descriptor_count; | |
254 | } mach_msg_body_t; | |
255 | ||
256 | #define MACH_MSG_BODY_NULL (mach_msg_body_t *) 0 | |
257 | #define MACH_MSG_DESCRIPTOR_NULL (mach_msg_descriptor_t *) 0 | |
258 | ||
259 | typedef struct | |
260 | { | |
261 | mach_msg_bits_t msgh_bits; | |
262 | mach_msg_size_t msgh_size; | |
263 | mach_port_t msgh_remote_port; | |
264 | mach_port_t msgh_local_port; | |
265 | mach_msg_size_t msgh_reserved; | |
266 | mach_msg_id_t msgh_id; | |
267 | } mach_msg_header_t; | |
268 | ||
269 | #define MACH_MSG_NULL (mach_msg_header_t *) 0 | |
270 | ||
271 | typedef struct | |
272 | { | |
273 | mach_msg_header_t header; | |
274 | mach_msg_body_t body; | |
275 | } mach_msg_base_t; | |
276 | ||
277 | typedef unsigned int mach_msg_trailer_type_t; | |
278 | ||
279 | #define MACH_MSG_TRAILER_FORMAT_0 0 | |
280 | ||
281 | typedef unsigned int mach_msg_trailer_size_t; | |
282 | ||
283 | typedef struct | |
284 | { | |
285 | mach_msg_trailer_type_t msgh_trailer_type; | |
286 | mach_msg_trailer_size_t msgh_trailer_size; | |
287 | } mach_msg_trailer_t; | |
288 | ||
289 | typedef struct | |
290 | { | |
291 | mach_msg_trailer_type_t msgh_trailer_type; | |
292 | mach_msg_trailer_size_t msgh_trailer_size; | |
293 | mach_port_seqno_t msgh_seqno; | |
294 | } mach_msg_seqno_trailer_t; | |
295 | ||
296 | typedef struct | |
297 | { | |
298 | unsigned int val[2]; | |
299 | } security_token_t; | |
300 | ||
301 | typedef struct | |
302 | { | |
303 | mach_msg_trailer_type_t msgh_trailer_type; | |
304 | mach_msg_trailer_size_t msgh_trailer_size; | |
305 | mach_port_seqno_t msgh_seqno; | |
306 | security_token_t msgh_sender; | |
307 | } mach_msg_security_trailer_t; | |
308 | ||
55e303ae A |
309 | typedef struct |
310 | { | |
311 | unsigned int val[8]; | |
312 | } audit_token_t; | |
313 | ||
314 | typedef struct | |
315 | { | |
316 | mach_msg_trailer_type_t msgh_trailer_type; | |
317 | mach_msg_trailer_size_t msgh_trailer_size; | |
318 | mach_port_seqno_t msgh_seqno; | |
319 | security_token_t msgh_sender; | |
320 | audit_token_t msgh_audit; | |
321 | } mach_msg_audit_trailer_t; | |
1c79356b | 322 | |
1c79356b | 323 | #define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t) |
55e303ae A |
324 | |
325 | /* | |
326 | * These values can change from release to release - but clearly | |
327 | * code cannot request additional trailer elements one was not | |
328 | * compiled to understand. Therefore, it is safe to use this | |
329 | * constant when the same module specified the receive options. | |
330 | * Otherwise, you run the risk that the options requested by | |
331 | * another module may exceed the local modules notion of | |
332 | * MAX_TRAILER_SIZE. | |
333 | */ | |
334 | typedef mach_msg_audit_trailer_t mach_msg_max_trailer_t; | |
335 | #define MAX_TRAILER_SIZE sizeof(mach_msg_max_trailer_t) | |
336 | ||
337 | /* | |
338 | * Legacy requirements keep us from ever updating these defines (even | |
339 | * when the format_0 trailers gain new option data fields in the future). | |
340 | * Therefore, they shouldn't be used going forward. Instead, the sizes | |
341 | * should be compared against the specific element size requested using | |
342 | * REQUESTED_TRAILER_SIZE. | |
343 | */ | |
344 | typedef mach_msg_security_trailer_t mach_msg_format_0_trailer_t; | |
345 | #define MACH_MSG_TRAILER_FORMAT_0_SIZE sizeof(mach_msg_format_0_trailer_t) | |
1c79356b A |
346 | |
347 | #define KERNEL_SECURITY_TOKEN_VALUE { {0, 1} } | |
348 | extern security_token_t KERNEL_SECURITY_TOKEN; | |
349 | ||
55e303ae A |
350 | #define KERNEL_AUDIT_TOKEN_VALUE { {0, 0, 0, 0, 0, 0, 0, 0} } |
351 | extern audit_token_t KERNEL_AUDIT_TOKEN; | |
352 | ||
1c79356b A |
353 | typedef integer_t mach_msg_options_t; |
354 | ||
355 | typedef struct | |
356 | { | |
357 | mach_msg_header_t header; | |
358 | } mach_msg_empty_send_t; | |
359 | ||
360 | typedef struct | |
361 | { | |
362 | mach_msg_header_t header; | |
363 | mach_msg_trailer_t trailer; | |
364 | } mach_msg_empty_rcv_t; | |
365 | ||
366 | typedef union | |
367 | { | |
368 | mach_msg_empty_send_t send; | |
369 | mach_msg_empty_rcv_t rcv; | |
370 | } mach_msg_empty_t; | |
371 | ||
372 | /* utility to round the message size - will become machine dependent */ | |
373 | #define round_msg(x) (((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \ | |
374 | ~(sizeof (natural_t) - 1)) | |
375 | ||
376 | /* | |
377 | * There is no fixed upper bound to the size of Mach messages. | |
378 | */ | |
379 | ||
380 | #define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0) | |
381 | ||
9bccf70c | 382 | #ifdef __APPLE_API_OBSOLETE |
1c79356b A |
383 | /* |
384 | * Compatibility definitions, for code written | |
385 | * when there was a msgh_kind instead of msgh_seqno. | |
386 | */ | |
1c79356b | 387 | #define MACH_MSGH_KIND_NORMAL 0x00000000 |
1c79356b | 388 | #define MACH_MSGH_KIND_NOTIFICATION 0x00000001 |
1c79356b A |
389 | #define msgh_kind msgh_seqno |
390 | #define mach_msg_kind_t mach_port_seqno_t | |
9bccf70c | 391 | #endif /* __APPLE_API_OBSOLETE */ |
1c79356b A |
392 | |
393 | /* | |
394 | * The msgt_number field specifies the number of data elements. | |
395 | * The msgt_size field specifies the size of each data element, in bits. | |
396 | * The msgt_name field specifies the type of each data element. | |
397 | * If msgt_inline is TRUE, the data follows the type descriptor | |
398 | * in the body of the message. If msgt_inline is FALSE, then a pointer | |
399 | * to the data should follow the type descriptor, and the data is | |
400 | * sent out-of-line. In this case, if msgt_deallocate is TRUE, | |
401 | * then the out-of-line data is moved (instead of copied) into the message. | |
402 | * If msgt_longform is TRUE, then the type descriptor is actually | |
403 | * a mach_msg_type_long_t. | |
404 | * | |
405 | * The actual amount of inline data following the descriptor must | |
406 | * a multiple of the word size. For out-of-line data, this is a | |
407 | * pointer. For inline data, the supplied data size (calculated | |
408 | * from msgt_number/msgt_size) is rounded up. This guarantees | |
409 | * that type descriptors always fall on word boundaries. | |
410 | * | |
411 | * For port rights, msgt_size must be 8*sizeof(mach_port_t). | |
412 | * If the data is inline, msgt_deallocate should be FALSE. | |
413 | * The msgt_unused bit should be zero. | |
414 | * The msgt_name, msgt_size, msgt_number fields in | |
415 | * a mach_msg_type_long_t should be zero. | |
416 | */ | |
417 | ||
418 | typedef natural_t mach_msg_type_size_t; | |
419 | typedef natural_t mach_msg_type_number_t; | |
420 | ||
421 | /* | |
422 | * Values received/carried in messages. Tells the receiver what | |
423 | * sort of port right he now has. | |
424 | * | |
425 | * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name | |
426 | * which should remain uninterpreted by the kernel. (Port rights | |
427 | * are not transferred, just the port name.) | |
428 | */ | |
429 | ||
430 | #define MACH_MSG_TYPE_PORT_NONE 0 | |
431 | ||
432 | #define MACH_MSG_TYPE_PORT_NAME 15 | |
433 | #define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE | |
434 | #define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND | |
435 | #define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE | |
436 | ||
437 | #define MACH_MSG_TYPE_LAST 22 /* Last assigned */ | |
438 | ||
439 | /* | |
440 | * A dummy value. Mostly used to indicate that the actual value | |
441 | * will be filled in later, dynamically. | |
442 | */ | |
443 | ||
444 | #define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1) | |
445 | ||
446 | /* | |
447 | * Is a given item a port type? | |
448 | */ | |
449 | ||
450 | #define MACH_MSG_TYPE_PORT_ANY(x) \ | |
451 | (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ | |
452 | ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) | |
453 | ||
454 | #define MACH_MSG_TYPE_PORT_ANY_SEND(x) \ | |
455 | (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \ | |
456 | ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) | |
457 | ||
458 | #define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \ | |
459 | (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ | |
460 | ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE)) | |
461 | ||
462 | typedef integer_t mach_msg_option_t; | |
463 | ||
464 | #define MACH_MSG_OPTION_NONE 0x00000000 | |
465 | ||
466 | #define MACH_SEND_MSG 0x00000001 | |
467 | #define MACH_RCV_MSG 0x00000002 | |
468 | #define MACH_RCV_LARGE 0x00000004 | |
469 | ||
470 | #define MACH_SEND_TIMEOUT 0x00000010 | |
471 | #define MACH_SEND_INTERRUPT 0x00000040 /* libmach implements */ | |
472 | #define MACH_SEND_CANCEL 0x00000080 | |
473 | #define MACH_SEND_ALWAYS 0x00010000 /* internal use only */ | |
474 | #define MACH_SEND_TRAILER 0x00020000 | |
475 | ||
476 | #define MACH_RCV_TIMEOUT 0x00000100 | |
477 | #define MACH_RCV_NOTIFY 0x00000200 | |
478 | #define MACH_RCV_INTERRUPT 0x00000400 /* libmach implements */ | |
479 | #define MACH_RCV_OVERWRITE 0x00001000 | |
480 | ||
481 | /* | |
482 | * NOTE: a 0x00------ RCV mask implies to ask for | |
483 | * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements, | |
484 | * which is equivalent to a mach_msg_trailer_t. | |
485 | */ | |
486 | #define MACH_RCV_TRAILER_NULL 0 | |
487 | #define MACH_RCV_TRAILER_SEQNO 1 | |
488 | #define MACH_RCV_TRAILER_SENDER 2 | |
55e303ae | 489 | #define MACH_RCV_TRAILER_AUDIT 3 |
1c79356b A |
490 | |
491 | #define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28) | |
492 | #define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24) | |
493 | #define MACH_RCV_TRAILER_MASK ((0xff << 24)) | |
494 | ||
1c79356b | 495 | #define GET_RCV_ELEMENTS(y) (((y) >> 24) & 0xf) |
9bccf70c A |
496 | #define REQUESTED_TRAILER_SIZE(y) \ |
497 | ((mach_msg_trailer_size_t) \ | |
498 | ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \ | |
499 | sizeof(mach_msg_trailer_t) : \ | |
500 | ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \ | |
501 | sizeof(mach_msg_seqno_trailer_t) : \ | |
55e303ae A |
502 | ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \ |
503 | sizeof(mach_msg_security_trailer_t) : \ | |
504 | sizeof(mach_msg_audit_trailer_t))))) | |
1c79356b A |
505 | /* |
506 | * Much code assumes that mach_msg_return_t == kern_return_t. | |
507 | * This definition is useful for descriptive purposes. | |
508 | * | |
509 | * See <mach/error.h> for the format of error codes. | |
510 | * IPC errors are system 4. Send errors are subsystem 0; | |
511 | * receive errors are subsystem 1. The code field is always non-zero. | |
512 | * The high bits of the code field communicate extra information | |
513 | * for some error codes. MACH_MSG_MASK masks off these special bits. | |
514 | */ | |
515 | ||
516 | typedef kern_return_t mach_msg_return_t; | |
517 | ||
518 | #define MACH_MSG_SUCCESS 0x00000000 | |
519 | ||
520 | ||
521 | #define MACH_MSG_MASK 0x00003e00 | |
522 | /* All special error code bits defined below. */ | |
523 | #define MACH_MSG_IPC_SPACE 0x00002000 | |
524 | /* No room in IPC name space for another capability name. */ | |
525 | #define MACH_MSG_VM_SPACE 0x00001000 | |
526 | /* No room in VM address space for out-of-line memory. */ | |
527 | #define MACH_MSG_IPC_KERNEL 0x00000800 | |
528 | /* Kernel resource shortage handling an IPC capability. */ | |
529 | #define MACH_MSG_VM_KERNEL 0x00000400 | |
530 | /* Kernel resource shortage handling out-of-line memory. */ | |
531 | ||
532 | #define MACH_SEND_IN_PROGRESS 0x10000001 | |
533 | /* Thread is waiting to send. (Internal use only.) */ | |
534 | #define MACH_SEND_INVALID_DATA 0x10000002 | |
535 | /* Bogus in-line data. */ | |
536 | #define MACH_SEND_INVALID_DEST 0x10000003 | |
537 | /* Bogus destination port. */ | |
538 | #define MACH_SEND_TIMED_OUT 0x10000004 | |
539 | /* Message not sent before timeout expired. */ | |
540 | #define MACH_SEND_INTERRUPTED 0x10000007 | |
541 | /* Software interrupt. */ | |
542 | #define MACH_SEND_MSG_TOO_SMALL 0x10000008 | |
543 | /* Data doesn't contain a complete message. */ | |
544 | #define MACH_SEND_INVALID_REPLY 0x10000009 | |
545 | /* Bogus reply port. */ | |
546 | #define MACH_SEND_INVALID_RIGHT 0x1000000a | |
547 | /* Bogus port rights in the message body. */ | |
548 | #define MACH_SEND_INVALID_NOTIFY 0x1000000b | |
549 | /* Bogus notify port argument. */ | |
550 | #define MACH_SEND_INVALID_MEMORY 0x1000000c | |
551 | /* Invalid out-of-line memory pointer. */ | |
552 | #define MACH_SEND_NO_BUFFER 0x1000000d | |
553 | /* No message buffer is available. */ | |
554 | #define MACH_SEND_TOO_LARGE 0x1000000e | |
555 | /* Send is too large for port */ | |
556 | #define MACH_SEND_INVALID_TYPE 0x1000000f | |
557 | /* Invalid msg-type specification. */ | |
558 | #define MACH_SEND_INVALID_HEADER 0x10000010 | |
559 | /* A field in the header had a bad value. */ | |
560 | #define MACH_SEND_INVALID_TRAILER 0x10000011 | |
561 | /* The trailer to be sent does not match kernel format. */ | |
562 | #define MACH_SEND_INVALID_RT_OOL_SIZE 0x10000015 | |
9bccf70c | 563 | /* compatibility: no longer a returned error */ |
1c79356b A |
564 | |
565 | #define MACH_RCV_IN_PROGRESS 0x10004001 | |
566 | /* Thread is waiting for receive. (Internal use only.) */ | |
567 | #define MACH_RCV_INVALID_NAME 0x10004002 | |
568 | /* Bogus name for receive port/port-set. */ | |
569 | #define MACH_RCV_TIMED_OUT 0x10004003 | |
570 | /* Didn't get a message within the timeout value. */ | |
571 | #define MACH_RCV_TOO_LARGE 0x10004004 | |
572 | /* Message buffer is not large enough for inline data. */ | |
573 | #define MACH_RCV_INTERRUPTED 0x10004005 | |
574 | /* Software interrupt. */ | |
575 | #define MACH_RCV_PORT_CHANGED 0x10004006 | |
9bccf70c | 576 | /* compatibility: no longer a returned error */ |
1c79356b A |
577 | #define MACH_RCV_INVALID_NOTIFY 0x10004007 |
578 | /* Bogus notify port argument. */ | |
579 | #define MACH_RCV_INVALID_DATA 0x10004008 | |
580 | /* Bogus message buffer for inline data. */ | |
581 | #define MACH_RCV_PORT_DIED 0x10004009 | |
582 | /* Port/set was sent away/died during receive. */ | |
583 | #define MACH_RCV_IN_SET 0x1000400a | |
9bccf70c | 584 | /* compatibility: no longer a returned error */ |
1c79356b A |
585 | #define MACH_RCV_HEADER_ERROR 0x1000400b |
586 | /* Error receiving message header. See special bits. */ | |
587 | #define MACH_RCV_BODY_ERROR 0x1000400c | |
588 | /* Error receiving message body. See special bits. */ | |
589 | #define MACH_RCV_INVALID_TYPE 0x1000400d | |
590 | /* Invalid msg-type specification in scatter list. */ | |
591 | #define MACH_RCV_SCATTER_SMALL 0x1000400e | |
592 | /* Out-of-line overwrite region is not large enough */ | |
593 | #define MACH_RCV_INVALID_TRAILER 0x1000400f | |
594 | /* trailer type or number of trailer elements not supported */ | |
595 | #define MACH_RCV_IN_PROGRESS_TIMED 0x10004011 | |
596 | /* Waiting for receive with timeout. (Internal use only.) */ | |
597 | ||
9bccf70c A |
598 | /* |
599 | * Routine: mach_msg_overwrite | |
600 | * Purpose: | |
601 | * Send and/or receive a message. If the message operation | |
602 | * is interrupted, and the user did not request an indication | |
603 | * of that fact, then restart the appropriate parts of the | |
604 | * operation silently (trap version does not restart). | |
605 | * | |
606 | * Distinct send and receive buffers may be specified. If | |
607 | * no separate receive buffer is specified, the msg parameter | |
608 | * will be used for both send and receive operations. | |
609 | * | |
610 | * In addition to a distinct receive buffer, that buffer may | |
611 | * already contain scatter control information to direct the | |
612 | * receiving of the message. | |
613 | */ | |
614 | #ifdef __APPLE_API_PRIVATE | |
1c79356b A |
615 | extern mach_msg_return_t mach_msg_overwrite_trap( |
616 | mach_msg_header_t *msg, | |
617 | mach_msg_option_t option, | |
618 | mach_msg_size_t send_size, | |
619 | mach_msg_size_t rcv_size, | |
620 | mach_port_name_t rcv_name, | |
621 | mach_msg_timeout_t timeout, | |
622 | mach_port_name_t notify, | |
623 | mach_msg_header_t *rcv_msg, | |
624 | mach_msg_size_t rcv_limit); | |
9bccf70c | 625 | #endif /* __APPLE_API_PRIVATE */ |
1c79356b A |
626 | |
627 | extern mach_msg_return_t mach_msg_overwrite( | |
628 | mach_msg_header_t *msg, | |
629 | mach_msg_option_t option, | |
630 | mach_msg_size_t send_size, | |
631 | mach_msg_size_t rcv_size, | |
632 | mach_port_name_t rcv_name, | |
633 | mach_msg_timeout_t timeout, | |
634 | mach_port_name_t notify, | |
635 | mach_msg_header_t *rcv_msg, | |
636 | mach_msg_size_t rcv_limit); | |
637 | ||
9bccf70c A |
638 | /* |
639 | * Routine: mach_msg | |
640 | * Purpose: | |
641 | * Send and/or receive a message. If the message operation | |
642 | * is interrupted, and the user did not request an indication | |
643 | * of that fact, then restart the appropriate parts of the | |
644 | * operation silently (trap version does not restart). | |
645 | */ | |
646 | #ifdef __APPLE_API_PRIVATE | |
1c79356b A |
647 | extern mach_msg_return_t mach_msg_trap( |
648 | mach_msg_header_t *msg, | |
649 | mach_msg_option_t option, | |
650 | mach_msg_size_t send_size, | |
651 | mach_msg_size_t rcv_size, | |
652 | mach_port_name_t rcv_name, | |
653 | mach_msg_timeout_t timeout, | |
654 | mach_port_name_t notify); | |
9bccf70c | 655 | #endif /* __APPLE_API_PRIVATE */ |
1c79356b A |
656 | |
657 | extern mach_msg_return_t mach_msg( | |
658 | mach_msg_header_t *msg, | |
659 | mach_msg_option_t option, | |
660 | mach_msg_size_t send_size, | |
661 | mach_msg_size_t rcv_size, | |
662 | mach_port_name_t rcv_name, | |
663 | mach_msg_timeout_t timeout, | |
664 | mach_port_name_t notify); | |
665 | ||
666 | #endif /* _MACH_MESSAGE_H_ */ |