2 * Copyright (c) 2002,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: vm/vm_shared_memory_server.h
26 * protos and struct definitions for shared library
27 * server and interface
30 #ifndef _VM_SHARED_MEMORY_SERVER_H_
31 #define _VM_SHARED_MEMORY_SERVER_H_
33 #include <sys/appleapiopts.h>
35 #ifdef __APPLE_API_PRIVATE
37 #include <mach/vm_prot.h>
38 #include <mach/mach_types.h>
39 #include <mach/shared_memory_server.h>
41 #include <kern/kern_types.h>
43 extern mach_port_t shared_text_region_handle
;
44 extern mach_port_t shared_data_region_handle
;
46 struct shared_region_task_mappings
{
47 mach_port_t text_region
;
49 mach_port_t data_region
;
51 vm_offset_t region_mappings
;
52 vm_offset_t client_base
;
53 vm_offset_t alternate_base
;
54 vm_offset_t alternate_next
;
59 #define SHARED_REGION_SYSTEM 0x1
60 #define SHARED_REGION_FULL 0x2
62 typedef struct shared_region_task_mappings
*shared_region_task_mappings_t
;
63 typedef struct shared_region_mapping
*shared_region_mapping_t
;
66 #ifdef MACH_KERNEL_PRIVATE
68 #include <kern/queue.h>
69 #include <vm/vm_object.h>
70 #include <vm/memory_object.h>
72 extern vm_offset_t shared_file_mapping_array
;
74 struct loaded_mapping
{
75 vm_offset_t mapping_offset
;
77 vm_offset_t file_offset
;
78 vm_prot_t protection
; /* read/write/execute/COW/ZF */
80 struct loaded_mapping
*next
;
83 typedef struct loaded_mapping loaded_mapping_t
;
87 shared_region_mapping_t regions_instance
;
90 vm_offset_t base_address
;
92 loaded_mapping_t
*mappings
;
95 typedef struct load_struct load_struct_t
;
96 typedef struct load_struct
*load_struct_ptr_t
;
98 struct load_file_ele
{
100 sf_mapping_t mapping
;
101 load_struct_t element
;
105 struct shared_file_info
{
106 mutex_t lock
; /* lock for the structure */
107 queue_head_t
*hash
; /* for later perf enhance */
112 typedef struct shared_file_info shared_file_info_t
;
114 struct shared_region_object_chain
{
115 shared_region_mapping_t object_chain_region
;
117 struct shared_region_object_chain
*next
;
119 typedef struct shared_region_object_chain
*shared_region_object_chain_t
;
121 /* address space shared region descriptor */
122 struct shared_region_mapping
{
123 decl_mutex_data(, Lock
) /* Synchronization */
125 mach_port_t text_region
;
127 mach_port_t data_region
;
129 vm_offset_t region_mappings
;
130 vm_offset_t client_base
;
131 vm_offset_t alternate_base
;
132 vm_offset_t alternate_next
;
135 shared_region_object_chain_t object_chain
;
136 shared_region_mapping_t self
;
137 shared_region_mapping_t next
;
140 #define shared_region_mapping_lock_init(object) \
141 mutex_init(&(object)->Lock, ETAP_VM_OBJ)
142 #define shared_region_mapping_lock(object) mutex_lock(&(object)->Lock)
143 #define shared_region_mapping_unlock(object) mutex_unlock(&(object)->Lock)
145 #else /* !MACH_KERNEL_PRIVATE */
147 struct shared_region_mapping
;
149 #endif /* MACH_KERNEL_PRIVATE */
151 extern kern_return_t
copyin_shared_file(
152 vm_offset_t mapped_file
,
153 vm_size_t mapped_file_size
,
154 vm_offset_t
*base_address
,
156 sf_mapping_t
*mappings
,
157 memory_object_control_t file_control
,
158 shared_region_task_mappings_t shared_region
,
161 extern kern_return_t
shared_region_mapping_info(
162 shared_region_mapping_t shared_region
,
163 mach_port_t
*text_region
,
164 vm_size_t
*text_size
,
165 mach_port_t
*data_region
,
166 vm_size_t
*data_size
,
167 vm_offset_t
*region_mappings
,
168 vm_offset_t
*client_base
,
169 vm_offset_t
*alternate_base
,
170 vm_offset_t
*alternate_next
,
172 shared_region_mapping_t
*next
);
174 extern kern_return_t
shared_region_mapping_create(
175 mach_port_t text_region
,
177 mach_port_t data_region
,
179 vm_offset_t region_mappings
,
180 vm_offset_t client_base
,
181 shared_region_mapping_t
*shared_region
,
182 vm_offset_t alt_base
,
183 vm_offset_t alt_next
);
185 extern kern_return_t
shared_region_mapping_ref(
186 shared_region_mapping_t shared_region
);
188 extern kern_return_t
shared_region_mapping_dealloc(
189 shared_region_mapping_t shared_region
);
191 extern kern_return_t
shared_region_object_chain_attach(
192 shared_region_mapping_t target_region
,
193 shared_region_mapping_t object_chain
);
195 extern kern_return_t
vm_get_shared_region(
197 shared_region_mapping_t
*shared_region
);
199 extern kern_return_t
vm_set_shared_region(
201 shared_region_mapping_t shared_region
);
203 extern unsigned int lsf_mapping_pool_gauge();
205 #endif /* __APPLE_API_PRIVATE */
207 #endif /* _VM_SHARED_MEMORY_SERVER_H_ */