Annotation of Gnu-Mach/ipc/ipc_object.h, revision 1.1.1.3

1.1.1.2   root        1: /*
1.1       root        2:  * Mach Operating System
                      3:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
                      4:  * All Rights Reserved.
1.1.1.2   root        5:  *
1.1       root        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.
1.1.1.2   root       11:  *
1.1       root       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.
1.1.1.2   root       15:  *
1.1       root       16:  * Carnegie Mellon requests users of this software to return to
1.1.1.2   root       17:  *
1.1       root       18:  *  Software Distribution Coordinator  or  [email protected]
                     19:  *  School of Computer Science
                     20:  *  Carnegie Mellon University
                     21:  *  Pittsburgh PA 15213-3890
1.1.1.2   root       22:  *
1.1       root       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/kern_return.h>
                     38: #include <mach/message.h>
1.1.1.3 ! root       39: #include <ipc/ipc_types.h>
1.1       root       40: #include <kern/lock.h>
                     41: #include <kern/macro_help.h>
1.1.1.3 ! root       42: #include <kern/slab.h>
1.1       root       43: 
                     44: typedef unsigned int ipc_object_refs_t;
                     45: typedef unsigned int ipc_object_bits_t;
                     46: typedef unsigned int ipc_object_type_t;
                     47: 
                     48: typedef struct ipc_object {
                     49:        decl_simple_lock_data(,io_lock_data)
                     50:        ipc_object_refs_t io_references;
                     51:        ipc_object_bits_t io_bits;
                     52: } *ipc_object_t;
                     53: 
                     54: #define        IO_NULL                 ((ipc_object_t) 0)
                     55: #define        IO_DEAD                 ((ipc_object_t) -1)
                     56: 
                     57: #define        IO_VALID(io)            (((io) != IO_NULL) && ((io) != IO_DEAD))
                     58: 
                     59: #define        IO_BITS_KOTYPE          0x0000ffff      /* used by the object */
1.1.1.3 ! root       60: #define IO_BITS_OTYPE          0x7fff0000      /* determines a cache */
1.1       root       61: #define        IO_BITS_ACTIVE          0x80000000U     /* is object alive? */
                     62: 
                     63: #define        io_active(io)           ((int)(io)->io_bits < 0)        /* hack */
                     64: 
                     65: #define        io_otype(io)            (((io)->io_bits & IO_BITS_OTYPE) >> 16)
                     66: #define        io_kotype(io)           ((io)->io_bits & IO_BITS_KOTYPE)
                     67: 
                     68: #define        io_makebits(active, otype, kotype)      \
                     69:        (((active) ? IO_BITS_ACTIVE : 0) | ((otype) << 16) | (kotype))
                     70: 
                     71: /*
                     72:  * Object types: ports, port sets, kernel-loaded ports
                     73:  */
                     74: #define        IOT_PORT                0
                     75: #define IOT_PORT_SET           1
                     76: #define IOT_NUMBER             2               /* number of types used */
                     77: 
1.1.1.3 ! root       78: extern struct kmem_cache ipc_object_caches[IOT_NUMBER];
1.1       root       79: 
                     80: #define        io_alloc(otype)         \
1.1.1.3 ! root       81:                ((ipc_object_t) kmem_cache_alloc(&ipc_object_caches[(otype)]))
1.1       root       82: 
                     83: #define        io_free(otype, io)      \
1.1.1.3 ! root       84:                kmem_cache_free(&ipc_object_caches[(otype)], (vm_offset_t) (io))
1.1       root       85: 
                     86: #define        io_lock_init(io)        simple_lock_init(&(io)->io_lock_data)
                     87: #define        io_lock(io)             simple_lock(&(io)->io_lock_data)
                     88: #define        io_lock_try(io)         simple_lock_try(&(io)->io_lock_data)
                     89: #define        io_unlock(io)           simple_unlock(&(io)->io_lock_data)
                     90: 
                     91: #define io_check_unlock(io)                                            \
                     92: MACRO_BEGIN                                                            \
                     93:        ipc_object_refs_t _refs = (io)->io_references;                  \
                     94:                                                                        \
                     95:        io_unlock(io);                                                  \
                     96:        if (_refs == 0)                                                 \
                     97:                io_free(io_otype(io), io);                              \
                     98: MACRO_END
                     99: 
                    100: #define        io_reference(io)                                                \
                    101: MACRO_BEGIN                                                            \
                    102:        (io)->io_references++;                                          \
                    103: MACRO_END
                    104: 
                    105: #define        io_release(io)                                                  \
                    106: MACRO_BEGIN                                                            \
                    107:        (io)->io_references--;                                          \
                    108: MACRO_END
                    109: 
                    110: extern void
1.1.1.3 ! root      111: ipc_object_reference(ipc_object_t);
1.1       root      112: 
                    113: extern void
1.1.1.3 ! root      114: ipc_object_release(ipc_object_t);
1.1       root      115: 
                    116: extern kern_return_t
1.1.1.3 ! root      117: ipc_object_translate(ipc_space_t, mach_port_t,
        !           118:                     mach_port_right_t, ipc_object_t *);
1.1       root      119: 
                    120: extern kern_return_t
1.1.1.3 ! root      121: ipc_object_alloc_dead(ipc_space_t, mach_port_t *);
1.1       root      122: 
                    123: extern kern_return_t
1.1.1.3 ! root      124: ipc_object_alloc_dead_name(ipc_space_t, mach_port_t);
1.1       root      125: 
                    126: extern kern_return_t
1.1.1.3 ! root      127: ipc_object_alloc(ipc_space_t, ipc_object_type_t,
        !           128:                 mach_port_type_t, mach_port_urefs_t,
        !           129:                 mach_port_t *, ipc_object_t *);
1.1       root      130: 
                    131: extern kern_return_t
1.1.1.3 ! root      132: ipc_object_alloc_name(ipc_space_t, ipc_object_type_t,
        !           133:                      mach_port_type_t, mach_port_urefs_t,
        !           134:                      mach_port_t, ipc_object_t *);
1.1       root      135: 
                    136: extern mach_msg_type_name_t
1.1.1.3 ! root      137: ipc_object_copyin_type(mach_msg_type_name_t);
1.1       root      138: 
                    139: extern kern_return_t
1.1.1.3 ! root      140: ipc_object_copyin(ipc_space_t, mach_port_t,
        !           141:                  mach_msg_type_name_t, ipc_object_t *);
1.1       root      142: 
                    143: extern void
1.1.1.3 ! root      144: ipc_object_copyin_from_kernel(ipc_object_t, mach_msg_type_name_t);
1.1       root      145: 
                    146: extern void
1.1.1.3 ! root      147: ipc_object_destroy(ipc_object_t, mach_msg_type_name_t);
1.1       root      148: 
                    149: extern kern_return_t
1.1.1.3 ! root      150: ipc_object_copyout(ipc_space_t, ipc_object_t,
        !           151:                   mach_msg_type_name_t, boolean_t, mach_port_t *);
1.1       root      152: 
                    153: extern kern_return_t
1.1.1.3 ! root      154: ipc_object_copyout_name(ipc_space_t, ipc_object_t,
        !           155:                        mach_msg_type_name_t, boolean_t, mach_port_t);
1.1       root      156: 
                    157: extern void
1.1.1.3 ! root      158: ipc_object_copyout_dest(ipc_space_t, ipc_object_t,
        !           159:                        mach_msg_type_name_t, mach_port_t *);
1.1       root      160: 
                    161: extern kern_return_t
1.1.1.3 ! root      162: ipc_object_rename(ipc_space_t, mach_port_t, mach_port_t);
1.1       root      163: 
                    164: extern void
1.1.1.3 ! root      165: ipc_object_print(ipc_object_t);
1.1       root      166: 
1.1.1.2   root      167: #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.