2 * Copyright (c) 2002,2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
27 * File: vm/vm_shared_memory_server.h
29 * protos and struct definitions for shared library
30 * server and interface
33 #ifndef _VM_SHARED_MEMORY_SERVER_H_
34 #define _VM_SHARED_MEMORY_SERVER_H_
36 #include <sys/appleapiopts.h>
38 #ifdef __APPLE_API_PRIVATE
40 #include <mach/vm_prot.h>
41 #include <mach/mach_types.h>
42 #include <mach/shared_memory_server.h>
44 #include <kern/kern_types.h>
46 extern mach_port_t shared_text_region_handle
;
47 extern mach_port_t shared_data_region_handle
;
49 struct shared_region_task_mappings
{
50 mach_port_t text_region
;
52 mach_port_t data_region
;
54 vm_offset_t region_mappings
;
55 vm_offset_t client_base
;
56 vm_offset_t alternate_base
;
57 vm_offset_t alternate_next
;
62 #define SHARED_REGION_SYSTEM 0x1
63 #define SHARED_REGION_FULL 0x2
65 typedef struct shared_region_task_mappings
*shared_region_task_mappings_t
;
66 typedef struct shared_region_mapping
*shared_region_mapping_t
;
69 #ifdef MACH_KERNEL_PRIVATE
71 #include <kern/queue.h>
72 #include <vm/vm_object.h>
73 #include <vm/memory_object.h>
75 extern vm_offset_t shared_file_mapping_array
;
77 struct loaded_mapping
{
78 vm_offset_t mapping_offset
;
80 vm_offset_t file_offset
;
81 vm_prot_t protection
; /* read/write/execute/COW/ZF */
83 struct loaded_mapping
*next
;
86 typedef struct loaded_mapping loaded_mapping_t
;
90 shared_region_mapping_t regions_instance
;
93 vm_offset_t base_address
;
95 loaded_mapping_t
*mappings
;
98 typedef struct load_struct load_struct_t
;
99 typedef struct load_struct
*load_struct_ptr_t
;
101 struct load_file_ele
{
103 sf_mapping_t mapping
;
104 load_struct_t element
;
108 struct shared_file_info
{
109 mutex_t lock
; /* lock for the structure */
110 queue_head_t
*hash
; /* for later perf enhance */
115 typedef struct shared_file_info shared_file_info_t
;
117 struct shared_region_object_chain
{
118 shared_region_mapping_t object_chain_region
;
120 struct shared_region_object_chain
*next
;
122 typedef struct shared_region_object_chain
*shared_region_object_chain_t
;
124 /* address space shared region descriptor */
125 struct shared_region_mapping
{
126 decl_mutex_data(, Lock
) /* Synchronization */
128 mach_port_t text_region
;
130 mach_port_t data_region
;
132 vm_offset_t region_mappings
;
133 vm_offset_t client_base
;
134 vm_offset_t alternate_base
;
135 vm_offset_t alternate_next
;
138 shared_region_object_chain_t object_chain
;
139 shared_region_mapping_t self
;
140 shared_region_mapping_t next
;
143 #define shared_region_mapping_lock_init(object) \
144 mutex_init(&(object)->Lock, ETAP_VM_OBJ)
145 #define shared_region_mapping_lock(object) mutex_lock(&(object)->Lock)
146 #define shared_region_mapping_unlock(object) mutex_unlock(&(object)->Lock)
148 #else /* !MACH_KERNEL_PRIVATE */
150 struct shared_region_mapping
;
152 #endif /* MACH_KERNEL_PRIVATE */
154 extern kern_return_t
copyin_shared_file(
155 vm_offset_t mapped_file
,
156 vm_size_t mapped_file_size
,
157 vm_offset_t
*base_address
,
159 sf_mapping_t
*mappings
,
160 memory_object_control_t file_control
,
161 shared_region_task_mappings_t shared_region
,
164 extern kern_return_t
shared_region_mapping_info(
165 shared_region_mapping_t shared_region
,
166 mach_port_t
*text_region
,
167 vm_size_t
*text_size
,
168 mach_port_t
*data_region
,
169 vm_size_t
*data_size
,
170 vm_offset_t
*region_mappings
,
171 vm_offset_t
*client_base
,
172 vm_offset_t
*alternate_base
,
173 vm_offset_t
*alternate_next
,
175 shared_region_mapping_t
*next
);
177 extern kern_return_t
shared_region_mapping_create(
178 mach_port_t text_region
,
180 mach_port_t data_region
,
182 vm_offset_t region_mappings
,
183 vm_offset_t client_base
,
184 shared_region_mapping_t
*shared_region
,
185 vm_offset_t alt_base
,
186 vm_offset_t alt_next
);
188 extern kern_return_t
shared_region_mapping_ref(
189 shared_region_mapping_t shared_region
);
191 extern kern_return_t
shared_region_mapping_dealloc(
192 shared_region_mapping_t shared_region
);
194 extern kern_return_t
shared_region_object_chain_attach(
195 shared_region_mapping_t target_region
,
196 shared_region_mapping_t object_chain
);
198 extern kern_return_t
vm_get_shared_region(
200 shared_region_mapping_t
*shared_region
);
202 extern kern_return_t
vm_set_shared_region(
204 shared_region_mapping_t shared_region
);
206 extern unsigned int lsf_mapping_pool_gauge();
208 #endif /* __APPLE_API_PRIVATE */
210 #endif /* _VM_SHARED_MEMORY_SERVER_H_ */