Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/include/mach/message.h

1/*
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31/*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56/*
57 * NOTICE: This file was modified by McAfee Research in 2004 to introduce
58 * support for mandatory and extensible security protections. This notice
59 * is included in support of clause 2.2 (b) of the Apple Public License,
60 * Version 2.0.
61 * Copyright (c) 2005 SPARTA, Inc.
62 */
63/*
64 */
65/*
66 *File:mach/message.h
67 *
68 *Mach IPC message and primitive function definitions.
69 */
70
71#ifndef_MACH_MESSAGE_H_
72#define _MACH_MESSAGE_H_
73
74#include <stdint.h>
75#include <mach/port.h>
76#include <mach/boolean.h>
77#include <mach/kern_return.h>
78#include <mach/machine/vm_types.h>
79
80#include <sys/cdefs.h>
81#include <sys/appleapiopts.h>
82
83/*
84 * The timeout mechanism uses mach_msg_timeout_t values,
85 * passed by value. The timeout units are milliseconds.
86 * It is controlled with the MACH_SEND_TIMEOUT
87 * and MACH_RCV_TIMEOUT options.
88 */
89
90typedef natural_t mach_msg_timeout_t;
91
92/*
93 * The value to be used when there is no timeout.
94 * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.)
95 */
96
97#define MACH_MSG_TIMEOUT_NONE((mach_msg_timeout_t) 0)
98
99/*
100 * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. If it isn't on, it
101 * assumes the body of the message doesn't contain port rights or OOL
102 * data. The field is set in received messages. A user task must
103 * use caution in interpreting the body of a message if the bit isn't
104 * on, because the mach_msg_type's in the body might "lie" about the
105 * contents. If the bit isn't on, but the mach_msg_types
106 * in the body specify rights or OOL data, the behavior is undefined.
107 * (Ie, an error may or may not be produced.)
108 *
109 * The value of MACH_MSGH_BITS_REMOTE determines the interpretation
110 * of the msgh_remote_port field. It is handled like a msgt_name.
111 *
112 * The value of MACH_MSGH_BITS_LOCAL determines the interpretation
113 * of the msgh_local_port field. It is handled like a msgt_name.
114 *
115 * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote
116 * and local fields, into a single value suitable for msgh_bits.
117 *
118 * MACH_MSGH_BITS_CIRCULAR should be zero; is is used internally.
119 *
120 * The unused bits should be zero and are reserved for the kernel
121 * or for future interface expansion.
122 */
123
124#define MACH_MSGH_BITS_ZERO0x00000000
125#define MACH_MSGH_BITS_REMOTE_MASK0x000000ff
126#define MACH_MSGH_BITS_LOCAL_MASK0x0000ff00
127#define MACH_MSGH_BITS_COMPLEX0x80000000U
128#define MACH_MSGH_BITS_USER 0x8000ffffU
129
130#defineMACH_MSGH_BITS_CIRCULAR0x40000000/* internal use only */
131#defineMACH_MSGH_BITS_USED0xc000ffffU
132
133#defineMACH_MSGH_BITS_PORTS_MASK\
134(MACH_MSGH_BITS_REMOTE_MASK|MACH_MSGH_BITS_LOCAL_MASK)
135
136#define MACH_MSGH_BITS(remote, local)\
137((remote) | ((local) << 8))
138#defineMACH_MSGH_BITS_REMOTE(bits)\
139((bits) & MACH_MSGH_BITS_REMOTE_MASK)
140#defineMACH_MSGH_BITS_LOCAL(bits)\
141(((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8)
142#defineMACH_MSGH_BITS_PORTS(bits)\
143((bits) & MACH_MSGH_BITS_PORTS_MASK)
144#defineMACH_MSGH_BITS_OTHER(bits)\
145((bits) &~ MACH_MSGH_BITS_PORTS_MASK)
146
147/*
148 * Every message starts with a message header.
149 * Following the message header, if the message is complex, are a count
150 * of type descriptors and the type descriptors themselves
151 * (mach_msg_descriptor_t). The size of the message must be specified in
152 * bytes, and includes the message header, descriptor count, descriptors,
153 * and inline data.
154 *
155 * The msgh_remote_port field specifies the destination of the message.
156 * It must specify a valid send or send-once right for a port.
157 *
158 * The msgh_local_port field specifies a "reply port". Normally,
159 * This field carries a send-once right that the receiver will use
160 * to reply to the message. It may carry the values MACH_PORT_NULL,
161 * MACH_PORT_DEAD, a send-once right, or a send right.
162 *
163 * The msgh_seqno field carries a sequence number associated with the
164 * received-from port. A port's sequence number is incremented every
165 * time a message is received from it. In sent messages, the field's
166 * value is ignored.
167 *
168 * The msgh_id field is uninterpreted by the message primitives.
169 * It normally carries information specifying the format
170 * or meaning of the message.
171 */
172
173typedef unsigned int mach_msg_bits_t;
174typedefnatural_t mach_msg_size_t;
175typedef integer_t mach_msg_id_t;
176
177
178#define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0
179
180typedef unsigned int mach_msg_type_name_t;
181
182#define MACH_MSG_TYPE_MOVE_RECEIVE16/* Must hold receive rights */
183#define MACH_MSG_TYPE_MOVE_SEND17/* Must hold send rights */
184#define MACH_MSG_TYPE_MOVE_SEND_ONCE18/* Must hold sendonce rights */
185#define MACH_MSG_TYPE_COPY_SEND19/* Must hold send rights */
186#define MACH_MSG_TYPE_MAKE_SEND20/* Must hold receive rights */
187#define MACH_MSG_TYPE_MAKE_SEND_ONCE21/* Must hold receive rights */
188#define MACH_MSG_TYPE_COPY_RECEIVE22/* Must hold receive rights */
189
190typedef unsigned int mach_msg_copy_options_t;
191
192#define MACH_MSG_PHYSICAL_COPY0
193#define MACH_MSG_VIRTUAL_COPY 1
194#define MACH_MSG_ALLOCATE2
195#define MACH_MSG_OVERWRITE3
196#ifdef MACH_KERNEL
197#define MACH_MSG_KALLOC_COPY_T4
198#endif /* MACH_KERNEL */
199
200/*
201 * In a complex mach message, the mach_msg_header_t is followed by
202 * a descriptor count, then an array of that number of descriptors
203 * (mach_msg_*_descriptor_t). The type field of mach_msg_type_descriptor_t
204 * (which any descriptor can be cast to) indicates the flavor of the
205 * descriptor.
206 *
207 * Note that in LP64, the various types of descriptors are no longer all
208 * the same size as mach_msg_descriptor_t, so the array cannot be indexed
209 * as expected.
210 */
211
212typedef unsigned int mach_msg_descriptor_type_t;
213
214#define MACH_MSG_PORT_DESCRIPTOR 0
215#define MACH_MSG_OOL_DESCRIPTOR 1
216#define MACH_MSG_OOL_PORTS_DESCRIPTOR 2
217#define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3
218
219#pragma pack(4)
220
221typedef struct
222{
223 natural_tpad1;
224 mach_msg_size_tpad2;
225 unsigned intpad3 : 24;
226 mach_msg_descriptor_type_ttype : 8;
227} mach_msg_type_descriptor_t;
228
229typedef struct
230{
231 mach_port_tname;
232// Pad to 8 bytes everywhere except the K64 kernel where mach_port_t is 8 bytes
233 mach_msg_size_tpad1;
234 unsigned intpad2 : 16;
235 mach_msg_type_name_tdisposition : 8;
236 mach_msg_descriptor_type_ttype : 8;
237} mach_msg_port_descriptor_t;
238
239typedef struct
240{
241 uint32_taddress;
242 mach_msg_size_t size;
243 boolean_t deallocate: 8;
244 mach_msg_copy_options_t copy: 8;
245 unsigned int pad1: 8;
246 mach_msg_descriptor_type_t type: 8;
247} mach_msg_ool_descriptor32_t;
248
249typedef struct
250{
251 uint64_taddress;
252 boolean_t deallocate: 8;
253 mach_msg_copy_options_t copy: 8;
254 unsigned int pad1: 8;
255 mach_msg_descriptor_type_t type: 8;
256 mach_msg_size_t size;
257} mach_msg_ool_descriptor64_t;
258
259typedef struct
260{
261 void*address;
262#if !defined(__LP64__)
263 mach_msg_size_t size;
264#endif
265 boolean_t deallocate: 8;
266 mach_msg_copy_options_t copy: 8;
267 unsigned int pad1: 8;
268 mach_msg_descriptor_type_t type: 8;
269#if defined(__LP64__)
270 mach_msg_size_t size;
271#endif
272} mach_msg_ool_descriptor_t;
273
274typedef struct
275{
276 uint32_taddress;
277 mach_msg_size_tcount;
278 boolean_t deallocate: 8;
279 mach_msg_copy_options_t copy: 8;
280 mach_msg_type_name_tdisposition : 8;
281 mach_msg_descriptor_type_ttype : 8;
282} mach_msg_ool_ports_descriptor32_t;
283
284typedef struct
285{
286 uint64_taddress;
287 boolean_t deallocate: 8;
288 mach_msg_copy_options_t copy: 8;
289 mach_msg_type_name_tdisposition : 8;
290 mach_msg_descriptor_type_ttype : 8;
291 mach_msg_size_tcount;
292} mach_msg_ool_ports_descriptor64_t;
293
294typedef struct
295{
296 void*address;
297#if !defined(__LP64__)
298 mach_msg_size_tcount;
299#endif
300 boolean_t deallocate: 8;
301 mach_msg_copy_options_t copy: 8;
302 mach_msg_type_name_tdisposition : 8;
303 mach_msg_descriptor_type_ttype : 8;
304#if defined(__LP64__)
305 mach_msg_size_tcount;
306#endif
307} mach_msg_ool_ports_descriptor_t;
308
309/*
310 * LP64support - This union definition is not really
311 * appropriate in LP64 mode because not all descriptors
312 * are of the same size in that environment.
313 */
314typedef union
315{
316 mach_msg_port_descriptor_tport;
317 mach_msg_ool_descriptor_tout_of_line;
318 mach_msg_ool_ports_descriptor_tool_ports;
319 mach_msg_type_descriptor_ttype;
320} mach_msg_descriptor_t;
321
322typedef struct
323{
324 mach_msg_size_t msgh_descriptor_count;
325} mach_msg_body_t;
326
327#define MACH_MSG_BODY_NULL (mach_msg_body_t *) 0
328#define MACH_MSG_DESCRIPTOR_NULL (mach_msg_descriptor_t *) 0
329
330typedefstruct
331{
332 mach_msg_bits_tmsgh_bits;
333 mach_msg_size_tmsgh_size;
334 mach_port_tmsgh_remote_port;
335 mach_port_tmsgh_local_port;
336 mach_msg_size_t msgh_reserved;
337 mach_msg_id_tmsgh_id;
338} mach_msg_header_t;
339
340#define MACH_MSG_NULL (mach_msg_header_t *) 0
341
342typedef struct
343{
344 mach_msg_header_t header;
345 mach_msg_body_t body;
346} mach_msg_base_t;
347
348typedefunsigned int mach_msg_trailer_type_t;
349
350#defineMACH_MSG_TRAILER_FORMAT_00
351
352typedefunsigned int mach_msg_trailer_size_t;
353
354typedef struct
355{
356 mach_msg_trailer_type_tmsgh_trailer_type;
357 mach_msg_trailer_size_tmsgh_trailer_size;
358} mach_msg_trailer_t;
359
360typedef struct
361{
362 mach_msg_trailer_type_t msgh_trailer_type;
363 mach_msg_trailer_size_t msgh_trailer_size;
364 mach_port_seqno_t msgh_seqno;
365} mach_msg_seqno_trailer_t;
366
367typedef struct
368{
369 unsigned intval[2];
370} security_token_t;
371
372typedef struct
373{
374 mach_msg_trailer_type_tmsgh_trailer_type;
375 mach_msg_trailer_size_tmsgh_trailer_size;
376 mach_port_seqno_tmsgh_seqno;
377 security_token_tmsgh_sender;
378} mach_msg_security_trailer_t;
379
380/*
381 * The audit token is an opaque token which identifies
382 * Mach tasks and senders of Mach messages as subjects
383 * to the BSM audit system. Only the appropriate BSM
384 * library routines should be used to interpret the
385 * contents of the audit token as the representation
386 * of the subject identity within the token may change
387 * over time.
388 */
389typedef struct
390{
391 unsigned intval[8];
392} audit_token_t;
393
394typedef struct
395{
396 mach_msg_trailer_type_tmsgh_trailer_type;
397 mach_msg_trailer_size_tmsgh_trailer_size;
398 mach_port_seqno_tmsgh_seqno;
399 security_token_tmsgh_sender;
400 audit_token_tmsgh_audit;
401} mach_msg_audit_trailer_t;
402
403typedef struct
404{
405 mach_msg_trailer_type_tmsgh_trailer_type;
406 mach_msg_trailer_size_tmsgh_trailer_size;
407 mach_port_seqno_tmsgh_seqno;
408 security_token_tmsgh_sender;
409 audit_token_tmsgh_audit;
410 mach_port_context_tmsgh_context;
411} mach_msg_context_trailer_t;
412
413typedef struct
414{
415 mach_port_name_t sender;
416} msg_labels_t;
417
418/*
419 Trailer type to pass MAC policy label info as a mach message trailer.
420
421*/
422
423typedef struct
424{
425 mach_msg_trailer_type_t msgh_trailer_type;
426 mach_msg_trailer_size_t msgh_trailer_size;
427 mach_port_seqno_t msgh_seqno;
428 security_token_t msgh_sender;
429 audit_token_t msgh_audit;
430 mach_port_context_tmsgh_context;
431 intmsgh_ad;
432 msg_labels_t msgh_labels;
433} mach_msg_mac_trailer_t;
434
435#define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t)
436
437/*
438 * These values can change from release to release - but clearly
439 * code cannot request additional trailer elements one was not
440 * compiled to understand. Therefore, it is safe to use this
441 * constant when the same module specified the receive options.
442 * Otherwise, you run the risk that the options requested by
443 * another module may exceed the local modules notion of
444 * MAX_TRAILER_SIZE.
445 */
446typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t;
447#define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t))
448
449/*
450 * Legacy requirements keep us from ever updating these defines (even
451 * when the format_0 trailers gain new option data fields in the future).
452 * Therefore, they shouldn't be used going forward. Instead, the sizes
453 * should be compared against the specific element size requested using
454 * REQUESTED_TRAILER_SIZE.
455 */
456typedef mach_msg_security_trailer_t mach_msg_format_0_trailer_t;
457
458/*typedef mach_msg_mac_trailer_t mach_msg_format_0_trailer_t;
459*/
460
461#define MACH_MSG_TRAILER_FORMAT_0_SIZE sizeof(mach_msg_format_0_trailer_t)
462
463#define KERNEL_SECURITY_TOKEN_VALUE { {0, 1} }
464extern security_token_t KERNEL_SECURITY_TOKEN;
465
466#define KERNEL_AUDIT_TOKEN_VALUE { {0, 0, 0, 0, 0, 0, 0, 0} }
467extern audit_token_t KERNEL_AUDIT_TOKEN;
468
469typedefinteger_t mach_msg_options_t;
470
471typedef struct
472{
473 mach_msg_header_theader;
474} mach_msg_empty_send_t;
475
476typedef struct
477{
478 mach_msg_header_theader;
479 mach_msg_trailer_ttrailer;
480} mach_msg_empty_rcv_t;
481
482typedef union
483{
484 mach_msg_empty_send_tsend;
485 mach_msg_empty_rcv_trcv;
486} mach_msg_empty_t;
487
488#pragma pack()
489
490/* utility to round the message size - will become machine dependent */
491#define round_msg(x)(((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \
492~(sizeof (natural_t) - 1))
493
494/*
495 * There is no fixed upper bound to the size of Mach messages.
496 */
497#defineMACH_MSG_SIZE_MAX((mach_msg_size_t) ~0)
498
499#if defined(__APPLE_API_PRIVATE)
500/*
501 * But architectural limits of a given implementation, or
502 * temporal conditions may cause unpredictable send failures
503 * for messages larger than MACH_MSG_SIZE_RELIABLE.
504 *
505 * In either case, waiting for memory is [currently] outside
506 * the scope of send timeout values provided to IPC.
507 */
508#defineMACH_MSG_SIZE_RELIABLE((mach_msg_size_t) 256 * 1024)
509#endif
510/*
511 * Compatibility definitions, for code written
512 * when there was a msgh_kind instead of msgh_seqno.
513 */
514#define MACH_MSGH_KIND_NORMAL0x00000000
515#define MACH_MSGH_KIND_NOTIFICATION0x00000001
516#definemsgh_kindmsgh_seqno
517#define mach_msg_kind_tmach_port_seqno_t
518
519typedef natural_t mach_msg_type_size_t;
520typedef natural_t mach_msg_type_number_t;
521
522/*
523 * Values received/carried in messages. Tells the receiver what
524 * sort of port right he now has.
525 *
526 * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name
527 * which should remain uninterpreted by the kernel. (Port rights
528 * are not transferred, just the port name.)
529 */
530
531#define MACH_MSG_TYPE_PORT_NONE0
532
533#define MACH_MSG_TYPE_PORT_NAME15
534#define MACH_MSG_TYPE_PORT_RECEIVEMACH_MSG_TYPE_MOVE_RECEIVE
535#define MACH_MSG_TYPE_PORT_SENDMACH_MSG_TYPE_MOVE_SEND
536#define MACH_MSG_TYPE_PORT_SEND_ONCEMACH_MSG_TYPE_MOVE_SEND_ONCE
537
538#define MACH_MSG_TYPE_LAST22/* Last assigned */
539
540/*
541 * A dummy value. Mostly used to indicate that the actual value
542 * will be filled in later, dynamically.
543 */
544
545#define MACH_MSG_TYPE_POLYMORPHIC((mach_msg_type_name_t) -1)
546
547/*
548 *Is a given item a port type?
549 */
550
551#define MACH_MSG_TYPE_PORT_ANY(x)\
552(((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) &&\
553 ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
554
555#defineMACH_MSG_TYPE_PORT_ANY_SEND(x)\
556(((x) >= MACH_MSG_TYPE_MOVE_SEND) &&\
557 ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
558
559#defineMACH_MSG_TYPE_PORT_ANY_RIGHT(x)\
560(((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) &&\
561 ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE))
562
563typedef integer_t mach_msg_option_t;
564
565#define MACH_MSG_OPTION_NONE0x00000000
566
567#defineMACH_SEND_MSG0x00000001
568#defineMACH_RCV_MSG0x00000002
569#define MACH_RCV_LARGE0x00000004
570
571#define MACH_SEND_TIMEOUT0x00000010
572#define MACH_SEND_INTERRUPT0x00000040/* libmach implements */
573#define MACH_SEND_NOTIFY0x00000080/* arm send-possible notify */
574#define MACH_SEND_ALWAYS0x00010000/* internal use only */
575#define MACH_SEND_TRAILER0x00020000
576
577#define MACH_RCV_TIMEOUT0x00000100
578#define MACH_RCV_NOTIFY0x00000200/* reserved - legacy */
579#define MACH_RCV_INTERRUPT0x00000400/* libmach implements */
580#define MACH_RCV_OVERWRITE0x00001000
581
582/*
583 * NOTE: a 0x00------ RCV mask implies to ask for
584 * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements,
585 * which is equivalent to a mach_msg_trailer_t.
586 *
587 * XXXMAC: unlike the rest of the MACH_RCV_* flags, MACH_RCV_TRAILER_LABELS
588 * needs its own private bit since we only calculate its fields when absolutely
589 * required.
590 */
591#define MACH_RCV_TRAILER_NULL 0
592#define MACH_RCV_TRAILER_SEQNO 1
593#define MACH_RCV_TRAILER_SENDER 2
594#define MACH_RCV_TRAILER_AUDIT 3
595#define MACH_RCV_TRAILER_CTX 4
596#define MACH_RCV_TRAILER_AV 7
597#define MACH_RCV_TRAILER_LABELS 8
598
599#define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28)
600#define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24)
601#define MACH_RCV_TRAILER_MASK ((0xff << 24))
602
603#define GET_RCV_ELEMENTS(y) (((y) >> 24) & 0xf)
604
605/*
606 * XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS,
607 * we just fall through to mach_msg_max_trailer_t.
608 * This is correct behavior since mach_msg_max_trailer_t is defined as
609 * mac_msg_mac_trailer_t which is used for the LABELS trailer.
610 * It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed
611 * with one of the other options.
612 */
613
614#define REQUESTED_TRAILER_SIZE_NATIVE(y)\
615((mach_msg_trailer_size_t)\
616 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ?\
617 sizeof(mach_msg_trailer_t) :\
618 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ?\
619 sizeof(mach_msg_seqno_trailer_t) :\
620 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ?\
621 sizeof(mach_msg_security_trailer_t) :\
622 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ?\
623 sizeof(mach_msg_audit_trailer_t) : \
624 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ?\
625 sizeof(mach_msg_context_trailer_t) : \
626 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ?\
627 sizeof(mach_msg_mac_trailer_t) : \
628 sizeof(mach_msg_max_trailer_t))))))))
629
630
631#define REQUESTED_TRAILER_SIZE(y) REQUESTED_TRAILER_SIZE_NATIVE(y)
632
633/*
634 * Much code assumes that mach_msg_return_t == kern_return_t.
635 * This definition is useful for descriptive purposes.
636 *
637 * See <mach/error.h> for the format of error codes.
638 * IPC errors are system 4. Send errors are subsystem 0;
639 * receive errors are subsystem 1. The code field is always non-zero.
640 * The high bits of the code field communicate extra information
641 * for some error codes. MACH_MSG_MASK masks off these special bits.
642 */
643
644typedef kern_return_t mach_msg_return_t;
645
646#define MACH_MSG_SUCCESS0x00000000
647
648
649#defineMACH_MSG_MASK0x00003e00
650/* All special error code bits defined below. */
651#defineMACH_MSG_IPC_SPACE0x00002000
652/* No room in IPC name space for another capability name. */
653#defineMACH_MSG_VM_SPACE0x00001000
654/* No room in VM address space for out-of-line memory. */
655#defineMACH_MSG_IPC_KERNEL0x00000800
656/* Kernel resource shortage handling an IPC capability. */
657#defineMACH_MSG_VM_KERNEL0x00000400
658/* Kernel resource shortage handling out-of-line memory. */
659
660#define MACH_SEND_IN_PROGRESS0x10000001
661/* Thread is waiting to send. (Internal use only.) */
662#define MACH_SEND_INVALID_DATA0x10000002
663/* Bogus in-line data. */
664#define MACH_SEND_INVALID_DEST0x10000003
665/* Bogus destination port. */
666#define MACH_SEND_TIMED_OUT0x10000004
667/* Message not sent before timeout expired. */
668#define MACH_SEND_INTERRUPTED0x10000007
669/* Software interrupt. */
670#define MACH_SEND_MSG_TOO_SMALL0x10000008
671/* Data doesn't contain a complete message. */
672#define MACH_SEND_INVALID_REPLY0x10000009
673/* Bogus reply port. */
674#define MACH_SEND_INVALID_RIGHT0x1000000a
675/* Bogus port rights in the message body. */
676#define MACH_SEND_INVALID_NOTIFY0x1000000b
677/* Bogus notify port argument. */
678#define MACH_SEND_INVALID_MEMORY0x1000000c
679/* Invalid out-of-line memory pointer. */
680#define MACH_SEND_NO_BUFFER0x1000000d
681/* No message buffer is available. */
682#define MACH_SEND_TOO_LARGE0x1000000e
683/* Send is too large for port */
684#define MACH_SEND_INVALID_TYPE0x1000000f
685/* Invalid msg-type specification. */
686#define MACH_SEND_INVALID_HEADER0x10000010
687/* A field in the header had a bad value. */
688#define MACH_SEND_INVALID_TRAILER0x10000011
689/* The trailer to be sent does not match kernel format. */
690#define MACH_SEND_INVALID_RT_OOL_SIZE0x10000015
691/* compatibility: no longer a returned error */
692
693#define MACH_RCV_IN_PROGRESS0x10004001
694/* Thread is waiting for receive. (Internal use only.) */
695#define MACH_RCV_INVALID_NAME0x10004002
696/* Bogus name for receive port/port-set. */
697#define MACH_RCV_TIMED_OUT0x10004003
698/* Didn't get a message within the timeout value. */
699#define MACH_RCV_TOO_LARGE0x10004004
700/* Message buffer is not large enough for inline data. */
701#define MACH_RCV_INTERRUPTED0x10004005
702/* Software interrupt. */
703#define MACH_RCV_PORT_CHANGED0x10004006
704/* compatibility: no longer a returned error */
705#define MACH_RCV_INVALID_NOTIFY0x10004007
706/* Bogus notify port argument. */
707#define MACH_RCV_INVALID_DATA0x10004008
708/* Bogus message buffer for inline data. */
709#define MACH_RCV_PORT_DIED0x10004009
710/* Port/set was sent away/died during receive. */
711#defineMACH_RCV_IN_SET0x1000400a
712/* compatibility: no longer a returned error */
713#defineMACH_RCV_HEADER_ERROR0x1000400b
714/* Error receiving message header. See special bits. */
715#defineMACH_RCV_BODY_ERROR0x1000400c
716/* Error receiving message body. See special bits. */
717#defineMACH_RCV_INVALID_TYPE0x1000400d
718/* Invalid msg-type specification in scatter list. */
719#defineMACH_RCV_SCATTER_SMALL0x1000400e
720/* Out-of-line overwrite region is not large enough */
721#define MACH_RCV_INVALID_TRAILER0x1000400f
722/* trailer type or number of trailer elements not supported */
723#define MACH_RCV_IN_PROGRESS_TIMED 0x10004011
724 /* Waiting for receive with timeout. (Internal use only.) */
725
726
727__BEGIN_DECLS
728
729/*
730 *Routine:mach_msg_overwrite
731 *Purpose:
732 *Send and/or receive a message. If the message operation
733 *is interrupted, and the user did not request an indication
734 *of that fact, then restart the appropriate parts of the
735 *operation silently (trap version does not restart).
736 *
737 *Distinct send and receive buffers may be specified. If
738 *no separate receive buffer is specified, the msg parameter
739 *will be used for both send and receive operations.
740 *
741 *In addition to a distinct receive buffer, that buffer may
742 *already contain scatter control information to direct the
743 *receiving of the message.
744 */
745
746extern mach_msg_return_tmach_msg_overwrite(
747mach_msg_header_t *msg,
748mach_msg_option_t option,
749mach_msg_size_t send_size,
750mach_msg_size_t rcv_size,
751mach_port_name_t rcv_name,
752mach_msg_timeout_t timeout,
753mach_port_name_t notify,
754mach_msg_header_t *rcv_msg,
755mach_msg_size_t rcv_limit);
756
757
758/*
759 *Routine:mach_msg
760 *Purpose:
761 *Send and/or receive a message. If the message operation
762 *is interrupted, and the user did not request an indication
763 *of that fact, then restart the appropriate parts of the
764 *operation silently (trap version does not restart).
765 */
766extern mach_msg_return_tmach_msg(
767mach_msg_header_t *msg,
768mach_msg_option_t option,
769mach_msg_size_t send_size,
770mach_msg_size_t rcv_size,
771mach_port_name_t rcv_name,
772mach_msg_timeout_t timeout,
773mach_port_name_t notify);
774
775
776__END_DECLS
777
778#endif/* _MACH_MESSAGE_H_ */
779
780

Archive Download this file

Revision: 2182