2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
24 * File: kern/shared_memory_server.h
26 * protos and struct definitions for shared library
27 * server and interface
29 #ifndef _SHARED_MEMORY_SERVER_H_
30 #define _SHARED_MEMORY_SERVER_H_
32 #define SHARED_TEXT_REGION_SIZE 0x10000000
33 #define SHARED_DATA_REGION_SIZE 0x10000000
35 * Note: the two masks below are useful because the assumption is
36 * made that these shared regions will always be mapped on natural boundaries
37 * i.e. if the size is 0x10000000 the object can be mapped at
38 * 0x20000000, or 0x30000000, but not 0x1000000
40 #define SHARED_TEXT_REGION_MASK 0xFFFFFFF
41 #define SHARED_DATA_REGION_MASK 0xFFFFFFF
43 #define SHARED_ALTERNATE_LOAD_BASE 0x9000000
45 #include <mach/vm_prot.h>
47 #include <mach/mach.h>
49 #include <vm/vm_map.h>
52 #ifdef MACH_KERNEL_PRIVATE
54 #include <kern/queue.h>
55 #include <vm/vm_object.h>
57 extern ipc_port_t shared_text_region_handle
;
58 extern ipc_port_t shared_data_region_handle
;
59 #else /* MACH_KERNEL_PRIVATE */
62 extern mach_port_t shared_text_region_handle
;
63 extern mach_port_t shared_data_region_handle
;
65 #endif /* MACH_KERNEL_PRIVATE*/
69 extern vm_offset_t shared_file_mapping_array
;
72 struct shared_region_task_mappings
{
73 ipc_port_t text_region
;
75 ipc_port_t data_region
;
77 vm_offset_t region_mappings
;
78 vm_offset_t client_base
;
79 vm_offset_t alternate_base
;
80 vm_offset_t alternate_next
;
85 #define SHARED_REGION_SYSTEM 0x1
86 #define SHARED_REGION_FULL 0x2
88 typedef struct shared_region_task_mappings
*shared_region_task_mappings_t
;
89 #endif /* KERNEL_PRIVATE */
92 #define SHARED_LIB_ALIAS 0x10
95 /* flags field aliases for copyin_shared_file and load_shared_file */
98 #define ALTERNATE_LOAD_SITE 0x1
99 #define NEW_LOCAL_SHARED_REGIONS 0x2
102 #define SF_PREV_LOADED 0x1
105 #define load_file_hash(file_object, size) \
106 ((((natural_t)file_object) & 0xffffff) % size)
108 #define VM_PROT_COW 0x8 /* must not interfere with normal prot assignments */
109 #define VM_PROT_ZF 0x10 /* must not interfere with normal prot assignments */
112 vm_offset_t mapping_offset
;
114 vm_offset_t file_offset
;
115 vm_prot_t protection
; /* read/write/execute/COW/ZF */
119 typedef struct sf_mapping sf_mapping_t
;
122 #ifdef MACH_KERNEL_PRIVATE
124 struct loaded_mapping
{
125 vm_offset_t mapping_offset
;
127 vm_offset_t file_offset
;
128 vm_prot_t protection
; /* read/write/execute/COW/ZF */
130 struct loaded_mapping
*next
;
133 typedef struct loaded_mapping loaded_mapping_t
;
137 shared_region_mapping_t regions_instance
;
140 vm_offset_t base_address
;
142 loaded_mapping_t
*mappings
;
145 #endif /* MACH_KERNEL_PRIVATE */
147 typedef struct load_struct load_struct_t
;
148 typedef struct load_struct
*load_struct_ptr_t
;
150 #ifdef MACH_KERNEL_PRIVATE
152 struct load_file_ele
{
154 sf_mapping_t mapping
;
155 load_struct_t element
;
159 struct shared_file_info
{
160 mutex_t lock
; /* lock for the structure */
161 queue_head_t
*hash
; /* for later perf enhance */
166 typedef struct shared_file_info shared_file_info_t
;
170 vm_offset_t mapped_file
,
171 vm_size_t mapped_file_size
,
172 vm_offset_t
*base_address
,
174 sf_mapping_t
*mappings
,
175 vm_object_t file_object
,
176 shared_region_task_mappings_t shared_region
,
181 ipc_port_t
*shared_text_region_handle
,
182 vm_size_t text_region_size
,
183 ipc_port_t
*shared_data_region_handle
,
184 vm_size_t data_region_size
,
185 vm_offset_t
*shared_file_mapping_array
);
187 extern load_struct_t
*
189 queue_head_t
*hash_table
,
193 shared_region_task_mappings_t sm_info
);
195 extern load_struct_t
*
198 vm_offset_t base_offset
,
199 shared_region_task_mappings_t sm_info
);
203 load_struct_t
*entry
,
204 shared_region_task_mappings_t sm_info
);
208 vm_offset_t mapped_file
,
209 vm_size_t mapped_file_size
,
210 vm_offset_t
*base_address
,
211 sf_mapping_t
*mappings
,
215 shared_region_task_mappings_t sm_info
);
220 vm_offset_t base_offset
,
221 shared_region_task_mappings_t sm_info
);
223 #endif /* MACH_KERNEL_PRIVATE */
224 #endif /* _SHARED_MEMORY_SERVER_H_ */