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: mach/shared_region.h
27 * protos and struct definitions for shared region
30 #ifndef _MACH_SHARED_REGION_H_
31 #define _MACH_SHARED_REGION_H_
33 #include <sys/cdefs.h>
34 #include <mach/vm_prot.h>
35 #include <mach/vm_types.h>
36 #include <mach/mach_types.h>
38 #define SHARED_REGION_BASE_I386 0x90000000ULL
39 #define SHARED_REGION_SIZE_I386 0x20000000ULL
40 #define SHARED_REGION_NESTING_BASE_I386 0x90000000ULL
41 #define SHARED_REGION_NESTING_SIZE_I386 0x20000000ULL
42 #define SHARED_REGION_NESTING_MIN_I386 0x00200000ULL
43 #define SHARED_REGION_NESTING_MAX_I386 0xFFE00000ULL
45 #define SHARED_REGION_BASE_X86_64 0x00007FFF00000000ULL
46 #define SHARED_REGION_SIZE_X86_64 0x00000000FFE00000ULL
47 #define SHARED_REGION_NESTING_BASE_X86_64 0x00007FFF00000000ULL
48 #define SHARED_REGION_NESTING_SIZE_X86_64 0x00000000FFE00000ULL
49 #define SHARED_REGION_NESTING_MIN_X86_64 0x0000000000200000ULL
50 #define SHARED_REGION_NESTING_MAX_X86_64 0xFFFFFFFFFFE00000ULL
52 #define SHARED_REGION_BASE_PPC 0x90000000ULL
53 #define SHARED_REGION_SIZE_PPC 0x20000000ULL
54 #define SHARED_REGION_NESTING_BASE_PPC 0x90000000ULL
55 #define SHARED_REGION_NESTING_SIZE_PPC 0x10000000ULL
56 #define SHARED_REGION_NESTING_MIN_PPC 0x10000000ULL
57 #define SHARED_REGION_NESTING_MAX_PPC 0x10000000ULL
59 #define SHARED_REGION_BASE_PPC64 0x00007FFF60000000ULL
60 #define SHARED_REGION_SIZE_PPC64 0x00000000A0000000ULL
61 #define SHARED_REGION_NESTING_BASE_PPC64 0x00007FFF60000000ULL
62 #define SHARED_REGION_NESTING_SIZE_PPC64 0x00000000A0000000ULL
63 #define SHARED_REGION_NESTING_MIN_PPC64 0x0000000010000000ULL
64 #define SHARED_REGION_NESTING_MAX_PPC64 0x0000000010000000ULL
66 #define SHARED_REGION_BASE_ARM 0x40000000ULL
67 #define SHARED_REGION_SIZE_ARM 0x40000000ULL
68 #define SHARED_REGION_NESTING_BASE_ARM 0x40000000ULL
69 #define SHARED_REGION_NESTING_SIZE_ARM 0x40000000ULL
70 #define SHARED_REGION_NESTING_MIN_ARM ?
71 #define SHARED_REGION_NESTING_MAX_ARM ?
73 #define SHARED_REGION_BASE_ARM64_32 0x1A000000ULL
74 #define SHARED_REGION_SIZE_ARM64_32 0x40000000ULL
75 #define SHARED_REGION_NESTING_BASE_ARM64_32 0x1A000000ULL
76 #define SHARED_REGION_NESTING_SIZE_ARM64_32 0x40000000ULL
77 #define SHARED_REGION_NESTING_MIN_ARM64_32 ?
78 #define SHARED_REGION_NESTING_MAX_ARM64_32 ?
80 #ifdef XNU_KERNEL_PRIVATE
81 /* ARM64_TODO: move to higher memory */
83 #define SHARED_REGION_BASE_ARM64 0x180000000ULL
84 #define SHARED_REGION_SIZE_ARM64 0x100000000ULL
85 #define SHARED_REGION_NESTING_BASE_ARM64 0x180000000ULL
86 #define SHARED_REGION_NESTING_SIZE_ARM64 0x100000000ULL
87 #define SHARED_REGION_NESTING_MIN_ARM64 ?
88 #define SHARED_REGION_NESTING_MAX_ARM64 ?
91 #define SHARED_REGION_BASE SHARED_REGION_BASE_I386
92 #define SHARED_REGION_SIZE SHARED_REGION_SIZE_I386
93 #define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_I386
94 #define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_I386
95 #define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_I386
96 #define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_I386
97 #elif defined(__x86_64__)
98 #define SHARED_REGION_BASE SHARED_REGION_BASE_X86_64
99 #define SHARED_REGION_SIZE SHARED_REGION_SIZE_X86_64
100 #define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_X86_64
101 #define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_X86_64
102 #define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_X86_64
103 #define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_X86_64
104 #elif defined(__arm__)
105 #define SHARED_REGION_BASE SHARED_REGION_BASE_ARM
106 #define SHARED_REGION_SIZE SHARED_REGION_SIZE_ARM
107 #define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_ARM
108 #define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_ARM
109 #define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_ARM
110 #define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_ARM
111 #elif defined(__arm64__) && !defined(__LP64__)
112 #define SHARED_REGION_BASE SHARED_REGION_BASE_ARM64_32
113 #define SHARED_REGION_SIZE SHARED_REGION_SIZE_ARM64_32
114 #define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_ARM64_32
115 #define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_ARM64_32
116 #define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_ARM64_32
117 #define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_ARM64_32
118 #elif defined(__arm64__) && defined(__LP64__)
119 #define SHARED_REGION_BASE SHARED_REGION_BASE_ARM64
120 #define SHARED_REGION_SIZE SHARED_REGION_SIZE_ARM64
121 #define SHARED_REGION_NESTING_BASE SHARED_REGION_NESTING_BASE_ARM64
122 #define SHARED_REGION_NESTING_SIZE SHARED_REGION_NESTING_SIZE_ARM64
123 #define SHARED_REGION_NESTING_MIN SHARED_REGION_NESTING_MIN_ARM64
124 #define SHARED_REGION_NESTING_MAX SHARED_REGION_NESTING_MAX_ARM64
127 #ifdef KERNEL_PRIVATE
130 * This is routine sets the current source of power.
132 * 0 if it is external source (connected to power )
133 * 1 if it is internal power source ie battery
136 void post_sys_powersource(int);
138 #endif /* KERNEL_PRIVATE */
140 * All shared_region_* declarations are a private interface
141 * between dyld and the kernel.
144 struct shared_file_mapping_np
{
145 mach_vm_address_t sfm_address
;
146 mach_vm_size_t sfm_size
;
147 mach_vm_offset_t sfm_file_offset
;
148 vm_prot_t sfm_max_prot
;
149 vm_prot_t sfm_init_prot
;
151 #define VM_PROT_COW 0x8 /* must not interfere with normal prot assignments */
152 #define VM_PROT_ZF 0x10 /* must not interfere with normal prot assignments */
153 #define VM_PROT_SLIDE 0x20 /* must not interfere with normal prot assignments */
158 int shared_region_check_np(uint64_t *startaddress
);
159 int shared_region_map_np(int fd
,
160 uint32_t mappingCount
,
161 const struct shared_file_mapping_np
*mappings
);
162 int shared_region_slide_np(void);
167 #endif /* _MACH_SHARED_REGION_H_ */