Annotation of kernel/ipc/ipc_object.h, revision 1.1.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) 1991,1990,1989 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:   ipc/ipc_object.h
                     75:  *     Author: Rich Draves
                     76:  *     Date:   1989
                     77:  *
                     78:  *     Definitions for IPC objects, for which tasks have capabilities.
                     79:  */
                     80: 
                     81: #ifndef        _IPC_IPC_OBJECT_H_
                     82: #define _IPC_IPC_OBJECT_H_
                     83: 
                     84: #import <mach/features.h>
                     85: 
                     86: #include <mach/kern_return.h>
                     87: #include <mach/message.h>
                     88: #include <kern/lock.h>
                     89: #include <kern/macro_help.h>
                     90: #include <kern/zalloc.h>
                     91: #include <ipc/ipc_types.h>
                     92: 
                     93: typedef unsigned int ipc_object_refs_t;
                     94: typedef unsigned int ipc_object_bits_t;
                     95: typedef unsigned int ipc_object_type_t;
                     96: 
                     97: typedef struct ipc_object {
                     98:        decl_simple_lock_data(,io_lock_data)
                     99:        ipc_object_refs_t io_references;
                    100:        ipc_object_bits_t io_bits;
                    101: } *ipc_object_t;
                    102: 
                    103: #define        IO_NULL                 ((ipc_object_t) 0)
                    104: #define        IO_DEAD                 ((ipc_object_t) -1)
                    105: 
                    106: #define        IO_VALID(io)            (((io) != IO_NULL) && ((io) != IO_DEAD))
                    107: 
                    108: #define        IO_BITS_KOTYPE          0x0000ffff      /* used by the object */
                    109: #define IO_BITS_OTYPE          0x7fff0000      /* determines a zone */
                    110: #define        IO_BITS_ACTIVE          0x80000000U     /* is object alive? */
                    111: 
                    112: #define        io_active(io)           ((int)(io)->io_bits < 0)        /* hack */
                    113: 
                    114: #define        io_otype(io)            (((io)->io_bits & IO_BITS_OTYPE) >> 16)
                    115: #define        io_kotype(io)           ((io)->io_bits & IO_BITS_KOTYPE)
                    116: 
                    117: #define        io_makebits(active, otype, kotype)      \
                    118:        (((active) ? IO_BITS_ACTIVE : 0) | ((otype) << 16) | (kotype))
                    119: 
                    120: /*
                    121:  * Object types: ports, port sets, kernel-loaded ports
                    122:  */
                    123: #define        IOT_PORT                0
                    124: #define IOT_PORT_SET           1
                    125: #define IOT_NUMBER             2               /* number of types used */
                    126: 
                    127: extern zone_t ipc_object_zones[IOT_NUMBER];
                    128: 
                    129: #define        io_alloc(otype)         \
                    130:                ((ipc_object_t) zalloc(ipc_object_zones[(otype)]))
                    131: 
                    132: #define        io_free(otype, io)      \
                    133:                zfree(ipc_object_zones[(otype)], (vm_offset_t) (io))
                    134: 
                    135: #define        io_lock_init(io)        simple_lock_init(&(io)->io_lock_data)
                    136: #define        io_lock(io)             simple_lock(&(io)->io_lock_data)
                    137: #define        io_lock_try(io)         simple_lock_try(&(io)->io_lock_data)
                    138: #define        io_unlock(io)           simple_unlock(&(io)->io_lock_data)
                    139: 
                    140: #define io_check_unlock(io)                                            \
                    141: MACRO_BEGIN                                                            \
                    142:        volatile ipc_object_refs_t _refs = (io)->io_references;         \
                    143:                                                                        \
                    144:        io_unlock(io);                                                  \
                    145:        if (_refs == 0)                                                 \
                    146:                io_free(io_otype(io), io);                              \
                    147: MACRO_END
                    148: 
                    149: #define        io_reference(io)                                                \
                    150: MACRO_BEGIN                                                            \
                    151:        (io)->io_references++;                                          \
                    152: MACRO_END
                    153: 
                    154: #define        io_release(io)                                                  \
                    155: MACRO_BEGIN                                                            \
                    156:        (io)->io_references--;                                          \
                    157: MACRO_END
                    158: 
                    159: /*
                    160:  * Exported interfaces
                    161:  */
                    162: 
                    163: /* Take a reference to an object */
                    164: extern void ipc_object_reference(
                    165:        ipc_object_t    object);
                    166: 
                    167: /* Release a reference to an object */
                    168: extern void ipc_object_release(
                    169:        ipc_object_t    object);
                    170: 
                    171: /* Look up an object in a space */
                    172: extern kern_return_t ipc_object_translate(
                    173:        ipc_space_t             space,
                    174:        mach_port_t             name,
                    175:        mach_port_right_t       right,
                    176:        ipc_object_t            *objectp);
                    177: 
                    178: /* Allocate a dead-name entry */
                    179: extern kern_return_t
                    180: ipc_object_alloc_dead(
                    181:        ipc_space_t     space,
                    182:        mach_port_t     *namep);
                    183: 
                    184: /*  Allocate a dead-name entry, with a specific name */
                    185: extern kern_return_t ipc_object_alloc_dead_name(
                    186:        ipc_space_t     space,
                    187:        mach_port_t     name);
                    188: 
                    189: /* Allocate an object */
                    190: extern kern_return_t ipc_object_alloc(
                    191:        ipc_space_t             space,
                    192:        ipc_object_type_t       otype,
                    193:        mach_port_type_t        type,
                    194:        mach_port_urefs_t       urefs,
                    195:        mach_port_t             *namep,
                    196:        ipc_object_t            *objectp);
                    197: 
                    198: /* Allocate an object, with a specific name */
                    199: extern kern_return_t ipc_object_alloc_name(
                    200:        ipc_space_t             space,
                    201:        ipc_object_type_t       otype,
                    202:        mach_port_type_t        type,
                    203:        mach_port_urefs_t       urefs,
                    204:        mach_port_t             name,
                    205:        ipc_object_t            *objectp);
                    206: 
                    207: /* Convert a send type name to a received type name */
                    208: extern mach_msg_type_name_t ipc_object_copyin_type(
                    209:        mach_msg_type_name_t    msgt_name);
                    210: 
                    211: /* Copyin a capability from a space */
                    212: extern kern_return_t ipc_object_copyin(
                    213:        ipc_space_t             space,
                    214:        mach_port_t             name,
                    215:        mach_msg_type_name_t    msgt_name,
                    216:        ipc_object_t            *objectp);
                    217: 
                    218: /* Copyin a naked capability from the kernel */
                    219: extern void ipc_object_copyin_from_kernel(
                    220:        ipc_object_t            object,
                    221:        mach_msg_type_name_t    msgt_name);
                    222: 
                    223: /* Destroy a naked capability */
                    224: extern void ipc_object_destroy(
                    225:        ipc_object_t            object,
                    226:        mach_msg_type_name_t    msgt_name);
                    227: 
                    228: /* Copyout a capability, placing it into a space */
                    229: extern kern_return_t ipc_object_copyout(
                    230:        ipc_space_t             space,
                    231:        ipc_object_t            object,
                    232:        mach_msg_type_name_t    msgt_name,
                    233:        boolean_t               overflow,
                    234:        mach_port_t             *namep);
                    235: 
                    236: /* Copyout a capability with a name, placing it into a space */
                    237: extern kern_return_t ipc_object_copyout_name(
                    238:        ipc_space_t             space,
                    239:        ipc_object_t            object,
                    240:        mach_msg_type_name_t    msgt_name,
                    241:        boolean_t               overflow,
                    242:        mach_port_t             name);
                    243: 
                    244: /* Translate/consume the destination right of a message */
                    245: extern void ipc_object_copyout_dest(
                    246:        ipc_space_t             space,
                    247:        ipc_object_t            object,
                    248:        mach_msg_type_name_t    msgt_name,
                    249:        mach_port_t             *namep);
                    250: 
                    251: /* Rename an entry in a space */
                    252: extern kern_return_t ipc_object_rename(
                    253:        ipc_space_t     space,
                    254:        mach_port_t     oname,
                    255:        mach_port_t     nname);
                    256: 
                    257: #if    MACH_IPC_COMPAT
                    258: 
                    259: extern mach_msg_type_name_t
                    260: ipc_object_copyout_type_compat(/* mach_msg_type_name_t */);
                    261: 
                    262: extern kern_return_t
                    263: ipc_object_copyin_compat(/* ipc_space_t, mach_port_t,
                    264:                            mach_msg_type_name_t, boolean_t,
                    265:                            ipc_object_t * */);
                    266: 
                    267: extern kern_return_t
                    268: ipc_object_copyin_header(/* ipc_space_t, mach_port_t,
                    269:                            ipc_object_t *, mach_msg_type_name_t * */);
                    270: 
                    271: extern kern_return_t
                    272: ipc_object_copyout_compat(/* ipc_space_t, ipc_object_t,
                    273:                             mach_msg_type_name_t, mach_port_t * */);
                    274: 
                    275: extern kern_return_t
                    276: ipc_object_copyout_name_compat(/* ipc_space_t, ipc_object_t,
                    277:                                  mach_msg_type_name_t, mach_port_t */);
                    278: 
                    279: #endif /* MACH_IPC_COMPAT */
                    280: 
                    281: #endif /* _IPC_IPC_OBJECT_H_ */

unix.superglobalmegacorp.com

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