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