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