Annotation of kernel/ipc/ipc_entry.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_entry.h
        !            75:  *     Author: Rich Draves
        !            76:  *     Date:   1989
        !            77:  *
        !            78:  *     Definitions for translation entries, which represent
        !            79:  *     tasks' capabilities for ports and port sets.
        !            80:  */
        !            81: 
        !            82: #ifndef        _IPC_IPC_ENTRY_H_
        !            83: #define _IPC_IPC_ENTRY_H_
        !            84: 
        !            85: #include <mach/port.h>
        !            86: #include <mach/kern_return.h>
        !            87: #include <kern/zalloc.h>
        !            88: #include <ipc/port.h>
        !            89: #include <ipc/ipc_table.h>
        !            90: #include <ipc/ipc_types.h>
        !            91: 
        !            92: /*
        !            93:  *     Spaces hold capabilities for ipc_object_t's (ports and port sets).
        !            94:  *     Each ipc_entry_t records a capability.  Most capabilities have
        !            95:  *     small names, and the entries are elements of a table.
        !            96:  *     Capabilities can have large names, and a splay tree holds
        !            97:  *     those entries.  The cutoff point between the table and the tree
        !            98:  *     is adjusted dynamically to minimize memory consumption.
        !            99:  *
        !           100:  *     The ie_index field of entries in the table implements
        !           101:  *     a ordered hash table with open addressing and linear probing.
        !           102:  *     This hash table converts (space, object) -> name.
        !           103:  *     It is used independently of the other fields.
        !           104:  *
        !           105:  *     Free (unallocated) entries in the table have null ie_object
        !           106:  *     fields.  The ie_bits field is zero except for IE_BITS_GEN.
        !           107:  *     The ie_next (ie_request) field links free entries into a free list.
        !           108:  *
        !           109:  *     The first entry in the table (index 0) is always free.
        !           110:  *     It is used as the head of the free list.
        !           111:  */
        !           112: 
        !           113: typedef unsigned int ipc_entry_bits_t;
        !           114: typedef ipc_table_elems_t ipc_entry_num_t;     /* number of entries */
        !           115: 
        !           116: typedef struct ipc_entry {
        !           117:        ipc_entry_bits_t ie_bits;
        !           118:        struct ipc_object *ie_object;
        !           119:        union {
        !           120:                mach_port_index_t next;
        !           121:                ipc_table_index_t request;
        !           122:        } index;
        !           123:        union {
        !           124:                mach_port_index_t table;
        !           125:                struct ipc_tree_entry *tree;
        !           126:        } hash;
        !           127: } *ipc_entry_t;
        !           128: 
        !           129: #define        IE_NULL         ((ipc_entry_t) 0)
        !           130: 
        !           131: #define        ie_request      index.request
        !           132: #define        ie_next         index.next
        !           133: #define        ie_index        hash.table
        !           134: 
        !           135: #define        IE_BITS_UREFS_MASK      0x0000ffff      /* 16 bits of user-reference */
        !           136: #define        IE_BITS_UREFS(bits)     ((bits) & IE_BITS_UREFS_MASK)
        !           137: 
        !           138: #define        IE_BITS_TYPE_MASK       0x001f0000      /* 5 bits of capability type */
        !           139: #define        IE_BITS_TYPE(bits)      ((bits) & IE_BITS_TYPE_MASK)
        !           140: 
        !           141: #define        IE_BITS_MAREQUEST       0x00200000      /* 1 bit for msg-accepted */
        !           142: 
        !           143: #define        IE_BITS_COMPAT          0x00400000      /* 1 bit for compatibility */
        !           144: 
        !           145: #define        IE_BITS_COLLISION       0x00800000      /* 1 bit for collisions */
        !           146: #define        IE_BITS_GEN_MASK        0xff000000U     /* 8 bits for generation */
        !           147: #define        IE_BITS_GEN(bits)       ((bits) & IE_BITS_GEN_MASK)
        !           148: #define        IE_BITS_GEN_ONE         0x01000000      /* low bit of generation */
        !           149: #define        IE_BITS_RIGHT_MASK      0x007fffff      /* relevant to the right */
        !           150: 
        !           151: 
        !           152: typedef struct ipc_tree_entry {
        !           153:        struct ipc_entry ite_entry;
        !           154:        mach_port_t ite_name;
        !           155:        struct ipc_space *ite_space;
        !           156:        struct ipc_tree_entry *ite_lchild;
        !           157:        struct ipc_tree_entry *ite_rchild;
        !           158: } *ipc_tree_entry_t;
        !           159: 
        !           160: #define        ITE_NULL        ((ipc_tree_entry_t) 0)
        !           161: 
        !           162: #define        ite_bits        ite_entry.ie_bits
        !           163: #define        ite_object      ite_entry.ie_object
        !           164: #define        ite_request     ite_entry.ie_request
        !           165: #define        ite_next        ite_entry.hash.tree
        !           166: 
        !           167: extern zone_t ipc_tree_entry_zone;
        !           168: 
        !           169: #define ite_alloc()    ((ipc_tree_entry_t) zalloc(ipc_tree_entry_zone))
        !           170: #define        ite_free(ite)   zfree(ipc_tree_entry_zone, (vm_offset_t) (ite))
        !           171: 
        !           172: /*
        !           173:  * Exported interfaces
        !           174:  */
        !           175: 
        !           176: /* Search for entry in a space by name */
        !           177: extern ipc_entry_t ipc_entry_lookup(
        !           178:        ipc_space_t     space,
        !           179:        mach_port_t     name);
        !           180: 
        !           181: /* Allocate an entry in a space */
        !           182: extern kern_return_t ipc_entry_get(
        !           183:        ipc_space_t     space,
        !           184:        mach_port_t     *namep,
        !           185:        ipc_entry_t     *entryp);
        !           186: 
        !           187: /* Allocate an entry in a space, growing the space if necessary */
        !           188: extern kern_return_t ipc_entry_alloc(
        !           189:        ipc_space_t     space,
        !           190:        mach_port_t     *namep,
        !           191:        ipc_entry_t     *entryp);
        !           192: 
        !           193: /* Allocate/find an entry in a space with a specific name */
        !           194: extern kern_return_t ipc_entry_alloc_name(
        !           195:        ipc_space_t     space,
        !           196:        mach_port_t     name,
        !           197:        ipc_entry_t     *entryp);
        !           198: 
        !           199: /* Deallocate an entry from a space */
        !           200: extern void ipc_entry_dealloc(
        !           201:        ipc_space_t     space,
        !           202:        mach_port_t     name,
        !           203:        ipc_entry_t     entry);
        !           204: 
        !           205: /* Grow the table in a space */
        !           206: extern kern_return_t ipc_entry_grow_table(
        !           207:        ipc_space_t     space,
        !           208:        int             target_size);
        !           209: 
        !           210: #endif /* _IPC_IPC_ENTRY_H_ */

unix.superglobalmegacorp.com

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