Annotation of Gnu-Mach/ipc/ipc_entry.h, revision 1.1.1.4

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:  *     File:   ipc/ipc_entry.h
                     31:  *     Author: Rich Draves
                     32:  *     Date:   1989
                     33:  *
                     34:  *     Definitions for translation entries, which represent
                     35:  *     tasks' capabilities for ports and port sets.
                     36:  */
                     37: 
                     38: #ifndef        _IPC_IPC_ENTRY_H_
                     39: #define _IPC_IPC_ENTRY_H_
                     40: 
1.1.1.3   root       41: #include <mach/mach_types.h>
1.1       root       42: #include <mach/port.h>
                     43: #include <mach/kern_return.h>
1.1.1.3   root       44: #include <kern/slab.h>
1.1       root       45: #include <ipc/port.h>
                     46: #include <ipc/ipc_table.h>
1.1.1.3   root       47: #include <ipc/ipc_types.h>
1.1       root       48: 
                     49: /*
                     50:  *     Spaces hold capabilities for ipc_object_t's (ports and port sets).
                     51:  *     Each ipc_entry_t records a capability.  Most capabilities have
                     52:  *     small names, and the entries are elements of a table.
                     53:  *     Capabilities can have large names, and a splay tree holds
                     54:  *     those entries.  The cutoff point between the table and the tree
                     55:  *     is adjusted dynamically to minimize memory consumption.
                     56:  *
                     57:  *     The ie_index field of entries in the table implements
                     58:  *     a ordered hash table with open addressing and linear probing.
                     59:  *     This hash table converts (space, object) -> name.
                     60:  *     It is used independently of the other fields.
                     61:  *
                     62:  *     Free (unallocated) entries in the table have null ie_object
                     63:  *     fields.  The ie_bits field is zero except for IE_BITS_GEN.
                     64:  *     The ie_next (ie_request) field links free entries into a free list.
                     65:  *
                     66:  *     The first entry in the table (index 0) is always free.
                     67:  *     It is used as the head of the free list.
                     68:  */
                     69: 
                     70: typedef unsigned int ipc_entry_bits_t;
                     71: typedef ipc_table_elems_t ipc_entry_num_t;     /* number of entries */
                     72: 
                     73: typedef struct ipc_entry {
                     74:        ipc_entry_bits_t ie_bits;
                     75:        struct ipc_object *ie_object;
                     76:        union {
                     77:                mach_port_index_t next;
                     78:                /*XXX ipc_port_request_index_t request;*/
                     79:                unsigned int request;
                     80:        } index;
                     81:        union {
                     82:                mach_port_index_t table;
                     83:                struct ipc_tree_entry *tree;
                     84:        } hash;
                     85: } *ipc_entry_t;
                     86: 
                     87: #define        IE_NULL         ((ipc_entry_t) 0)
                     88: 
                     89: #define        ie_request      index.request
                     90: #define        ie_next         index.next
                     91: #define        ie_index        hash.table
                     92: 
                     93: #define        IE_BITS_UREFS_MASK      0x0000ffff      /* 16 bits of user-reference */
                     94: #define        IE_BITS_UREFS(bits)     ((bits) & IE_BITS_UREFS_MASK)
                     95: 
                     96: #define        IE_BITS_TYPE_MASK       0x001f0000      /* 5 bits of capability type */
                     97: #define        IE_BITS_TYPE(bits)      ((bits) & IE_BITS_TYPE_MASK)
                     98: 
                     99: #define        IE_BITS_MAREQUEST       0x00200000      /* 1 bit for msg-accepted */
                    100: 
                    101: #define        IE_BITS_COMPAT          0x00400000      /* 1 bit for compatibility */
                    102: 
                    103: #define        IE_BITS_COLLISION       0x00800000      /* 1 bit for collisions */
                    104: #define        IE_BITS_RIGHT_MASK      0x007fffff      /* relevant to the right */
                    105: 
                    106: #if PORT_GENERATIONS
                    107: #define        IE_BITS_GEN_MASK        0xff000000U     /* 8 bits for generation */
                    108: #define        IE_BITS_GEN(bits)       ((bits) & IE_BITS_GEN_MASK)
                    109: #define        IE_BITS_GEN_ONE         0x01000000      /* low bit of generation */
                    110: #else
                    111: #define        IE_BITS_GEN_MASK        0
                    112: #define        IE_BITS_GEN(bits)       0
                    113: #define        IE_BITS_GEN_ONE         0
                    114: #endif
                    115: 
                    116: 
                    117: typedef struct ipc_tree_entry {
                    118:        struct ipc_entry ite_entry;
                    119:        mach_port_t ite_name;
                    120:        struct ipc_space *ite_space;
                    121:        struct ipc_tree_entry *ite_lchild;
                    122:        struct ipc_tree_entry *ite_rchild;
                    123: } *ipc_tree_entry_t;
                    124: 
                    125: #define        ITE_NULL        ((ipc_tree_entry_t) 0)
                    126: 
                    127: #define        ite_bits        ite_entry.ie_bits
                    128: #define        ite_object      ite_entry.ie_object
                    129: #define        ite_request     ite_entry.ie_request
                    130: #define        ite_next        ite_entry.hash.tree
                    131: 
1.1.1.3   root      132: extern struct kmem_cache ipc_tree_entry_cache;
1.1       root      133: 
1.1.1.3   root      134: #define ite_alloc()    ((ipc_tree_entry_t) kmem_cache_alloc(&ipc_tree_entry_cache))
                    135: #define        ite_free(ite)   kmem_cache_free(&ipc_tree_entry_cache, (vm_offset_t) (ite))
1.1       root      136: 
                    137: 
                    138: extern ipc_entry_t
1.1.1.3   root      139: ipc_entry_lookup(ipc_space_t space, mach_port_t name);
1.1       root      140: 
                    141: extern kern_return_t
1.1.1.3   root      142: ipc_entry_get(ipc_space_t space, mach_port_t *namep, ipc_entry_t *entryp);
1.1       root      143: 
                    144: extern kern_return_t
1.1.1.3   root      145: ipc_entry_alloc(ipc_space_t space, mach_port_t *namep, ipc_entry_t *entryp);
1.1       root      146: 
                    147: extern kern_return_t
1.1.1.3   root      148: ipc_entry_alloc_name(ipc_space_t space, mach_port_t name, ipc_entry_t *entryp);
1.1       root      149: 
                    150: extern void
1.1.1.3   root      151: ipc_entry_dealloc(ipc_space_t space, mach_port_t name, ipc_entry_t entry);
1.1       root      152: 
                    153: extern kern_return_t
1.1.1.3   root      154: ipc_entry_grow_table(ipc_space_t space);
1.1       root      155: 
1.1.1.4 ! root      156: ipc_entry_t
        !           157: db_ipc_object_by_name(
        !           158:        task_t          task,
        !           159:        mach_port_t     name);
        !           160: 
1.1.1.2   root      161: #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.