Annotation of kernel/ipc/ipc_space.h, revision 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_space.h
        !            75:  *     Author: Rich Draves
        !            76:  *     Date:   1989
        !            77:  *
        !            78:  *     Definitions for IPC spaces of capabilities.
        !            79:  */
        !            80: 
        !            81: #ifndef        _IPC_IPC_SPACE_H_
        !            82: #define _IPC_IPC_SPACE_H_
        !            83: 
        !            84: #import <mach/features.h>
        !            85: 
        !            86: #include <mach/boolean.h>
        !            87: #include <mach/kern_return.h>
        !            88: #include <kern/macro_help.h>
        !            89: #include <kern/lock.h>
        !            90: #include <kern/zalloc.h>
        !            91: #include <ipc/ipc_entry.h>
        !            92: #include <ipc/ipc_splay.h>
        !            93: #include <ipc/ipc_types.h>
        !            94: 
        !            95: /*
        !            96:  *     Every task has a space of IPC capabilities.
        !            97:  *     IPC operations like send and receive use this space.
        !            98:  *     IPC kernel calls manipulate the space of the target task.
        !            99:  *
        !           100:  *     Every space has a non-NULL is_table with is_table_size entries.
        !           101:  *     A space may have a NULL is_tree.  is_tree_small records the
        !           102:  *     number of entries in the tree that, if the table were to grow
        !           103:  *     to the next larger size, would move from the tree to the table.
        !           104:  *
        !           105:  *     is_growing marks when the table is in the process of growing.
        !           106:  *     When the table is growing, it can't be freed or grown by another
        !           107:  *     thread, because of krealloc/kmem_realloc's requirements.
        !           108:  */
        !           109: 
        !           110: typedef unsigned int ipc_space_refs_t;
        !           111: 
        !           112: struct ipc_space {
        !           113:        decl_simple_lock_data(,is_ref_lock_data)
        !           114:        ipc_space_refs_t is_references;
        !           115: 
        !           116:        decl_simple_lock_data(,is_lock_data)
        !           117:        boolean_t is_active;            /* is the space alive? */
        !           118:        boolean_t is_growing;           /* is the space growing? */
        !           119:        ipc_entry_t is_table;           /* an array of entries */
        !           120:        ipc_entry_num_t is_table_size;  /* current size of table */
        !           121:        struct ipc_table_size *is_table_next; /* info for larger table */
        !           122:        struct ipc_splay_tree is_tree;  /* a splay tree of entries */
        !           123:        ipc_entry_num_t is_tree_total;  /* number of entries in the tree */
        !           124:        ipc_entry_num_t is_tree_small;  /* # of small entries in the tree */
        !           125:        ipc_entry_num_t is_tree_hash;   /* # of hashed entries in the tree */
        !           126: 
        !           127: #if    MACH_IPC_COMPAT
        !           128:        struct ipc_port *is_notify;     /* notification port */
        !           129: #endif /* MACH_IPC_COMPAT */
        !           130: };
        !           131: 
        !           132: #define        IS_NULL                 ((ipc_space_t) 0)
        !           133: 
        !           134: extern zone_t ipc_space_zone;
        !           135: 
        !           136: #define is_alloc()             ((ipc_space_t) zalloc(ipc_space_zone))
        !           137: #define        is_free(is)             zfree(ipc_space_zone, (vm_offset_t) (is))
        !           138: 
        !           139: extern ipc_space_t ipc_space_kernel;
        !           140: extern ipc_space_t ipc_space_reply;
        !           141: 
        !           142: #define        is_ref_lock_init(is)    simple_lock_init(&(is)->is_ref_lock_data)
        !           143: 
        !           144: #define        ipc_space_reference_macro(is)                                   \
        !           145: MACRO_BEGIN                                                            \
        !           146:        simple_lock(&(is)->is_ref_lock_data);                           \
        !           147:        assert((is)->is_references > 0);                                \
        !           148:        (is)->is_references++;                                          \
        !           149:        simple_unlock(&(is)->is_ref_lock_data);                         \
        !           150: MACRO_END
        !           151: 
        !           152: #define        ipc_space_release_macro(is)                                     \
        !           153: MACRO_BEGIN                                                            \
        !           154:        ipc_space_refs_t _refs;                                         \
        !           155:                                                                        \
        !           156:        simple_lock(&(is)->is_ref_lock_data);                           \
        !           157:        assert((is)->is_references > 0);                                \
        !           158:        _refs = --(is)->is_references;                                  \
        !           159:        simple_unlock(&(is)->is_ref_lock_data);                         \
        !           160:                                                                        \
        !           161:        if (_refs == 0)                                                 \
        !           162:                is_free(is);                                            \
        !           163: MACRO_END
        !           164: 
        !           165: #define        is_lock_init(is)        simple_lock_init(&(is)->is_lock_data)
        !           166: 
        !           167: #define        is_read_lock(is)        simple_lock(&(is)->is_lock_data)
        !           168: #define is_read_unlock(is)     simple_unlock(&(is)->is_lock_data)
        !           169: 
        !           170: #define        is_write_lock(is)       simple_lock(&(is)->is_lock_data)
        !           171: #define        is_write_lock_try(is)   simple_lock_try(&(is)->is_lock_data)
        !           172: #define is_write_unlock(is)    simple_unlock(&(is)->is_lock_data)
        !           173: 
        !           174: #define        is_write_to_read_lock(is)
        !           175: 
        !           176: /* Take a reference on a space */
        !           177: extern void ipc_space_reference(
        !           178:        ipc_space_t     space);
        !           179: 
        !           180: /* Realase a reference on a space */
        !           181: extern void ipc_space_release(
        !           182:        ipc_space_t     space);
        !           183: 
        !           184: #define        is_reference(is)        ipc_space_reference(is)
        !           185: #define        is_release(is)          ipc_space_release(is)
        !           186: 
        !           187: /* Create  new IPC space */
        !           188: extern kern_return_t ipc_space_create(
        !           189:        ipc_table_size_t        initial,
        !           190:        ipc_space_t             *spacep);
        !           191: 
        !           192: /* Create a special IPC space */
        !           193: extern kern_return_t ipc_space_create_special(
        !           194:        ipc_space_t     *spacep);
        !           195: 
        !           196: /* Mark a space as dead and cleans up the entries*/
        !           197: extern void ipc_space_destroy(
        !           198:        ipc_space_t     space);
        !           199: 
        !           200: #if    MACH_IPC_COMPAT
        !           201: 
        !           202: /*
        !           203:  *     Routine:        ipc_space_make_notify
        !           204:  *     Purpose:
        !           205:  *             Given a space, return a send right for a notification.
        !           206:  *             May return IP_NULL/IP_DEAD.
        !           207:  *     Conditions:
        !           208:  *             The space is locked (read or write) and active.
        !           209:  *
        !           210:  *     ipc_port_t
        !           211:  *     ipc_space_make_notify(space)
        !           212:  *             ipc_space_t space;
        !           213:  */
        !           214: 
        !           215: #define        ipc_space_make_notify(space)    \
        !           216:                ipc_port_copy_send(space->is_notify)
        !           217: 
        !           218: #endif /* MACH_IPC_COMPAT */
        !           219: 
        !           220: #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.