Annotation of XNU/osfmk/mach/shared_memory_server.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:  *
                     24:  *     File: kern/shared_memory_server.h
                     25:  *
                     26:  *     protos and struct definitions for shared library
                     27:  *     server and interface
                     28:  */
                     29: #ifndef _SHARED_MEMORY_SERVER_H_
                     30: #define _SHARED_MEMORY_SERVER_H_
                     31: 
                     32: #include <mach/vm_prot.h>
                     33: 
                     34: #ifdef MACH_KERNEL_PRIVATE
                     35: 
                     36: #include <kern/queue.h>
                     37: #include <vm/vm_object.h>
                     38: 
                     39: extern ipc_port_t      shared_text_region_handle;
                     40: extern ipc_port_t      shared_data_region_handle;
                     41: #else /* MACH_KERNEL_PRIVATE */
                     42: 
                     43: #ifdef KERNEL_PRIVATE
                     44: extern mach_port_t      shared_text_region_handle;
                     45: extern mach_port_t      shared_data_region_handle;
                     46: #endif
                     47: #endif /* MACH_KERNEL_PRIVATE*/
                     48: 
                     49: #ifdef KERNEL_PRIVATE
                     50: extern vm_offset_t     shared_file_mapping_array;
                     51: #endif
                     52: 
                     53: 
                     54: #define SHARED_LIB_ALIAS  0x10
                     55: 
                     56: 
                     57: /* flags field aliases for copyin_shared_file and load_shared_file */
                     58: 
                     59: /* IN */
                     60: #define ALTERNATE_LOAD_SITE 0x1
                     61: 
                     62: /* OUT */
                     63: #define SF_PREV_LOADED    0x1
                     64: 
                     65: 
                     66: #define load_file_hash(file_object, size) \
                     67:                ((((natural_t)file_object) & 0xffffff) % size)
                     68: 
                     69: #define VM_PROT_COW  0x8  /* must not interfere with normal prot assignments */
                     70: 
                     71: struct sf_mapping {
                     72:        vm_offset_t     mapping_offset;
                     73:        vm_size_t       size;
                     74:        vm_offset_t     file_offset;
                     75:        vm_prot_t       protection;  /* read/write/execute/COW */
                     76:        
                     77:        struct sf_mapping *next;
                     78: };
                     79: 
                     80: typedef struct sf_mapping sf_mapping_t;
                     81: 
                     82: #ifdef MACH_KERNEL_PRIVATE
                     83: 
                     84: struct load_struct {
                     85:        queue_chain_t   links;  
                     86:        int             file_object;
                     87:        vm_offset_t     base_address;
                     88:        int             mapping_cnt;
                     89:        sf_mapping_t    *mappings;
                     90: };
                     91: 
                     92: #endif /* MACH_KERNEL_PRIVATE */
                     93: 
                     94: typedef struct load_struct load_struct_t;
                     95: typedef struct load_struct *load_struct_ptr_t;
                     96: 
                     97: #ifdef MACH_KERNEL_PRIVATE
                     98: 
                     99: struct load_file_ele {
                    100:        union {
                    101:                sf_mapping_t    mapping;
                    102:                load_struct_t   element;
                    103:        } u;
                    104: };
                    105: 
                    106: struct shared_file_info {
                    107:        mutex_t         lock;   /* lock for the structure */
                    108:        queue_head_t    *hash;  /* for later perf enhance */
                    109:        int             hash_size;
                    110:        boolean_t       hash_init;
                    111: };
                    112: 
                    113: typedef struct shared_file_info shared_file_info_t;
                    114: 
                    115: extern kern_return_t                                   
                    116: copyin_shared_file(
                    117:         vm_offset_t     mapped_file,
                    118:         vm_size_t       mapped_file_size,
                    119:         vm_offset_t     *base_address,
                    120:         int             map_cnt,
                    121:         sf_mapping_t    *mappings,
                    122:         vm_object_t     file_object,
                    123:         int             *flags);
                    124: 
                    125: extern kern_return_t           
                    126: shared_file_init(               
                    127:         ipc_port_t      *shared_text_region_handle,
                    128:         vm_size_t       text_region_size,
                    129:         ipc_port_t      *shared_data_region_handle,
                    130:         vm_size_t       data_region_size, 
                    131:         vm_offset_t     *shared_file_mapping_array);
                    132: 
                    133: extern load_struct_t  *
                    134: lsf_hash_lookup(   
                    135:         queue_head_t    *hash_table,
                    136:         void           *file_object,  
                    137:         int            size,
                    138:        boolean_t       alternate);
                    139: 
                    140: extern load_struct_t *
                    141: lsf_hash_delete(
                    142:         void            *file_object);
                    143: 
                    144: extern void    
                    145: lsf_hash_insert(
                    146:         load_struct_t   *entry);
                    147: 
                    148: extern kern_return_t                   
                    149: lsf_load(
                    150:         vm_offset_t     mapped_file,
                    151:         vm_size_t       mapped_file_size,
                    152:         vm_offset_t     *base_address,
                    153:         sf_mapping_t    *mappings,
                    154:         int             map_cnt,
                    155:         void            *file_object,
                    156:         int             flags);
                    157: 
                    158: extern void
                    159: lsf_unload(
                    160:         void     *file_object);
                    161: 
                    162: #endif /* MACH_KERNEL_PRIVATE */
                    163: #endif /* _SHARED_MEMORY_SERVER_H_ */

unix.superglobalmegacorp.com

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