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

1.1     ! root        1: /*
        !             2:  * Mach Operating System
        !             3:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University.
        !             4:  * Copyright (c) 1993,1994 The University of Utah and
        !             5:  * the Computer Systems Laboratory (CSL).
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * Permission to use, copy, modify and distribute this software and its
        !             9:  * documentation is hereby granted, provided that both the copyright
        !            10:  * notice and this permission notice appear in all copies of the
        !            11:  * software, derivative works or modified versions, and any portions
        !            12:  * thereof, and that both notices appear in supporting documentation.
        !            13:  *
        !            14:  * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF
        !            15:  * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM ANY LIABILITY
        !            16:  * OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF
        !            17:  * THIS SOFTWARE.
        !            18:  *
        !            19:  * Carnegie Mellon requests users of this software to return to
        !            20:  *
        !            21:  *  Software Distribution Coordinator  or  [email protected]
        !            22:  *  School of Computer Science
        !            23:  *  Carnegie Mellon University
        !            24:  *  Pittsburgh PA 15213-3890
        !            25:  *
        !            26:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            27:  * the rights to redistribute these changes.
        !            28:  */
        !            29: /*
        !            30:  */
        !            31: /*
        !            32:  *     File:   ipc/ipc_space.h
        !            33:  *     Author: Rich Draves
        !            34:  *     Date:   1989
        !            35:  *
        !            36:  *     Definitions for IPC spaces of capabilities.
        !            37:  */
        !            38: 
        !            39: #ifndef        _IPC_IPC_SPACE_H_
        !            40: #define _IPC_IPC_SPACE_H_
        !            41: 
        !            42: #include <mach_ipc_compat.h>
        !            43: #include <norma_ipc.h>
        !            44: 
        !            45: #include <mach/boolean.h>
        !            46: #include <mach/kern_return.h>
        !            47: #include <kern/macro_help.h>
        !            48: #include <kern/lock.h>
        !            49: #include <ipc/ipc_splay.h>
        !            50: 
        !            51: /*
        !            52:  *     Every task has a space of IPC capabilities.
        !            53:  *     IPC operations like send and receive use this space.
        !            54:  *     IPC kernel calls manipulate the space of the target task.
        !            55:  *
        !            56:  *     Every space has a non-NULL is_table with is_table_size entries.
        !            57:  *     A space may have a NULL is_tree.  is_tree_small records the
        !            58:  *     number of entries in the tree that, if the table were to grow
        !            59:  *     to the next larger size, would move from the tree to the table.
        !            60:  *
        !            61:  *     is_growing marks when the table is in the process of growing.
        !            62:  *     When the table is growing, it can't be freed or grown by another
        !            63:  *     thread, because of krealloc/kmem_realloc's requirements.
        !            64:  */
        !            65: 
        !            66: typedef unsigned int ipc_space_refs_t;
        !            67: 
        !            68: struct ipc_space {
        !            69:        decl_simple_lock_data(,is_ref_lock_data)
        !            70:        ipc_space_refs_t is_references;
        !            71: 
        !            72:        decl_simple_lock_data(,is_lock_data)
        !            73:        boolean_t is_active;            /* is the space alive? */
        !            74:        boolean_t is_growing;           /* is the space growing? */
        !            75:        ipc_entry_t is_table;           /* an array of entries */
        !            76:        ipc_entry_num_t is_table_size;  /* current size of table */
        !            77:        struct ipc_table_size *is_table_next; /* info for larger table */
        !            78:        struct ipc_splay_tree is_tree;  /* a splay tree of entries */
        !            79:        ipc_entry_num_t is_tree_total;  /* number of entries in the tree */
        !            80:        ipc_entry_num_t is_tree_small;  /* # of small entries in the tree */
        !            81:        ipc_entry_num_t is_tree_hash;   /* # of hashed entries in the tree */
        !            82: 
        !            83: #if    MACH_IPC_COMPAT
        !            84:        struct ipc_port *is_notify;     /* notification port */
        !            85: #endif /* MACH_IPC_COMPAT */
        !            86: };
        !            87: 
        !            88: #define        IS_NULL                 ((ipc_space_t) 0)
        !            89: 
        !            90: extern zone_t ipc_space_zone;
        !            91: 
        !            92: #define is_alloc()             ((ipc_space_t) zalloc(ipc_space_zone))
        !            93: #define        is_free(is)             zfree(ipc_space_zone, (vm_offset_t) (is))
        !            94: 
        !            95: extern struct ipc_space *ipc_space_kernel;
        !            96: extern struct ipc_space *ipc_space_reply;
        !            97: #if    NORMA_IPC
        !            98: extern struct ipc_space *ipc_space_remote;
        !            99: #endif /* NORMA_IPC */
        !           100: 
        !           101: #define        is_ref_lock_init(is)    simple_lock_init(&(is)->is_ref_lock_data)
        !           102: 
        !           103: #define        ipc_space_reference_macro(is)                                   \
        !           104: MACRO_BEGIN                                                            \
        !           105:        simple_lock(&(is)->is_ref_lock_data);                           \
        !           106:        assert((is)->is_references > 0);                                \
        !           107:        (is)->is_references++;                                          \
        !           108:        simple_unlock(&(is)->is_ref_lock_data);                         \
        !           109: MACRO_END
        !           110: 
        !           111: #define        ipc_space_release_macro(is)                                     \
        !           112: MACRO_BEGIN                                                            \
        !           113:        ipc_space_refs_t _refs;                                         \
        !           114:                                                                        \
        !           115:        simple_lock(&(is)->is_ref_lock_data);                           \
        !           116:        assert((is)->is_references > 0);                                \
        !           117:        _refs = --(is)->is_references;                                  \
        !           118:        simple_unlock(&(is)->is_ref_lock_data);                         \
        !           119:                                                                        \
        !           120:        if (_refs == 0)                                                 \
        !           121:                is_free(is);                                            \
        !           122: MACRO_END
        !           123: 
        !           124: #define        is_lock_init(is)        simple_lock_init(&(is)->is_lock_data)
        !           125: 
        !           126: #define        is_read_lock(is)        simple_lock(&(is)->is_lock_data)
        !           127: #define is_read_unlock(is)     simple_unlock(&(is)->is_lock_data)
        !           128: 
        !           129: #define        is_write_lock(is)       simple_lock(&(is)->is_lock_data)
        !           130: #define        is_write_lock_try(is)   simple_lock_try(&(is)->is_lock_data)
        !           131: #define is_write_unlock(is)    simple_unlock(&(is)->is_lock_data)
        !           132: 
        !           133: #define        is_write_to_read_lock(is)
        !           134: 
        !           135: extern void ipc_space_reference(struct ipc_space *space);
        !           136: extern void ipc_space_release(struct ipc_space *space);
        !           137: 
        !           138: #define        is_reference(is)        ipc_space_reference(is)
        !           139: #define        is_release(is)          ipc_space_release(is)
        !           140: 
        !           141: kern_return_t  ipc_space_create(/* ipc_table_size_t, ipc_space_t * */);
        !           142: kern_return_t  ipc_space_create_special(struct ipc_space **);
        !           143: void           ipc_space_destroy(struct ipc_space *);
        !           144: 
        !           145: #if    MACH_IPC_COMPAT
        !           146: 
        !           147: /*
        !           148:  *     Routine:        ipc_space_make_notify
        !           149:  *     Purpose:
        !           150:  *             Given a space, return a send right for a notification.
        !           151:  *             May return IP_NULL/IP_DEAD.
        !           152:  *     Conditions:
        !           153:  *             The space is locked (read or write) and active.
        !           154:  *
        !           155:  *     ipc_port_t
        !           156:  *     ipc_space_make_notify(space)
        !           157:  *             ipc_space_t space;
        !           158:  */
        !           159: 
        !           160: #define        ipc_space_make_notify(space)    \
        !           161:                ipc_port_copy_send(space->is_notify)
        !           162: 
        !           163: #endif /* MACH_IPC_COMPAT */
        !           164: #endif /* _IPC_IPC_SPACE_H_ */

unix.superglobalmegacorp.com

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