Annotation of OSKit-Mach/ipc/ipc_object.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Mach Operating System
        !             3:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
        !             4:  * All Rights Reserved.
        !             5:  *
        !             6:  * Permission to use, copy, modify and distribute this software and its
        !             7:  * documentation is hereby granted, provided that both the copyright
        !             8:  * notice and this permission notice appear in all copies of the
        !             9:  * software, derivative works or modified versions, and any portions
        !            10:  * thereof, and that both notices appear in supporting documentation.
        !            11:  *
        !            12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            15:  *
        !            16:  * Carnegie Mellon requests users of this software to return to
        !            17:  *
        !            18:  *  Software Distribution Coordinator  or  [email protected]
        !            19:  *  School of Computer Science
        !            20:  *  Carnegie Mellon University
        !            21:  *  Pittsburgh PA 15213-3890
        !            22:  *
        !            23:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            24:  * the rights to redistribute these changes.
        !            25:  */
        !            26: /*
        !            27:  *     File:   ipc/ipc_object.h
        !            28:  *     Author: Rich Draves
        !            29:  *     Date:   1989
        !            30:  *
        !            31:  *     Definitions for IPC objects, for which tasks have capabilities.
        !            32:  */
        !            33: 
        !            34: #ifndef        _IPC_IPC_OBJECT_H_
        !            35: #define _IPC_IPC_OBJECT_H_
        !            36: 
        !            37: #include <mach_ipc_compat.h>
        !            38: 
        !            39: #include <mach/kern_return.h>
        !            40: #include <mach/message.h>
        !            41: #include <kern/lock.h>
        !            42: #include <kern/macro_help.h>
        !            43: #include <kern/zalloc.h>
        !            44: #include "ipc_types.h"
        !            45: 
        !            46: typedef unsigned int ipc_object_refs_t;
        !            47: typedef unsigned int ipc_object_bits_t;
        !            48: typedef unsigned int ipc_object_type_t;
        !            49: 
        !            50: typedef struct ipc_object {
        !            51:        decl_simple_lock_data(,io_lock_data)
        !            52:        ipc_object_refs_t io_references;
        !            53:        ipc_object_bits_t io_bits;
        !            54: } *ipc_object_t;
        !            55: 
        !            56: #define        IO_NULL                 ((ipc_object_t) 0)
        !            57: #define        IO_DEAD                 ((ipc_object_t) -1)
        !            58: 
        !            59: #define        IO_VALID(io)            (((io) != IO_NULL) && ((io) != IO_DEAD))
        !            60: 
        !            61: #define        IO_BITS_KOTYPE          0x0000ffff      /* used by the object */
        !            62: #define IO_BITS_OTYPE          0x7fff0000      /* determines a zone */
        !            63: #define        IO_BITS_ACTIVE          0x80000000U     /* is object alive? */
        !            64: 
        !            65: #define        io_active(io)           ((int)(io)->io_bits < 0)        /* hack */
        !            66: 
        !            67: #define        io_otype(io)            (((io)->io_bits & IO_BITS_OTYPE) >> 16)
        !            68: #define        io_kotype(io)           ((io)->io_bits & IO_BITS_KOTYPE)
        !            69: 
        !            70: #define        io_makebits(active, otype, kotype)      \
        !            71:        (((active) ? IO_BITS_ACTIVE : 0) | ((otype) << 16) | (kotype))
        !            72: 
        !            73: /*
        !            74:  * Object types: ports, port sets, kernel-loaded ports
        !            75:  */
        !            76: #define        IOT_PORT                0
        !            77: #define IOT_PORT_SET           1
        !            78: #define IOT_NUMBER             2               /* number of types used */
        !            79: 
        !            80: extern zone_t ipc_object_zones[IOT_NUMBER];
        !            81: 
        !            82: #define        io_alloc(otype)         \
        !            83:                ((ipc_object_t) zalloc(ipc_object_zones[(otype)]))
        !            84: 
        !            85: #define        io_free(otype, io)      \
        !            86:                zfree(ipc_object_zones[(otype)], (vm_offset_t) (io))
        !            87: 
        !            88: #define        io_lock_init(io)        simple_lock_init(&(io)->io_lock_data)
        !            89: #define        io_lock(io)             simple_lock(&(io)->io_lock_data)
        !            90: #define        io_lock_try(io)         simple_lock_try(&(io)->io_lock_data)
        !            91: #define        io_unlock(io)           simple_unlock(&(io)->io_lock_data)
        !            92: 
        !            93: #define io_check_unlock(io)                                            \
        !            94: MACRO_BEGIN                                                            \
        !            95:        ipc_object_refs_t _refs = (io)->io_references;                  \
        !            96:                                                                        \
        !            97:        io_unlock(io);                                                  \
        !            98:        if (_refs == 0)                                                 \
        !            99:                io_free(io_otype(io), io);                              \
        !           100: MACRO_END
        !           101: 
        !           102: #define        io_reference(io)                                                \
        !           103: MACRO_BEGIN                                                            \
        !           104:        (io)->io_references++;                                          \
        !           105: MACRO_END
        !           106: 
        !           107: #define        io_release(io)                                                  \
        !           108: MACRO_BEGIN                                                            \
        !           109:        (io)->io_references--;                                          \
        !           110: MACRO_END
        !           111: 
        !           112: extern void ipc_object_reference(ipc_object_t);
        !           113: 
        !           114: extern void ipc_object_release(ipc_object_t);
        !           115: 
        !           116: extern kern_return_t ipc_object_translate(ipc_space_t, mach_port_t,
        !           117:                                          mach_port_right_t, ipc_object_t *);
        !           118: 
        !           119: extern kern_return_t ipc_object_alloc_dead(ipc_space_t, mach_port_t *);
        !           120: 
        !           121: extern kern_return_t ipc_object_alloc_dead_name(ipc_space_t, mach_port_t);
        !           122: 
        !           123: extern kern_return_t ipc_object_alloc(ipc_space_t, ipc_object_type_t,
        !           124:                                      mach_port_type_t, mach_port_urefs_t,
        !           125:                                      mach_port_t *, ipc_object_t *);
        !           126: 
        !           127: extern kern_return_t ipc_object_alloc_name(ipc_space_t, ipc_object_type_t,
        !           128:                                           mach_port_type_t, mach_port_urefs_t,
        !           129:                                           mach_port_t, ipc_object_t *);
        !           130: 
        !           131: extern mach_msg_type_name_t ipc_object_copyin_type(mach_msg_type_name_t);
        !           132: 
        !           133: extern kern_return_t ipc_object_copyin(ipc_space_t, mach_port_t,
        !           134:                                       mach_msg_type_name_t, ipc_object_t *);
        !           135: 
        !           136: extern void ipc_object_copyin_from_kernel(ipc_object_t, mach_msg_type_name_t);
        !           137: 
        !           138: extern void ipc_object_destroy(ipc_object_t, mach_msg_type_name_t);
        !           139: 
        !           140: extern kern_return_t ipc_object_copyout(ipc_space_t, ipc_object_t,
        !           141:                                        mach_msg_type_name_t,
        !           142:                                        boolean_t, mach_port_t *);
        !           143: 
        !           144: extern kern_return_t ipc_object_copyout_name(ipc_space_t, ipc_object_t,
        !           145:                                             mach_msg_type_name_t,
        !           146:                                             boolean_t, mach_port_t);
        !           147: 
        !           148: extern void ipc_object_copyout_dest(ipc_space_t, ipc_object_t,
        !           149:                                    mach_msg_type_name_t, mach_port_t *);
        !           150: 
        !           151: extern kern_return_t ipc_object_rename(ipc_space_t, mach_port_t, mach_port_t);
        !           152: 
        !           153: #if    MACH_IPC_COMPAT
        !           154: 
        !           155: extern mach_msg_type_name_t
        !           156: ipc_object_copyout_type_compat(mach_msg_type_name_t);
        !           157: 
        !           158: extern kern_return_t ipc_object_copyin_compat(ipc_space_t, mach_port_t,
        !           159:                                              mach_msg_type_name_t, boolean_t,
        !           160:                                              ipc_object_t *);
        !           161: 
        !           162: extern kern_return_t ipc_object_copyin_header(ipc_space_t, mach_port_t,
        !           163:                                              ipc_object_t *,
        !           164:                                              mach_msg_type_name_t *);
        !           165: 
        !           166: extern kern_return_t ipc_object_copyout_compat(ipc_space_t, ipc_object_t,
        !           167:                                               mach_msg_type_name_t,
        !           168:                                               mach_port_t *);
        !           169: 
        !           170: extern kern_return_t ipc_object_copyout_name_compat(ipc_space_t, ipc_object_t,
        !           171:                                                    mach_msg_type_name_t,
        !           172:                                                    mach_port_t);
        !           173: 
        !           174: #endif /* MACH_IPC_COMPAT */
        !           175: 
        !           176: extern void ipc_object_print(ipc_object_t);
        !           177: 
        !           178: #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.