Annotation of XNU/osfmk/ipc/ipc_entry.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * The contents of this file constitute Original Code as defined in and
                      7:  * are subject to the Apple Public Source License Version 1.1 (the
                      8:  * "License").  You may not use this file except in compliance with the
                      9:  * License.  Please obtain a copy of the License at
                     10:  * http://www.apple.com/publicsource and read it before using this file.
                     11:  * 
                     12:  * This Original Code and all software distributed under the License are
                     13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     17:  * License for the specific language governing rights and limitations
                     18:  * under the License.
                     19:  * 
                     20:  * @APPLE_LICENSE_HEADER_END@
                     21:  */
                     22: /*
                     23:  * @OSF_COPYRIGHT@
                     24:  */
                     25: /* 
                     26:  * Mach Operating System
                     27:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
                     28:  * All Rights Reserved.
                     29:  * 
                     30:  * Permission to use, copy, modify and distribute this software and its
                     31:  * documentation is hereby granted, provided that both the copyright
                     32:  * notice and this permission notice appear in all copies of the
                     33:  * software, derivative works or modified versions, and any portions
                     34:  * thereof, and that both notices appear in supporting documentation.
                     35:  * 
                     36:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     37:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     38:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     39:  * 
                     40:  * Carnegie Mellon requests users of this software to return to
                     41:  * 
                     42:  *  Software Distribution Coordinator  or  [email protected]
                     43:  *  School of Computer Science
                     44:  *  Carnegie Mellon University
                     45:  *  Pittsburgh PA 15213-3890
                     46:  * 
                     47:  * any improvements or extensions that they make and grant Carnegie Mellon
                     48:  * the rights to redistribute these changes.
                     49:  */
                     50: /*
                     51:  */
                     52: /*
                     53:  *     File:   ipc/ipc_entry.h
                     54:  *     Author: Rich Draves
                     55:  *     Date:   1989
                     56:  *
                     57:  *     Definitions for translation entries, which represent
                     58:  *     tasks' capabilities for ports and port sets.
                     59:  */
                     60: 
                     61: #ifndef        _IPC_IPC_ENTRY_H_
                     62: #define _IPC_IPC_ENTRY_H_
                     63: 
                     64: #include <mach/port.h>
                     65: #include <mach/kern_return.h>
                     66: #include <kern/zalloc.h>
                     67: #include <ipc/port.h>
                     68: #include <ipc/ipc_table.h>
                     69: #include <ipc/ipc_types.h>
                     70: 
                     71: /*
                     72:  *     Spaces hold capabilities for ipc_object_t's.
                     73:  *     Each ipc_entry_t records a capability.  Most capabilities have
                     74:  *     small names, and the entries are elements of a table.
                     75:  *     Capabilities can have large names, and a splay tree holds
                     76:  *     those entries.  The cutoff point between the table and the tree
                     77:  *     is adjusted dynamically to minimize memory consumption.
                     78:  *
                     79:  *     The ie_index field of entries in the table implements
                     80:  *     a ordered hash table with open addressing and linear probing.
                     81:  *     This hash table converts (space, object) -> name.
                     82:  *     It is used independently of the other fields.
                     83:  *
                     84:  *     Free (unallocated) entries in the table have null ie_object
                     85:  *     fields.  The ie_bits field is zero except for IE_BITS_GEN.
                     86:  *     The ie_next (ie_request) field links free entries into a free list.
                     87:  *
                     88:  *     The first entry in the table (index 0) is always free.
                     89:  *     It is used as the head of the free list.
                     90:  */
                     91: 
                     92: typedef natural_t ipc_entry_bits_t;
                     93: typedef ipc_table_elems_t ipc_entry_num_t;     /* number of entries */
                     94: 
                     95: typedef struct ipc_entry {
                     96:        struct ipc_object *ie_object;
                     97:        ipc_entry_bits_t ie_bits;
                     98:        union {
                     99:                mach_port_index_t next;         /* next in freelist, or...  */
                    100:                ipc_table_index_t request;      /* dead name request notify */
                    101:        } index;
                    102:        union {
                    103:                mach_port_index_t table;
                    104:                struct ipc_tree_entry *tree;
                    105:        } hash;
                    106: } *ipc_entry_t;
                    107: 
                    108: #define        IE_NULL         ((ipc_entry_t) 0)
                    109: 
                    110: #define        ie_request      index.request
                    111: #define        ie_next         index.next
                    112: #define        ie_index        hash.table
                    113: 
                    114: #define        IE_BITS_UREFS_MASK      0x0000ffff      /* 16 bits of user-reference */
                    115: #define        IE_BITS_UREFS(bits)     ((bits) & IE_BITS_UREFS_MASK)
                    116: 
                    117: #define        IE_BITS_TYPE_MASK       0x001f0000      /* 5 bits of capability type */
                    118: #define        IE_BITS_TYPE(bits)      ((bits) & IE_BITS_TYPE_MASK)
                    119: 
                    120: #define        IE_BITS_COLLISION       0x00800000      /* 1 bit for collisions */
                    121: 
                    122: 
                    123: #ifndef NO_PORT_GEN
                    124: #define        IE_BITS_GEN_MASK        0xff000000      /* 8 bits for generation */
                    125: #define        IE_BITS_GEN(bits)       ((bits) & IE_BITS_GEN_MASK)
                    126: #define        IE_BITS_GEN_ONE         0x04000000      /* low bit of generation */
                    127: #define IE_BITS_NEW_GEN(old)   (((old) + IE_BITS_GEN_ONE) & IE_BITS_GEN_MASK)
                    128: #else
                    129: #define        IE_BITS_GEN_MASK        0
                    130: #define        IE_BITS_GEN(bits)       0
                    131: #define        IE_BITS_GEN_ONE         0
                    132: #define IE_BITS_NEW_GEN(old)   (old)
                    133: #endif /* !USE_PORT_GEN */
                    134: 
                    135: 
                    136: #define        IE_BITS_RIGHT_MASK      0x007fffff      /* relevant to the right */
                    137: 
                    138: typedef struct ipc_tree_entry {
                    139:        struct ipc_entry ite_entry;
                    140:        mach_port_name_t ite_name;
                    141:        struct ipc_space *ite_space;
                    142:        struct ipc_tree_entry *ite_lchild;
                    143:        struct ipc_tree_entry *ite_rchild;
                    144: } *ipc_tree_entry_t;
                    145: 
                    146: #define        ITE_NULL        ((ipc_tree_entry_t) 0)
                    147: 
                    148: #define        ite_bits        ite_entry.ie_bits
                    149: #define        ite_object      ite_entry.ie_object
                    150: #define        ite_request     ite_entry.ie_request
                    151: #define        ite_next        ite_entry.hash.tree
                    152: 
                    153: extern zone_t ipc_tree_entry_zone;
                    154: 
                    155: #define ite_alloc()    ((ipc_tree_entry_t) zalloc(ipc_tree_entry_zone))
                    156: #define        ite_free(ite)   zfree(ipc_tree_entry_zone, (vm_offset_t) (ite))
                    157: 
                    158: /*
                    159:  * Exported interfaces
                    160:  */
                    161: 
                    162: /* Search for entry in a space by name */
                    163: extern ipc_entry_t ipc_entry_lookup(
                    164:        ipc_space_t             space,
                    165:        mach_port_name_t        name);
                    166: 
                    167: /* Allocate an entry in a space */
                    168: extern kern_return_t ipc_entry_get(
                    169:        ipc_space_t             space,
                    170:        mach_port_name_t        *namep,
                    171:        ipc_entry_t             *entryp);
                    172: 
                    173: /* Allocate an entry in a space, growing the space if necessary */
                    174: extern kern_return_t ipc_entry_alloc(
                    175:        ipc_space_t             space,
                    176:        mach_port_name_t        *namep,
                    177:        ipc_entry_t             *entryp);
                    178: 
                    179: /* Allocate/find an entry in a space with a specific name */
                    180: extern kern_return_t ipc_entry_alloc_name(
                    181:        ipc_space_t             space,
                    182:        mach_port_name_t        name,
                    183:        ipc_entry_t             *entryp);
                    184: 
                    185: /* Deallocate an entry from a space */
                    186: extern void ipc_entry_dealloc(
                    187:        ipc_space_t             space,
                    188:        mach_port_name_t        name,
                    189:        ipc_entry_t             entry);
                    190: 
                    191: /* Grow the table in a space */
                    192: extern kern_return_t ipc_entry_grow_table(
                    193:        ipc_space_t     space,
                    194:        int             target_size);
                    195: 
                    196: #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.