Annotation of kernel/mach/message.h, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.