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