Annotation of XNU/osfmk/ipc/ipc_table.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:  * HISTORY
                     27:  * 
                     28:  * Revision 1.1.1.1  1998/09/22 21:05:28  wsanchez
                     29:  * Import of Mac OS X kernel (~semeria)
                     30:  *
                     31:  * Revision 1.2  1998/05/29 23:50:33  youngwor
                     32:  * Added infrastructure for shared port space support
                     33:  *
                     34:  * Revision 1.1.1.1  1998/03/07 02:26:16  wsanchez
                     35:  * Import of OSF Mach kernel (~mburg)
                     36:  *
                     37:  * Revision 1.1.8.3  1995/01/06  19:46:05  devrcs
                     38:  *     mk6 CR668 - 1.3b26 merge
                     39:  *     64bit cleanup
                     40:  *     [1994/10/14  03:41:41  dwm]
                     41:  *
                     42:  * Revision 1.1.8.2  1994/09/23  02:12:26  ezf
                     43:  *     change marker to not FREE
                     44:  *     [1994/09/22  21:30:53  ezf]
                     45:  * 
                     46:  * Revision 1.1.8.1  1994/08/18  23:11:45  widyono
                     47:  *     RT IPC from RT2_SHARED
                     48:  *     [1994/08/18  15:49:24  widyono]
                     49:  * 
                     50:  * Revision 1.1.6.1  1994/07/29  07:33:22  widyono
                     51:  *     Define default target size, ITS_SIZE_NONE
                     52:  *     [1994/07/28  22:27:01  widyono]
                     53:  * 
                     54:  * Revision 1.1.2.4  1993/07/22  16:17:33  rod
                     55:  *     Add ANSI prototypes.  CR #9523.
                     56:  *     [1993/07/22  13:33:33  rod]
                     57:  * 
                     58:  * Revision 1.1.2.3  1993/06/07  22:11:46  jeffc
                     59:  *     CR9176 - ANSI C violations: trailing tokens on CPP
                     60:  *     directives, extra semicolons after decl_ ..., asm keywords
                     61:  *     [1993/06/07  19:02:58  jeffc]
                     62:  * 
                     63:  * Revision 1.1.2.2  1993/06/02  23:34:02  jeffc
                     64:  *     Added to OSF/1 R1.3 from NMK15.0.
                     65:  *     [1993/06/02  21:11:17  jeffc]
                     66:  * 
                     67:  * Revision 1.1  1992/09/30  02:29:14  robert
                     68:  *     Initial revision
                     69:  * 
                     70:  * $EndLog$
                     71:  */
                     72: /* CMU_HIST */
                     73: /*
                     74:  * Revision 2.5  91/05/14  16:37:52  mrt
                     75:  *     Correcting copyright
                     76:  * 
                     77:  * Revision 2.4  91/03/16  14:49:01  rpd
                     78:  *     Added ipc_table_realloc.
                     79:  *     [91/03/04            rpd]
                     80:  * 
                     81:  * Revision 2.3  91/02/05  17:24:19  mrt
                     82:  *     Changed to new Mach copyright
                     83:  *     [91/02/01  15:52:19  mrt]
                     84:  * 
                     85:  * Revision 2.2  90/06/02  14:52:02  rpd
                     86:  *     Created for new IPC.
                     87:  *     [90/03/26  21:04:35  rpd]
                     88:  * 
                     89:  */
                     90: /* CMU_ENDHIST */
                     91: /* 
                     92:  * Mach Operating System
                     93:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
                     94:  * All Rights Reserved.
                     95:  * 
                     96:  * Permission to use, copy, modify and distribute this software and its
                     97:  * documentation is hereby granted, provided that both the copyright
                     98:  * notice and this permission notice appear in all copies of the
                     99:  * software, derivative works or modified versions, and any portions
                    100:  * thereof, and that both notices appear in supporting documentation.
                    101:  * 
                    102:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                    103:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                    104:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                    105:  * 
                    106:  * Carnegie Mellon requests users of this software to return to
                    107:  * 
                    108:  *  Software Distribution Coordinator  or  [email protected]
                    109:  *  School of Computer Science
                    110:  *  Carnegie Mellon University
                    111:  *  Pittsburgh PA 15213-3890
                    112:  * 
                    113:  * any improvements or extensions that they make and grant Carnegie Mellon
                    114:  * the rights to redistribute these changes.
                    115:  */
                    116: /*
                    117:  */
                    118: /*
                    119:  *     File:   ipc/ipc_table.h
                    120:  *     Author: Rich Draves
                    121:  *     Date:   1989
                    122:  *
                    123:  *     Definitions for tables, used for IPC capabilities (ipc_entry_t)
                    124:  *     and dead-name requests (ipc_port_request_t).
                    125:  */
                    126: 
                    127: #ifndef        _IPC_IPC_TABLE_H_
                    128: #define        _IPC_IPC_TABLE_H_
                    129: 
                    130: #include <mach/boolean.h>
                    131: #include <mach/vm_param.h>
                    132: 
                    133: /*
                    134:  *     The is_table_next field of an ipc_space_t points to
                    135:  *     an ipc_table_size structure.  These structures must
                    136:  *     be elements of an array, ipc_table_entries.
                    137:  *
                    138:  *     The array must end with two elements with the same its_size value.
                    139:  *     Except for the terminating element, the its_size values must
                    140:  *     be strictly increasing.  The largest (last) its_size value
                    141:  *     must be less than or equal to MACH_PORT_INDEX(MACH_PORT_DEAD).
                    142:  *     This ensures that
                    143:  *             1) MACH_PORT_INDEX(MACH_PORT_DEAD) isn't a valid index
                    144:  *             in the table, so ipc_entry_get won't allocate it.
                    145:  *             2) MACH_PORT_MAKE(index+1, 0) and MAKE_PORT_MAKE(size, 0)
                    146:  *             won't ever overflow.
                    147:  *
                    148:  *
                    149:  *     The ipr_size field of the first element in a table of
                    150:  *     dead-name requests (ipc_port_request_t) points to the
                    151:  *     ipc_table_size structure.  The structures must be elements
                    152:  *     of ipc_table_dnrequests.  ipc_table_dnrequests must end
                    153:  *     with an element with zero its_size, and except for this last
                    154:  *     element, the its_size values must be strictly increasing.
                    155:  *
                    156:  *     The is_table_next field points to the ipc_table_size structure
                    157:  *     for the next larger size of table, not the one currently in use.
                    158:  *     The ipr_size field points to the currently used ipc_table_size.
                    159:  */
                    160: 
                    161: typedef natural_t ipc_table_index_t;   /* index into tables */
                    162: typedef natural_t ipc_table_elems_t;   /* size of tables */
                    163: 
                    164: typedef struct ipc_table_size {
                    165:        ipc_table_elems_t its_size;     /* number of elements in table */
                    166: } *ipc_table_size_t;
                    167: 
                    168: #define        ITS_NULL        ((ipc_table_size_t) 0)
                    169: #define ITS_SIZE_NONE  -1
                    170: 
                    171: extern ipc_table_size_t ipc_table_entries;
                    172: extern ipc_table_size_t ipc_table_dnrequests;
                    173: 
                    174: /* Initialize IPC capabilities table storage */
                    175: extern void ipc_table_init(void);
                    176: 
                    177: /*
                    178:  *     Note that ipc_table_alloc, ipc_table_realloc, and ipc_table_free
                    179:  *     all potentially use the VM system.  Hence simple locks can't
                    180:  *     be held across them.
                    181:  *
                    182:  *     We can't use a copying realloc, because the realloc happens
                    183:  *     with the data unlocked.  ipc_table_realloc remaps the data,
                    184:  *     so it is OK.
                    185:  */
                    186: 
                    187: /* Allocate a table */
                    188: extern vm_offset_t ipc_table_alloc(
                    189:        vm_size_t       size);
                    190: 
                    191: /* Reallocate a big table */
                    192: extern vm_offset_t ipc_table_realloc(
                    193:        vm_size_t       old_size,
                    194:        vm_offset_t     old_table,
                    195:        vm_size_t       new_size);
                    196: 
                    197: /* Free a table */
                    198: extern void ipc_table_free(
                    199:        vm_size_t       size,
                    200:        vm_offset_t     table);
                    201: 
                    202: #define        it_entries_alloc(its)                                           \
                    203:        ((ipc_entry_t)                                                  \
                    204:         ipc_table_alloc(round_page(                                    \
                    205:        (its)->its_size * sizeof(struct ipc_entry))))
                    206: 
                    207: #define it_entries_reallocable(its)                                    \
                    208:        ((its)->its_size * sizeof(struct ipc_entry)                     \
                    209:        >= PAGE_SIZE)
                    210: 
                    211: #define        it_entries_realloc(its, table, nits)                            \
                    212:        ((ipc_entry_t)                                                  \
                    213:        ipc_table_realloc(                                              \
                    214:            round_page((its)->its_size * sizeof(struct ipc_entry)),     \
                    215:            (vm_offset_t)(table),                                       \
                    216:            round_page((nits)->its_size * sizeof(struct ipc_entry))     \
                    217:        ))
                    218: 
                    219: #define        it_entries_free(its, table)                                     \
                    220:        ipc_table_free(                                                 \
                    221:            round_page((its)->its_size * sizeof(struct ipc_entry)),     \
                    222:            (vm_offset_t)(table)                                        \
                    223:        )
                    224: 
                    225: #define        it_dnrequests_alloc(its)                                        \
                    226:        ((ipc_port_request_t)                                           \
                    227:         ipc_table_alloc((its)->its_size *                              \
                    228:                         sizeof(struct ipc_port_request)))
                    229: 
                    230: #define        it_dnrequests_free(its, table)                                  \
                    231:        ipc_table_free((its)->its_size *                                \
                    232:                       sizeof(struct ipc_port_request),                 \
                    233:                       (vm_offset_t)(table))
                    234: 
                    235: #endif /* _IPC_IPC_TABLE_H_ */

unix.superglobalmegacorp.com

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