]> git.saurik.com Git - apple/xnu.git/blame - osfmk/vm/vm_shared_memory_server.h
xnu-344.34.tar.gz
[apple/xnu.git] / osfmk / vm / vm_shared_memory_server.h
CommitLineData
9bccf70c
A
1/*
2 * Copyright (c) 2002,2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
de355530
A
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.
9bccf70c 11 *
de355530
A
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
9bccf70c
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
de355530
A
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.
9bccf70c
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 *
24 * File: vm/vm_shared_memory_server.h
25 *
26 * protos and struct definitions for shared library
27 * server and interface
28 */
29
30#ifndef _VM_SHARED_MEMORY_SERVER_H_
31#define _VM_SHARED_MEMORY_SERVER_H_
32
33#include <sys/appleapiopts.h>
34
35#ifdef __APPLE_API_PRIVATE
36
37#include <mach/vm_prot.h>
38#include <mach/mach_types.h>
39#include <mach/shared_memory_server.h>
40
41#include <kern/kern_types.h>
42
43extern mach_port_t shared_text_region_handle;
44extern mach_port_t shared_data_region_handle;
45
46struct shared_region_task_mappings {
47 mach_port_t text_region;
48 vm_size_t text_size;
49 mach_port_t data_region;
50 vm_size_t data_size;
51 vm_offset_t region_mappings;
52 vm_offset_t client_base;
53 vm_offset_t alternate_base;
54 vm_offset_t alternate_next;
55 int flags;
56 vm_offset_t self;
57};
58
de355530
A
59#define SHARED_REGION_SYSTEM 0x1
60#define SHARED_REGION_FULL 0x2
9bccf70c
A
61
62typedef struct shared_region_task_mappings *shared_region_task_mappings_t;
63typedef struct shared_region_mapping *shared_region_mapping_t;
64
65
66#ifdef MACH_KERNEL_PRIVATE
67
68#include <kern/queue.h>
69#include <vm/vm_object.h>
70#include <vm/memory_object.h>
71
72extern vm_offset_t shared_file_mapping_array;
73
74struct loaded_mapping {
75 vm_offset_t mapping_offset;
76 vm_size_t size;
77 vm_offset_t file_offset;
78 vm_prot_t protection; /* read/write/execute/COW/ZF */
79
80 struct loaded_mapping *next;
81};
82
83typedef struct loaded_mapping loaded_mapping_t;
84
85struct load_struct {
86 queue_chain_t links;
87 shared_region_mapping_t regions_instance;
88 int depth;
89 int file_object;
90 vm_offset_t base_address;
91 int mapping_cnt;
92 loaded_mapping_t *mappings;
93};
94
95typedef struct load_struct load_struct_t;
96typedef struct load_struct *load_struct_ptr_t;
97
98struct load_file_ele {
99 union {
100 sf_mapping_t mapping;
101 load_struct_t element;
102 } u;
103};
104
105struct shared_file_info {
106 mutex_t lock; /* lock for the structure */
107 queue_head_t *hash; /* for later perf enhance */
108 int hash_size;
109 boolean_t hash_init;
110};
111
112typedef struct shared_file_info shared_file_info_t;
113
114struct shared_region_object_chain {
115 shared_region_mapping_t object_chain_region;
116 int depth;
117 struct shared_region_object_chain *next;
118};
119typedef struct shared_region_object_chain *shared_region_object_chain_t;
120
121/* address space shared region descriptor */
122struct shared_region_mapping {
123 decl_mutex_data(, Lock) /* Synchronization */
124 int ref_count;
125 mach_port_t text_region;
126 vm_size_t text_size;
127 mach_port_t data_region;
128 vm_size_t data_size;
129 vm_offset_t region_mappings;
130 vm_offset_t client_base;
131 vm_offset_t alternate_base;
132 vm_offset_t alternate_next;
133 int flags;
134 int depth;
135 shared_region_object_chain_t object_chain;
136 shared_region_mapping_t self;
137 shared_region_mapping_t next;
138};
139
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)
144
145#else /* !MACH_KERNEL_PRIVATE */
146
147struct shared_region_mapping ;
148
149#endif /* MACH_KERNEL_PRIVATE */
150
151extern 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,
155 int map_cnt,
156 sf_mapping_t *mappings,
157 memory_object_control_t file_control,
158 shared_region_task_mappings_t shared_region,
159 int *flags);
160
161extern 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,
171 int *flags,
172 shared_region_mapping_t *next);
173
174extern kern_return_t shared_region_mapping_create(
175 mach_port_t text_region,
176 vm_size_t text_size,
177 mach_port_t data_region,
178 vm_size_t data_size,
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);
184
185extern kern_return_t shared_region_mapping_ref(
186 shared_region_mapping_t shared_region);
187
188extern kern_return_t shared_region_mapping_dealloc(
189 shared_region_mapping_t shared_region);
190
191extern kern_return_t shared_region_object_chain_attach(
192 shared_region_mapping_t target_region,
193 shared_region_mapping_t object_chain);
194
195extern kern_return_t vm_get_shared_region(
196 task_t task,
197 shared_region_mapping_t *shared_region);
198
199extern kern_return_t vm_set_shared_region(
200 task_t task,
201 shared_region_mapping_t shared_region);
202
203extern unsigned int lsf_mapping_pool_gauge();
204
205#endif /* __APPLE_API_PRIVATE */
206
207#endif /* _VM_SHARED_MEMORY_SERVER_H_ */