2 * Copyright (c) 2007 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 * File: vm/vm_shared_region.h
27 * protos and struct definitions for shared region
30 #ifndef _VM_SHARED_REGION_H_
31 #define _VM_SHARED_REGION_H_
35 #include <mach/vm_prot.h>
36 #include <mach/mach_types.h>
37 #include <mach/shared_region.h>
39 #include <kern/kern_types.h>
40 #include <kern/macro_help.h>
42 #include <vm/vm_map.h>
44 extern int shared_region_version
;
45 extern int shared_region_persistence
;
48 extern int shared_region_debug
;
49 #define SHARED_REGION_DEBUG(args) \
51 if (shared_region_debug) { \
56 #define SHARED_REGION_DEBUG(args)
59 extern int shared_region_trace_level
;
60 #define SHARED_REGION_TRACE_NONE_LVL 0 /* no trace */
61 #define SHARED_REGION_TRACE_ERROR_LVL 1 /* trace abnormal events */
62 #define SHARED_REGION_TRACE_INFO_LVL 2 /* trace all events */
63 #define SHARED_REGION_TRACE_DEBUG_LVL 3 /* extra traces for debug */
64 #define SHARED_REGION_TRACE(level, args) \
66 if (shared_region_trace_level >= level) { \
70 #define SHARED_REGION_TRACE_NONE(args)
71 #define SHARED_REGION_TRACE_ERROR(args) \
73 SHARED_REGION_TRACE(SHARED_REGION_TRACE_ERROR_LVL, \
76 #define SHARED_REGION_TRACE_INFO(args) \
78 SHARED_REGION_TRACE(SHARED_REGION_TRACE_INFO_LVL, \
81 #define SHARED_REGION_TRACE_DEBUG(args) \
83 SHARED_REGION_TRACE(SHARED_REGION_TRACE_DEBUG_LVL, \
87 typedef struct vm_shared_region
*vm_shared_region_t
;
89 #ifdef MACH_KERNEL_PRIVATE
91 #include <kern/queue.h>
92 #include <vm/vm_object.h>
93 #include <vm/memory_object.h>
95 /* address space shared region descriptor */
96 struct vm_shared_region
{
97 uint32_t sr_ref_count
;
100 cpu_type_t sr_cpu_type
;
102 boolean_t sr_mapping_in_progress
;
103 boolean_t sr_persists
;
104 ipc_port_t sr_mem_entry
;
105 mach_vm_offset_t sr_first_mapping
;
106 mach_vm_offset_t sr_base_address
;
107 mach_vm_size_t sr_size
;
108 mach_vm_offset_t sr_pmap_nesting_start
;
109 mach_vm_size_t sr_pmap_nesting_size
;
110 thread_call_t sr_timer_call
;
113 #else /* !MACH_KERNEL_PRIVATE */
115 struct vm_shared_region
;
117 #endif /* MACH_KERNEL_PRIVATE */
119 extern void vm_shared_region_init(void);
120 extern kern_return_t
vm_shared_region_enter(
125 extern kern_return_t
vm_shared_region_remove(
128 extern vm_shared_region_t
vm_shared_region_get(
130 extern void vm_shared_region_deallocate(
131 struct vm_shared_region
*shared_region
);
132 extern mach_vm_offset_t
vm_shared_region_base_address(
133 struct vm_shared_region
*shared_region
);
134 extern mach_vm_size_t
vm_shared_region_size(
135 struct vm_shared_region
*shared_region
);
136 extern ipc_port_t
vm_shared_region_mem_entry(
137 struct vm_shared_region
*shared_region
);
138 extern void vm_shared_region_set(
140 struct vm_shared_region
*new_shared_region
);
141 extern vm_shared_region_t
vm_shared_region_lookup(
145 extern kern_return_t
vm_shared_region_start_address(
146 struct vm_shared_region
*shared_region
,
147 mach_vm_offset_t
*start_address
);
148 extern kern_return_t
vm_shared_region_map_file(
149 struct vm_shared_region
*shared_region
,
150 unsigned int mappings_count
,
151 struct shared_file_mapping_np
*mappings
,
152 memory_object_control_t file_control
,
153 memory_object_size_t file_size
,
156 extern void vm_commpage_init(void);
157 extern kern_return_t
vm_commpage_enter(
160 extern kern_return_t
vm_commpage_remove(
164 #endif /* KERNEL_PRIVATE */
166 #endif /* _VM_SHARED_REGION_H_ */