FreeBSD/Linux Kernel Cross Reference
sys/mach/message.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1992-1987 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: message.h,v $
29 * Revision 2.15 93/01/14 17:44:53 danner
30 * Cleanup.
31 * [92/06/10 pds]
32 * 64bit cleanup.
33 * [92/12/01 af]
34 *
35 * Revision 2.14 92/05/21 17:22:30 jfriedl
36 * Appended 'U' to constants that would otherwise be signed.
37 * [92/05/16 jfriedl]
38 *
39 * Revision 2.13 92/02/23 14:42:54 elf
40 * Condensed history, update copyright.
41 * [92/02/23 danner]
42 *
43 * Added MACH_MSGH_BITS_MIGRATED (NORMA_IPC internal).
44 * [91/12/25 16:42:44 jsb]
45 *
46 * Revision 2.12 92/01/15 13:44:29 rpd
47 * Changed MACH_IPC_COMPAT conditionals to default to not present.
48 *
49 * Condensed history:
50 * Check __STDC__ to get function prototypes. (rpd)
51 * Removed MACH_MSGH_KIND_NOTIFICATION compatibility defn. (rpd)
52 * Replaced msgh_kind with msgh_seqno. (jsb)
53 * Added MACH_MSGH_BITS_COMPLEX_{PORTS,DATA}. (jsb)
54 * Changed mach_msg_timeout_t to unsigned. (rpd)
55 * Converted to new IPC (rpd)
56 * Named unused bits in message structures (rpd).
57 * Added MSG_TYPE_POLYMORPHIC (rpd).
58 * Put ownership rights under MACH_IPC_XXXHACK (rpd).
59 * Removed some unused defines (rpd).
60 * Made MSG_TYPE_PORT_NAME a separate type (rpd).
61 * Added SEND_SWITCH (mwyoung).
62 * Added SEND_MSG_SIZE_CHANGE (mwyoung).
63 * Added msg_size_t, msg_timeout_t (mwyoung).
64 * Added MSG_TYPE_INTERNAL_MEMORY (mwyoung).
65 * Use unsigned ints/shorts (avie).
66 * Added SEND_INTERRUPT (mwyoung).
67 */
68 /*
69 * File: mach/message.h
70 *
71 * Mach IPC message and primitive function definitions.
72 */
73
74 #ifndef _MACH_MESSAGE_H_
75 #define _MACH_MESSAGE_H_
76
77 #ifdef KERNEL
78 #include <mach_ipc_compat.h>
79 #endif /* KERNEL */
80
81 #include <mach/kern_return.h>
82 #include <mach/port.h>
83
84
85 /*
86 * The timeout mechanism uses mach_msg_timeout_t values,
87 * passed by value. The timeout units are milliseconds.
88 * It is controlled with the MACH_SEND_TIMEOUT
89 * and MACH_RCV_TIMEOUT options.
90 */
91
92 typedef natural_t mach_msg_timeout_t;
93
94 /*
95 * The value to be used when there is no timeout.
96 * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.)
97 */
98
99 #define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0)
100
101 /*
102 * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. It it isn't on, it
103 * assumes the body of the message doesn't contain port rights or OOL
104 * data. The field is set in received messages. A user task must
105 * use caution in interpreting the body of a message if the bit isn't
106 * on, because the mach_msg_type's in the body might "lie" about the
107 * contents. If the bit isn't on, but the mach_msg_types
108 * in the body specify rights or OOL data, the behaviour is undefined.
109 * (Ie, an error may or may not be produced.)
110 *
111 * The value of MACH_MSGH_BITS_REMOTE determines the interpretation
112 * of the msgh_remote_port field. It is handled like a msgt_name.
113 *
114 * The value of MACH_MSGH_BITS_LOCAL determines the interpretation
115 * of the msgh_local_port field. It is handled like a msgt_name.
116 *
117 * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote
118 * and local fields, into a single value suitable for msgh_bits.
119 *
120 * MACH_MSGH_BITS_COMPLEX_PORTS, MACH_MSGH_BITS_COMPLEX_DATA, and
121 * MACH_MSGH_BITS_CIRCULAR should be zero; they are used internally.
122 *
123 * The unused bits should be zero.
124 */
125
126 #define MACH_MSGH_BITS_ZERO 0x00000000
127 #define MACH_MSGH_BITS_REMOTE_MASK 0x000000ff
128 #define MACH_MSGH_BITS_LOCAL_MASK 0x0000ff00
129 #define MACH_MSGH_BITS_COMPLEX 0x80000000U
130 #define MACH_MSGH_BITS_CIRCULAR 0x40000000 /* internal use only */
131 #define MACH_MSGH_BITS_COMPLEX_PORTS 0x20000000 /* internal use only */
132 #define MACH_MSGH_BITS_COMPLEX_DATA 0x10000000 /* internal use only */
133 #define MACH_MSGH_BITS_MIGRATED 0x08000000 /* internal use only */
134 #define MACH_MSGH_BITS_UNUSED 0x07ff0000
135
136 #define MACH_MSGH_BITS_PORTS_MASK \
137 (MACH_MSGH_BITS_REMOTE_MASK|MACH_MSGH_BITS_LOCAL_MASK)
138
139 #define MACH_MSGH_BITS(remote, local) \
140 ((remote) | ((local) << 8))
141 #define MACH_MSGH_BITS_REMOTE(bits) \
142 ((bits) & MACH_MSGH_BITS_REMOTE_MASK)
143 #define MACH_MSGH_BITS_LOCAL(bits) \
144 (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8)
145 #define MACH_MSGH_BITS_PORTS(bits) \
146 ((bits) & MACH_MSGH_BITS_PORTS_MASK)
147 #define MACH_MSGH_BITS_OTHER(bits) \
148 ((bits) &~ MACH_MSGH_BITS_PORTS_MASK)
149
150 /*
151 * Every message starts with a message header.
152 * Following the message header are zero or more pairs of
153 * type descriptors (mach_msg_type_t/mach_msg_type_long_t) and
154 * data values. The size of the message must be specified in bytes,
155 * and includes the message header, type descriptors, inline
156 * data, and inline pointer for out-of-line data.
157 *
158 * The msgh_remote_port field specifies the destination of the message.
159 * It must specify a valid send or send-once right for a port.
160 *
161 * The msgh_local_port field specifies a "reply port". Normally,
162 * This field carries a send-once right that the receiver will use
163 * to reply to the message. It may carry the values MACH_PORT_NULL,
164 * MACH_PORT_DEAD, a send-once right, or a send right.
165 *
166 * The msgh_seqno field carries a sequence number associated with the
167 * received-from port. A port's sequence number is incremented every
168 * time a message is received from it. In sent messages, the field's
169 * value is ignored.
170 *
171 * The msgh_id field is uninterpreted by the message primitives.
172 * It normally carries information specifying the format
173 * or meaning of the message.
174 */
175
176 typedef unsigned int mach_msg_bits_t;
177 typedef unsigned int mach_msg_size_t;
178 typedef natural_t mach_msg_seqno_t;
179 typedef integer_t mach_msg_id_t;
180
181 typedef struct {
182 mach_msg_bits_t msgh_bits;
183 mach_msg_size_t msgh_size;
184 mach_port_t msgh_remote_port;
185 mach_port_t msgh_local_port;
186 mach_port_seqno_t msgh_seqno;
187 mach_msg_id_t msgh_id;
188 } mach_msg_header_t;
189
190 /*
191 * There is no fixed upper bound to the size of Mach messages.
192 */
193
194 #define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0)
195
196 /*
197 * Compatibility definitions, for code written
198 * when there was a msgh_kind instead of msgh_seqno.
199 */
200
201 #define MACH_MSGH_KIND_NORMAL 0x00000000
202 #if 0
203 /* code using this is likely to break, so better not to have it defined */
204 #define MACH_MSGH_KIND_NOTIFICATION 0x00000001
205 #endif
206 #define msgh_kind msgh_seqno
207 #define mach_msg_kind_t mach_port_seqno_t
208
209 /*
210 * The msgt_number field specifies the number of data elements.
211 * The msgt_size field specifies the size of each data element, in bits.
212 * The msgt_name field specifies the type of each data element.
213 * If msgt_inline is TRUE, the data follows the type descriptor
214 * in the body of the message. If msgt_inline is FALSE, then a pointer
215 * to the data should follow the type descriptor, and the data is
216 * sent out-of-line. In this case, if msgt_deallocate is TRUE,
217 * then the out-of-line data is moved (instead of copied) into the message.
218 * If msgt_longform is TRUE, then the type descriptor is actually
219 * a mach_msg_type_long_t.
220 *
221 * The actual amount of inline data following the descriptor must
222 * a multiple of the word size. For out-of-line data, this is a
223 * pointer. For inline data, the supplied data size (calculated
224 * from msgt_number/msgt_size) is rounded up. This guarantees
225 * that type descriptors always fall on word boundaries.
226 *
227 * For port rights, msgt_size must be 8*sizeof(mach_port_t).
228 * If the data is inline, msgt_deallocate should be FALSE.
229 * The msgt_unused bit should be zero.
230 * The msgt_name, msgt_size, msgt_number fields in
231 * a mach_msg_type_long_t should be zero.
232 */
233
234 typedef unsigned int mach_msg_type_name_t;
235 typedef unsigned int mach_msg_type_size_t;
236 typedef natural_t mach_msg_type_number_t;
237
238 typedef struct {
239 unsigned int msgt_name : 8,
240 msgt_size : 8,
241 msgt_number : 12,
242 msgt_inline : 1,
243 msgt_longform : 1,
244 msgt_deallocate : 1,
245 msgt_unused : 1;
246 } mach_msg_type_t;
247
248 typedef struct {
249 mach_msg_type_t msgtl_header;
250 unsigned short msgtl_name;
251 unsigned short msgtl_size;
252 natural_t msgtl_number;
253 } mach_msg_type_long_t;
254
255
256 /*
257 * Known values for the msgt_name field.
258 *
259 * The only types known to the Mach kernel are
260 * the port types, and those types used in the
261 * kernel RPC interface.
262 */
263
264 #define MACH_MSG_TYPE_UNSTRUCTURED 0
265 #define MACH_MSG_TYPE_BIT 0
266 #define MACH_MSG_TYPE_BOOLEAN 0
267 #define MACH_MSG_TYPE_INTEGER_16 1
268 #define MACH_MSG_TYPE_INTEGER_32 2
269 #define MACH_MSG_TYPE_CHAR 8
270 #define MACH_MSG_TYPE_BYTE 9
271 #define MACH_MSG_TYPE_INTEGER_8 9
272 #define MACH_MSG_TYPE_REAL 10
273 #define MACH_MSG_TYPE_INTEGER_64 11
274 #define MACH_MSG_TYPE_STRING 12
275 #define MACH_MSG_TYPE_STRING_C 12
276
277 /*
278 * Values used when sending a port right.
279 */
280
281 #define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive rights */
282 #define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send rights */
283 #define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce rights */
284 #define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send rights */
285 #define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive rights */
286 #define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive rights */
287
288 /*
289 * Values received/carried in messages. Tells the receiver what
290 * sort of port right he now has.
291 *
292 * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name
293 * which should remain uninterpreted by the kernel. (Port rights
294 * are not transferred, just the port name.)
295 */
296
297 #define MACH_MSG_TYPE_PORT_NAME 15
298 #define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE
299 #define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND
300 #define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE
301
302 #define MACH_MSG_TYPE_LAST 22 /* Last assigned */
303
304 /*
305 * A dummy value. Mostly used to indicate that the actual value
306 * will be filled in later, dynamically.
307 */
308
309 #define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1)
310
311 /*
312 * Is a given item a port type?
313 */
314
315 #define MACH_MSG_TYPE_PORT_ANY(x) \
316 (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
317 ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
318
319 #define MACH_MSG_TYPE_PORT_ANY_SEND(x) \
320 (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \
321 ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
322
323 #define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \
324 (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
325 ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE))
326
327 typedef integer_t mach_msg_option_t;
328
329 #define MACH_MSG_OPTION_NONE 0x00000000
330
331 #define MACH_SEND_MSG 0x00000001
332 #define MACH_RCV_MSG 0x00000002
333
334 #define MACH_SEND_TIMEOUT 0x00000010
335 #define MACH_SEND_NOTIFY 0x00000020
336 #define MACH_SEND_INTERRUPT 0x00000040 /* libmach implements */
337 #define MACH_SEND_CANCEL 0x00000080
338 #define MACH_RCV_TIMEOUT 0x00000100
339 #define MACH_RCV_NOTIFY 0x00000200
340 #define MACH_RCV_INTERRUPT 0x00000400 /* libmach implements */
341 #define MACH_RCV_LARGE 0x00000800
342
343 #define MACH_SEND_ALWAYS 0x00010000 /* internal use only */
344
345
346 /*
347 * Much code assumes that mach_msg_return_t == kern_return_t.
348 * This definition is useful for descriptive purposes.
349 *
350 * See <mach/error.h> for the format of error codes.
351 * IPC errors are system 4. Send errors are subsystem 0;
352 * receive errors are subsystem 1. The code field is always non-zero.
353 * The high bits of the code field communicate extra information
354 * for some error codes. MACH_MSG_MASK masks off these special bits.
355 */
356
357 typedef kern_return_t mach_msg_return_t;
358
359 #define MACH_MSG_SUCCESS 0x00000000
360
361 #define MACH_MSG_MASK 0x00003c00
362 /* All special error code bits defined below. */
363 #define MACH_MSG_IPC_SPACE 0x00002000
364 /* No room in IPC name space for another capability name. */
365 #define MACH_MSG_VM_SPACE 0x00001000
366 /* No room in VM address space for out-of-line memory. */
367 #define MACH_MSG_IPC_KERNEL 0x00000800
368 /* Kernel resource shortage handling an IPC capability. */
369 #define MACH_MSG_VM_KERNEL 0x00000400
370 /* Kernel resource shortage handling out-of-line memory. */
371
372 #define MACH_SEND_IN_PROGRESS 0x10000001
373 /* Thread is waiting to send. (Internal use only.) */
374 #define MACH_SEND_INVALID_DATA 0x10000002
375 /* Bogus in-line data. */
376 #define MACH_SEND_INVALID_DEST 0x10000003
377 /* Bogus destination port. */
378 #define MACH_SEND_TIMED_OUT 0x10000004
379 /* Message not sent before timeout expired. */
380 #define MACH_SEND_WILL_NOTIFY 0x10000005
381 /* Msg-accepted notification will be generated. */
382 #define MACH_SEND_NOTIFY_IN_PROGRESS 0x10000006
383 /* Msg-accepted notification already pending. */
384 #define MACH_SEND_INTERRUPTED 0x10000007
385 /* Software interrupt. */
386 #define MACH_SEND_MSG_TOO_SMALL 0x10000008
387 /* Data doesn't contain a complete message. */
388 #define MACH_SEND_INVALID_REPLY 0x10000009
389 /* Bogus reply port. */
390 #define MACH_SEND_INVALID_RIGHT 0x1000000a
391 /* Bogus port rights in the message body. */
392 #define MACH_SEND_INVALID_NOTIFY 0x1000000b
393 /* Bogus notify port argument. */
394 #define MACH_SEND_INVALID_MEMORY 0x1000000c
395 /* Invalid out-of-line memory pointer. */
396 #define MACH_SEND_NO_BUFFER 0x1000000d
397 /* No message buffer is available. */
398 #define MACH_SEND_NO_NOTIFY 0x1000000e
399 /* Resource shortage; can't request msg-accepted notif. */
400 #define MACH_SEND_INVALID_TYPE 0x1000000f
401 /* Invalid msg-type specification. */
402 #define MACH_SEND_INVALID_HEADER 0x10000010
403 /* A field in the header had a bad value. */
404
405 #define MACH_RCV_IN_PROGRESS 0x10004001
406 /* Thread is waiting for receive. (Internal use only.) */
407 #define MACH_RCV_INVALID_NAME 0x10004002
408 /* Bogus name for receive port/port-set. */
409 #define MACH_RCV_TIMED_OUT 0x10004003
410 /* Didn't get a message within the timeout value. */
411 #define MACH_RCV_TOO_LARGE 0x10004004
412 /* Message buffer is not large enough for inline data. */
413 #define MACH_RCV_INTERRUPTED 0x10004005
414 /* Software interrupt. */
415 #define MACH_RCV_PORT_CHANGED 0x10004006
416 /* Port moved into a set during the receive. */
417 #define MACH_RCV_INVALID_NOTIFY 0x10004007
418 /* Bogus notify port argument. */
419 #define MACH_RCV_INVALID_DATA 0x10004008
420 /* Bogus message buffer for inline data. */
421 #define MACH_RCV_PORT_DIED 0x10004009
422 /* Port/set was sent away/died during receive. */
423 #define MACH_RCV_IN_SET 0x1000400a
424 /* Port is a member of a port set. */
425 #define MACH_RCV_HEADER_ERROR 0x1000400b
426 /* Error receiving message header. See special bits. */
427 #define MACH_RCV_BODY_ERROR 0x1000400c
428 /* Error receiving message body. See special bits. */
429
430
431 extern mach_msg_return_t
432 mach_msg_trap
433 #if defined(c_plusplus) || defined(__STDC__)
434 (mach_msg_header_t *msg,
435 mach_msg_option_t option,
436 mach_msg_size_t send_size,
437 mach_msg_size_t rcv_size,
438 mach_port_t rcv_name,
439 mach_msg_timeout_t timeout,
440 mach_port_t notify);
441 #else /* c_plusplus || __STDC__ */
442 #ifdef LINTLIBRARY
443 (msg, option, send_size, rcv_size, rcv_name, timeout, notify)
444 mach_msg_header_t *msg;
445 mach_msg_option_t option;
446 mach_msg_size_t send_size;
447 mach_msg_size_t rcv_size
448 mach_port_t rcv_name;
449 mach_msg_timeout_t timeout;
450 mach_port_t notify;
451 { return MACH_RCV_SUCCESS; }
452 #else /* LINTLIBRARY */
453 ();
454 #endif /* LINTLIBRARY */
455 #endif /* c_plusplus || __STDC__ */
456
457 extern mach_msg_return_t
458 mach_msg
459 #if defined(c_plusplus) || defined(__STDC__)
460 (mach_msg_header_t *msg,
461 mach_msg_option_t option,
462 mach_msg_size_t send_size,
463 mach_msg_size_t rcv_size,
464 mach_port_t rcv_name,
465 mach_msg_timeout_t timeout,
466 mach_port_t notify);
467 #else /* c_plusplus || __STDC__ */
468 #ifdef LINTLIBRARY
469 (msg, option, send_size, rcv_size, rcv_name, timeout, notify)
470 mach_msg_header_t *msg;
471 mach_msg_option_t option;
472 mach_msg_size_t send_size;
473 mach_msg_size_t rcv_size
474 mach_port_t rcv_name;
475 mach_msg_timeout_t timeout;
476 mach_port_t notify;
477 { return MACH_RCV_SUCCESS; }
478 #else /* LINTLIBRARY */
479 ();
480 #endif /* LINTLIBRARY */
481 #endif /* c_plusplus || __STDC__ */
482
483
484 /* Definitions for the old IPC interface. */
485
486 #if MACH_IPC_COMPAT
487
488 /*
489 * Message data structures.
490 *
491 * Messages consist of two parts: a fixed-size header, immediately
492 * followed by a variable-size array of typed data items.
493 *
494 */
495
496 typedef unsigned int msg_size_t;
497
498 typedef struct {
499 unsigned int msg_unused : 24,
500 msg_simple : 8;
501 msg_size_t msg_size;
502 integer_t msg_type;
503 port_t msg_local_port;
504 port_t msg_remote_port;
505 integer_t msg_id;
506 } msg_header_t;
507
508 #define MSG_SIZE_MAX 8192
509
510 /*
511 * Known values for the msg_type field.
512 * These are Accent holdovers, which should be purged when possible.
513 *
514 * Only one bit in the msg_type field is used by the kernel.
515 * Others are available to user applications. See <msg_type.h>
516 * for system application-assigned values.
517 */
518
519 #define MSG_TYPE_NORMAL 0
520 #define MSG_TYPE_EMERGENCY 1
521
522 /*
523 * Each data item is preceded by a description of that
524 * item, including what type of data, how big it is, and
525 * how many of them are present.
526 *
527 * The actual data will either follow this type
528 * descriptor ("inline") or will be specified by a pointer.
529 *
530 * If the type name, size, or number is too large to be encoded
531 * in this structure, the "longform" option may be selected,
532 * and those fields must immediately follow in full integer fields.
533 *
534 * For convenience, out-of-line data regions or port rights may
535 * be deallocated when the message is sent by specifying the
536 * "deallocate" field. Beware: if the data item in question is both
537 * out-of-line and contains port rights, then both will be deallocated.
538 */
539
540 typedef struct {
541 unsigned int msg_type_name : 8, /* What kind of data */
542 msg_type_size : 8, /* How many bits is each item */
543 msg_type_number : 12, /* How many items are there */
544 msg_type_inline : 1, /* If true, data follows; else a pointer */
545 msg_type_longform : 1, /* Name, size, number follow: see above */
546 msg_type_deallocate : 1, /* Deallocate port rights or memory */
547 msg_type_unused : 1;
548 } msg_type_t;
549
550 typedef struct {
551 msg_type_t msg_type_header;
552 unsigned short msg_type_long_name;
553 unsigned short msg_type_long_size;
554 natural_t msg_type_long_number;
555 } msg_type_long_t;
556
557 /*
558 * Known values for the msg_type_name field.
559 *
560 * The only types known to the Mach kernel are
561 * the port types, and those types used in the
562 * kernel RPC interface.
563 */
564
565 #define MSG_TYPE_UNSTRUCTURED 0
566 #define MSG_TYPE_BIT 0
567 #define MSG_TYPE_BOOLEAN 0
568 #define MSG_TYPE_INTEGER_16 1
569 #define MSG_TYPE_INTEGER_32 2
570 #define MSG_TYPE_PORT_OWNERSHIP 3 /* obsolete */
571 #define MSG_TYPE_PORT_RECEIVE 4 /* obsolete */
572 #define MSG_TYPE_PORT_ALL 5
573 #define MSG_TYPE_PORT 6
574 #define MSG_TYPE_CHAR 8
575 #define MSG_TYPE_BYTE 9
576 #define MSG_TYPE_INTEGER_8 9
577 #define MSG_TYPE_REAL 10
578 #define MSG_TYPE_STRING 12
579 #define MSG_TYPE_STRING_C 12
580 /* MSG_TYPE_INVALID 13 unused */
581
582 #define MSG_TYPE_INTERNAL_MEMORY MSG_TYPE_INTEGER_8
583
584 #define MSG_TYPE_PORT_NAME 15 /* A capability name */
585 #define MSG_TYPE_LAST 16 /* Last assigned */
586
587 #define MSG_TYPE_POLYMORPHIC ((unsigned int) -1)
588
589 /*
590 * Is a given item a port type?
591 */
592
593 #define MSG_TYPE_PORT_ANY(x) \
594 (((x) == MSG_TYPE_PORT) || ((x) == MSG_TYPE_PORT_ALL))
595
596 /*
597 * Other basic types
598 */
599
600 typedef natural_t msg_timeout_t;
601
602 /*
603 * Options to IPC primitives.
604 *
605 * These can be combined by or'ing; the combination RPC call
606 * uses both SEND_ and RCV_ options at once.
607 */
608
609 typedef integer_t msg_option_t;
610
611 #define MSG_OPTION_NONE 0x0000 /* Terminate only when message op works */
612
613 #define SEND_TIMEOUT 0x0001 /* Terminate on timeout elapsed */
614 #define SEND_NOTIFY 0x0002 /* Terminate with reply message if need be */
615
616 #define SEND_INTERRUPT 0x0004 /* Terminate on software interrupt */
617
618 #define RCV_TIMEOUT 0x0100 /* Terminate on timeout elapsed */
619 #define RCV_NO_SENDERS 0x0200 /* Terminate if I'm the only sender left */
620 #define RCV_INTERRUPT 0x0400 /* Terminate on software interrupt */
621
622 /*
623 * Returns from IPC primitives.
624 *
625 * Values are separate in order to allow RPC users to
626 * distinguish which operation failed; for successful completion,
627 * this doesn't matter.
628 */
629
630 typedef int msg_return_t;
631
632 #define SEND_SUCCESS 0
633
634 #define SEND_ERRORS_START -100
635 #define SEND_INVALID_MEMORY -101 /* Message or OOL data invalid */
636 #define SEND_INVALID_PORT -102 /* Reference to inacessible port */
637 #define SEND_TIMED_OUT -103 /* Terminated due to timeout */
638 #define SEND_WILL_NOTIFY -105 /* Msg accepted provisionally */
639 #define SEND_NOTIFY_IN_PROGRESS -106 /* Already awaiting a notification */
640 #define SEND_KERNEL_REFUSED -107 /* Message to the kernel refused */
641 #define SEND_INTERRUPTED -108 /* Software interrupt during send */
642 #define SEND_MSG_TOO_LARGE -109 /* Message specified was too large */
643 #define SEND_MSG_TOO_SMALL -110 /* Data specified exceeds msg size */
644 /* SEND_MSG_SIZE_CHANGE -111 Msg size changed during copy */
645 #define SEND_ERRORS_END -111
646
647 #define msg_return_send(x) ((x) < SEND_ERRORS_START && (x) > SEND_ERRORS_END)
648
649 #define RCV_SUCCESS 0
650
651 #define RCV_ERRORS_START -200
652 #define RCV_INVALID_MEMORY -201
653 #define RCV_INVALID_PORT -202
654 #define RCV_TIMED_OUT -203
655 #define RCV_TOO_LARGE -204 /* Msg structure too small for data */
656 #define RCV_NOT_ENOUGH_MEMORY -205 /* Can't find space for OOL data */
657 #define RCV_ONLY_SENDER -206 /* Receiver is only sender */
658 #define RCV_INTERRUPTED -207
659 #define RCV_PORT_CHANGE -208 /* Port was put in a set */
660 #define RCV_ERRORS_END -209
661
662 #define msg_return_rcv(x) ((x) < RCV_ERRORS_START && (x) > RCV_ERRORS_END)
663
664 #define RPC_SUCCESS 0
665
666 /*
667 * The IPC primitive functions themselves
668 */
669
670 msg_return_t msg_send(
671 #if defined(c_plusplus) || defined(__STDC__)
672 msg_header_t *header,
673 msg_option_t option,
674 msg_timeout_t timeout);
675 #else /* c_plusplus || __STDC__ */
676 #if LINTLIBRARY
677 header, option, timeout)
678 msg_header_t *header;
679 msg_option_t option;
680 msg_timeout_t timeout;
681 { return(SEND_SUCCESS); }
682 #else /* LINTLIBRARY */
683 );
684 #endif /* LINTLIBRARY */
685 #endif /* c_plusplus || __STDC__ */
686
687 msg_return_t msg_receive(
688 #if defined(c_plusplus) || defined(__STDC__)
689 msg_header_t *header,
690 msg_option_t option,
691 msg_timeout_t timeout);
692 #else /* c_plusplus || __STDC__ */
693 #if LINTLIBRARY
694 header, option, timeout)
695 msg_header_t *header;
696 msg_option_t option;
697 msg_timeout_t timeout;
698 { return(RCV_SUCCESS); }
699 #else /* LINTLIBRARY */
700 );
701 #endif /* LINTLIBRARY */
702 #endif /* c_plusplus || __STDC__ */
703
704 msg_return_t msg_rpc(
705 #if defined(c_plusplus) || defined(__STDC__)
706 msg_header_t *header, /* in/out */
707 msg_option_t option,
708 msg_size_t rcv_size,
709 msg_timeout_t send_timeout,
710 msg_timeout_t rcv_timeout);
711 #else /* c_plusplus || __STDC__ */
712 #if LINTLIBRARY
713 header, option, rcv_size,
714 send_timeout, rcv_timeout)
715 msg_header_t *header; /* in/out */
716 msg_option_t option;
717 msg_size_t rcv_size;
718 msg_timeout_t send_timeout;
719 msg_timeout_t rcv_timeout;
720 { return(RPC_SUCCESS); }
721 #else /* LINTLIBRARY */
722 );
723 #endif /* LINTLIBRARY */
724 #endif /* c_plusplus || __STDC__ */
725
726 msg_return_t msg_send_trap(
727 #if defined(c_plusplus) || defined(__STDC__)
728 msg_header_t *header,
729 msg_option_t option,
730 msg_size_t send_size,
731 msg_timeout_t timeout);
732 #else /* c_plusplus || __STDC__ */
733 #if LINTLIBRARY
734 header, option, send_size, timeout)
735 msg_header_t *header;
736 msg_option_t option;
737 msg_size_t send_size;
738 msg_timeout_t timeout;
739 { return(SEND_SUCCESS); }
740 #else /* LINTLIBRARY */
741 );
742 #endif /* LINTLIBRARY */
743 #endif /* c_plusplus || __STDC__ */
744
745 msg_return_t msg_receive_trap(
746 #if defined(c_plusplus) || defined(__STDC__)
747 msg_header_t *header,
748 msg_option_t option,
749 msg_size_t rcv_size,
750 port_name_t rcv_name,
751 msg_timeout_t timeout);
752 #else /* c_plusplus || __STDC__ */
753 #if LINTLIBRARY
754 header, option, rcv_size, rcv_name, timeout)
755 msg_header_t *header;
756 msg_option_t option;
757 msg_size_t rcv_size;
758 port_name_t rcv_name;
759 msg_timeout_t timeout;
760 { return(RCV_SUCCESS); }
761 #else /* LINTLIBRARY */
762 );
763 #endif /* LINTLIBRARY */
764 #endif /* c_plusplus || __STDC__ */
765
766 msg_return_t msg_rpc_trap(
767 #if defined(c_plusplus) || defined(__STDC__)
768 msg_header_t *header, /* in/out */
769 msg_option_t option,
770 msg_size_t send_size,
771 msg_size_t rcv_size,
772 msg_timeout_t send_timeout,
773 msg_timeout_t rcv_timeout);
774 #else /* c_plusplus || __STDC__ */
775 #if LINTLIBRARY
776 header, option, send_size, rcv_size,
777 send_timeout, rcv_timeout)
778 msg_header_t *header; /* in/out */
779 msg_option_t option;
780 msg_size_t send_size;
781 msg_size_t rcv_size;
782 msg_timeout_t send_timeout;
783 msg_timeout_t rcv_timeout;
784 { return(RPC_SUCCESS); }
785 #else /* LINTLIBRARY */
786 );
787 #endif /* LINTLIBRARY */
788 #endif /* c_plusplus || __STDC__ */
789
790 #endif /* MACH_IPC_COMPAT */
791
792 #endif /* _MACH_MESSAGE_H_ */
Cache object: 846221b3a14a3e08f892c9cc7b249682
|