Annotation of XNU/osfmk/mach/port.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * The contents of this file constitute Original Code as defined in and
                      7:  * are subject to the Apple Public Source License Version 1.1 (the
                      8:  * "License").  You may not use this file except in compliance with the
                      9:  * License.  Please obtain a copy of the License at
                     10:  * http://www.apple.com/publicsource and read it before using this file.
                     11:  * 
                     12:  * This Original Code and all software distributed under the License are
                     13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     17:  * License for the specific language governing rights and limitations
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: /*
                     23:  * @OSF_COPYRIGHT@
                     24:  */
                     25: /* 
                     26:  * Mach Operating System
                     27:  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
                     28:  * All Rights Reserved.
                     29:  * 
                     30:  * Permission to use, copy, modify and distribute this software and its
                     31:  * documentation is hereby granted, provided that both the copyright
                     32:  * notice and this permission notice appear in all copies of the
                     33:  * software, derivative works or modified versions, and any portions
                     34:  * thereof, and that both notices appear in supporting documentation.
                     35:  * 
                     36:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     37:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     38:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     39:  * 
                     40:  * Carnegie Mellon requests users of this software to return to
                     41:  * 
                     42:  *  Software Distribution Coordinator  or  [email protected]
                     43:  *  School of Computer Science
                     44:  *  Carnegie Mellon University
                     45:  *  Pittsburgh PA 15213-3890
                     46:  * 
                     47:  * any improvements or extensions that they make and grant Carnegie Mellon
                     48:  * the rights to redistribute these changes.
                     49:  */
                     50: /*
                     51:  */
                     52: /*
                     53:  *     File:   mach/port.h
                     54:  *
                     55:  *     Definition of a port
                     56:  *
                     57:  *     [The basic port_t type should probably be machine-dependent,
                     58:  *     as it must be represented by a 32-bit integer.]
                     59:  */
                     60: 
                     61: #ifndef        _MACH_PORT_H_
                     62: #define _MACH_PORT_H_
                     63: 
                     64: #if    MACH_KERNEL_PRIVATE
                     65: #include <dipc.h>
                     66: #endif /* MACH_KERNEL_PRIVATE */
                     67: 
                     68: #include <mach/boolean.h>
                     69: #include <mach/machine/vm_types.h>
                     70: 
                     71: /*
                     72:  * A port_name_t is a 32 bit value which represents a name of a
                     73:  * port right within some ipc space.  This is a constant definition
                     74:  * everywhere.
                     75:  *
                     76:  * The type port_t represents a reference added or deleted to a
                     77:  * port right.
                     78:  *
                     79:  *     At user space, this is represented by returning the name of
                     80:  *     the right(s) that got altered within the user's ipc space.
                     81:  *     So a port_t is the same type as a port_name_t there.
                     82:  *
                     83:  *     Since there is no right space for the kernel proper (all rights
                     84:  *     are naked rights) these rights are represented by passing a
                     85:  *     pointer to the specific ipc_object_t subclass (typically
                     86:  *     ipc_port_t) that got altered/is to be altered.
                     87:  */
                     88: typedef natural_t port_name_t;
                     89: typedef port_name_t *port_name_array_t;
                     90: 
                     91: #ifdef KERNEL_PRIVATE
                     92: 
                     93: #include <ipc/ipc_types.h>
                     94: typedef ipc_port_t port_t;
                     95: 
                     96: #else  /* ! KERNEL_PRIVATE */
                     97: 
                     98: typedef port_name_t port_t;
                     99: 
                    100: #endif /* KERNEL_PRIVATE */
                    101: 
                    102: /*
                    103:  *  PORT_NULL is a legal value that can be carried in messages.
                    104:  *  It indicates the absence of any port or port rights.  (A port
                    105:  *  argument keeps the message from being "simple", even if the
                    106:  *  value is PORT_NULL.)  The value PORT_DEAD is also a legal
                    107:  *  value that can be carried in messages.  It indicates
                    108:  *  that a port right was present, but it died.
                    109:  */
                    110: #define PORT_NULL              ((port_t) 0)
                    111: #define PORT_DEAD              ((port_t) ~0)
                    112: #define        PORT_VALID(name)                                \
                    113:                (((port_t)(name) != PORT_NULL) &&       \
                    114:                  ((port_t)(name) != PORT_DEAD))
                    115: 
                    116: /*
                    117:  *  Mach 3.0 renamed everything to have mach_ in front of it.
                    118:  *  Do that mapping here, so we have the types and macros in
                    119:  *  both formats.
                    120:  */
                    121: typedef port_t                 mach_port_t;
                    122: typedef port_t                 *mach_port_array_t;
                    123: typedef port_name_t            mach_port_name_t;
                    124: typedef mach_port_name_t       *mach_port_name_array_t;
                    125: 
                    126: #define MACH_PORT_NULL         0  /* intentional loose typing */
                    127: #define MACH_PORT_DEAD         ((mach_port_name_t) ~0)
                    128: #define MACH_PORT_VALID(name)                          \
                    129:                (((name) != MACH_PORT_NULL) &&          \
                    130:                 ((name) != MACH_PORT_DEAD))
                    131: 
                    132: /*
                    133:  *  mach_port_name_t must be an unsigned type.  Port values
                    134:  *  have two parts, a generation number and an index.
                    135:  *  These macros encapsulate all knowledge of how
                    136:  *  a mach_port_name_t is laid out.  They are made visible 
                    137:  *  to user tasks so that packages to map from a mach_port_name_t
                    138:  *  to associated user data can discount the generation
                    139:  *  nuber (if desired) in doing the mapping.
                    140:  *
                    141:  *  Within the kernel, ipc/ipc_entry.c implicitly assumes
                    142:  *  when it uses the splay tree functions that the generation
                    143:  *  number is in the low bits, so that names are ordered first
                    144:  *  by index and then by generation.  If the size of generation
                    145:  *  numbers changes, be sure to update IE_BITS_GEN_MASK and
                    146:  *  friends in ipc/ipc_entry.h.
                    147:  */
                    148: #ifndef NO_PORT_GEN
                    149: #define        MACH_PORT_INDEX(name)           ((name) >> 8)
                    150: #define        MACH_PORT_GEN(name)             (((name) & 0xff) << 24)
                    151: #define        MACH_PORT_MAKE(index, gen)      \
                    152:                (((index) << 8) | (gen) >> 24)
                    153: #else
                    154: #define        MACH_PORT_INDEX(name)           (name)
                    155: #define        MACH_PORT_GEN(name)             (0)
                    156: #define        MACH_PORT_MAKE(index, gen)      (index)
                    157: #endif /* !NO_PORT_GEN */
                    158: 
                    159: /*
                    160:  *  These are the different rights a task may have.
                    161:  *  The MACH_PORT_RIGHT_* definitions are used as arguments
                    162:  *  to mach_port_allocate, mach_port_get_refs, etc, to specify
                    163:  *  a particular right to act upon.  The mach_port_names and
                    164:  *  mach_port_type calls return bitmasks using the MACH_PORT_TYPE_*
                    165:  *  definitions.  This is because a single name may denote
                    166:  *  multiple rights.
                    167:  */
                    168: 
                    169: typedef natural_t mach_port_right_t;
                    170: 
                    171: #define MACH_PORT_RIGHT_SEND           ((mach_port_right_t) 0)
                    172: #define MACH_PORT_RIGHT_RECEIVE                ((mach_port_right_t) 1)
                    173: #define MACH_PORT_RIGHT_SEND_ONCE      ((mach_port_right_t) 2)
                    174: #define MACH_PORT_RIGHT_PORT_SET       ((mach_port_right_t) 3)
                    175: #define MACH_PORT_RIGHT_DEAD_NAME      ((mach_port_right_t) 4)
                    176: #define MACH_PORT_RIGHT_NUMBER         ((mach_port_right_t) 5)
                    177: 
                    178: /*
                    179:  * Turn the temporary_no_nms token ON for all configurations, rather
                    180:  * than only DIPC configurations. This is so we can create all RPC
                    181:  * target ports with nms disabled.
                    182:  */
                    183: #define        TEMPORARY_NO_NMS 1
                    184: #if    TEMPORARY_NO_NMS
                    185: /*
                    186:  *     XXX This definition is TEMPORARY, to permit
                    187:  *     users in-the-know to allocate ports that don't
                    188:  *     use NMS detection.  Later, mach_port_allocate
                    189:  *     will DEFAULT to this case, and an option will
                    190:  *     permit allocating ports that DO support NMS.
                    191:  *     Confused yet?  XXX
                    192:  */
                    193: #define        MACH_PORT_RIGHT_RECEIVE_NO_NMS  ((mach_port_right_t) 6)
                    194: #endif /* TEMPORARY_NO_NMS */
                    195: 
                    196: typedef natural_t mach_port_type_t;
                    197: typedef mach_port_type_t *mach_port_type_array_t;
                    198: 
                    199: #define MACH_PORT_TYPE(right)                                          \
                    200:                ((mach_port_type_t)(((mach_port_type_t) 1)              \
                    201:                << ((right) + ((mach_port_right_t) 16))))       
                    202: #define MACH_PORT_TYPE_NONE        ((mach_port_type_t) 0L)
                    203: #define MACH_PORT_TYPE_SEND        MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND)
                    204: #define MACH_PORT_TYPE_RECEIVE     MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE)
                    205: #define MACH_PORT_TYPE_SEND_ONCE    MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND_ONCE)
                    206: #define MACH_PORT_TYPE_PORT_SET            MACH_PORT_TYPE(MACH_PORT_RIGHT_PORT_SET)
                    207: #define MACH_PORT_TYPE_DEAD_NAME    MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME)
                    208: 
                    209: /* Convenient combinations. */
                    210: 
                    211: #define MACH_PORT_TYPE_SEND_RECEIVE                                    \
                    212:                (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE)
                    213: #define        MACH_PORT_TYPE_SEND_RIGHTS                                      \
                    214:                (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE)
                    215: #define        MACH_PORT_TYPE_PORT_RIGHTS                                      \
                    216:                (MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE)
                    217: #define        MACH_PORT_TYPE_PORT_OR_DEAD                                     \
                    218:                (MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME)
                    219: #define MACH_PORT_TYPE_ALL_RIGHTS                                      \
                    220:                (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET)
                    221: 
                    222: /* Dummy type bits that mach_port_type/mach_port_names can return. */
                    223: 
                    224: #define MACH_PORT_TYPE_DNREQUEST       0x80000000
                    225: 
                    226: /* User-references for capabilities. */
                    227: 
                    228: typedef natural_t mach_port_urefs_t;
                    229: typedef integer_t mach_port_delta_t;                   /* change in urefs */
                    230: 
                    231: /* Attributes of ports.  (See mach_port_get_receive_status.) */
                    232: 
                    233: typedef natural_t mach_port_seqno_t;           /* sequence number */
                    234: typedef natural_t mach_port_mscount_t;         /* make-send count */
                    235: typedef natural_t mach_port_msgcount_t;                /* number of msgs */
                    236: typedef natural_t mach_port_rights_t;          /* number of rights */
                    237: 
                    238: /*
                    239:  *     A port may have NMS detection enabled, in which case
                    240:  *     it tracks outstanding send rights.  Otherwise, there
                    241:  *     is no information available about outstanding srights.
                    242:  *     The return values are deliberately chosen to match
                    243:  *     the old boolean (0=FALSE=no srights, 1=TRUE=srights,
                    244:  *     2=xxx=no information available).
                    245:  */
                    246: #define        MACH_PORT_SRIGHTS_NONE          0               /* NMS:  no srights */
                    247: #define        MACH_PORT_SRIGHTS_PRESENT       1               /* NMS:  srights */
                    248: #define        MACH_PORT_SRIGHTS_NO_INFO       2               /* no NMS */
                    249: typedef unsigned int mach_port_srights_t;      /* status of send rights */
                    250: 
                    251: typedef struct mach_port_status {
                    252:        mach_port_name_t        mps_pset;       /* containing port set */
                    253:        mach_port_seqno_t       mps_seqno;      /* sequence number */
                    254:        mach_port_mscount_t     mps_mscount;    /* make-send count */
                    255:        mach_port_msgcount_t    mps_qlimit;     /* queue limit */
                    256:        mach_port_msgcount_t    mps_msgcount;   /* number in the queue */
                    257:        mach_port_rights_t      mps_sorights;   /* how many send-once rights */
                    258: #if    DIPC
                    259:        mach_port_srights_t     mps_srights;    /* do send rights exist? */
                    260: #else  /* DIPC */
                    261:        boolean_t               mps_srights;    /* do send rights exist? */
                    262: #endif /* DIPC */
                    263:        boolean_t               mps_pdrequest;  /* port-deleted requested? */
                    264:        boolean_t               mps_nsrequest;  /* no-senders requested? */
                    265:        unsigned int            mps_flags;      /* port flags */
                    266: } mach_port_status_t;
                    267: 
                    268: #define MACH_PORT_QLIMIT_DEFAULT       ((mach_port_msgcount_t) 5)
                    269: #define MACH_PORT_QLIMIT_MAX           ((mach_port_msgcount_t) 16)
                    270: 
                    271: typedef struct mach_port_limits {
                    272:        mach_port_msgcount_t    mpl_qlimit;     /* number of msgs */
                    273: } mach_port_limits_t;
                    274: 
                    275: typedef integer_t *mach_port_info_t;           /* varying array of natural_t */
                    276: 
                    277: /* Flavors for mach_port_get/set_attributes() */
                    278: typedef int    mach_port_flavor_t;
                    279: #define MACH_PORT_LIMITS_INFO          1       /* uses mach_port_status_t */
                    280: #define MACH_PORT_RECEIVE_STATUS       2       /* uses mach_port_limits_t */
                    281: #define MACH_PORT_DNREQUESTS_SIZE      3       /* info is int */
                    282: 
                    283: #define MACH_PORT_LIMITS_INFO_COUNT \
                    284:        (sizeof(mach_port_limits_t)/sizeof(natural_t))
                    285: #define MACH_PORT_RECEIVE_STATUS_COUNT \
                    286:        (sizeof(mach_port_status_t)/sizeof(natural_t))
                    287: #define MACH_PORT_DNREQUESTS_SIZE_COUNT 1
                    288: 
                    289: /*
                    290:  * Structure used to pass information about port allocation requests.
                    291:  * Must be padded to 64-bits total length.
                    292:  */
                    293: 
                    294: typedef struct mach_port_qos {
                    295:        boolean_t               name:1;         /* name given */
                    296:        boolean_t               rt:1;           /* real-time port */
                    297:        boolean_t               pad1:30;
                    298:        boolean_t               pad2:32;
                    299: } mach_port_qos_t;
                    300: 
                    301: #endif /* _MACH_PORT_H_ */

unix.superglobalmegacorp.com

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