]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/arm/vm_param.h
915e237e6a1b99379cf09e57d3e493544594aab1
[apple/xnu.git] / osfmk / mach / arm / vm_param.h
1 /*
2 * Copyright (c) 2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * FILE_ID: vm_param.h
30 */
31
32 /*
33 * ARM machine dependent virtual memory parameters.
34 */
35
36 #ifndef _MACH_ARM_VM_PARAM_H_
37 #define _MACH_ARM_VM_PARAM_H_
38
39 #if defined(KERNEL_PRIVATE) && __ARM_16K_PG__
40 #include <arm64/proc_reg.h>
41 #endif
42
43 #if !defined (KERNEL) && !defined (__ASSEMBLER__)
44 #include <mach/vm_page_size.h>
45 #endif
46
47 #define BYTE_SIZE 8 /* byte size in bits */
48
49 #if defined (KERNEL)
50
51 #ifndef __ASSEMBLER__
52
53 #ifdef __arm__
54 #define PAGE_SHIFT_CONST 12
55 #elif defined(__arm64__)
56 extern unsigned PAGE_SHIFT_CONST;
57 #else
58 #error Unsupported arch
59 #endif
60
61 #if defined(KERNEL_PRIVATE) && __ARM_16K_PG__
62 #define PAGE_SHIFT ARM_PGSHIFT
63 #else
64 #define PAGE_SHIFT PAGE_SHIFT_CONST
65 #endif
66 #define PAGE_SIZE (1 << PAGE_SHIFT)
67 #define PAGE_MASK (PAGE_SIZE-1)
68
69 #define VM_PAGE_SIZE PAGE_SIZE
70
71 #define machine_ptob(x) ((x) << PAGE_SHIFT)
72
73 /*
74 * Defined for the purpose of testing the pmap advertised page
75 * size; this does not necessarily match the hardware page size.
76 */
77 #define TEST_PAGE_SIZE_16K ((PAGE_SHIFT_CONST == 14))
78 #define TEST_PAGE_SIZE_4K ((PAGE_SHIFT_CONST == 12))
79
80 #endif /* !__ASSEMBLER__ */
81
82 #else
83
84 #define PAGE_SHIFT vm_page_shift
85 #define PAGE_SIZE vm_page_size
86 #define PAGE_MASK vm_page_mask
87
88 #define VM_PAGE_SIZE vm_page_size
89
90 #define machine_ptob(x) ((x) << PAGE_SHIFT)
91
92 #endif
93
94 #define PAGE_MAX_SHIFT 14
95 #define PAGE_MAX_SIZE (1 << PAGE_MAX_SHIFT)
96 #define PAGE_MAX_MASK (PAGE_MAX_SIZE-1)
97
98 #define PAGE_MIN_SHIFT 12
99 #define PAGE_MIN_SIZE (1 << PAGE_MIN_SHIFT)
100 #define PAGE_MIN_MASK (PAGE_MIN_SIZE-1)
101
102 #ifndef __ASSEMBLER__
103
104 #ifdef MACH_KERNEL_PRIVATE
105
106 #define VM32_SUPPORT 1
107 #define VM32_MIN_ADDRESS ((vm32_offset_t) 0)
108 #define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
109 #define VM_MAX_PAGE_ADDRESS VM_MAX_ADDRESS /* ARM64_TODO: ?? */
110
111 /*
112 * kalloc() parameters:
113 *
114 * Historically kalloc's underlying zones were power-of-2 sizes, with a
115 * KALLOC_MINSIZE of 16 bytes. Thus the allocator ensured that
116 * (sizeof == alignof) >= 16 for all kalloc allocations.
117 *
118 * Today kalloc may use zones with intermediate (small) sizes, constrained by
119 * KALLOC_MINSIZE and a minimum alignment, expressed by KALLOC_LOG2_MINALIGN.
120 *
121 * Note that most dynamically allocated data structures contain more than
122 * one int/long/pointer member, so KALLOC_MINSIZE should probably start at 8.
123 */
124
125 #if defined (__arm__)
126
127 #define KALLOC_MINSIZE 8 /* minimum allocation size */
128 #define KALLOC_LOG2_MINALIGN 3 /* log2 minimum alignment */
129
130 #elif defined(__arm64__)
131
132 #define KALLOC_MINSIZE 16 /* minimum allocation size */
133 #define KALLOC_LOG2_MINALIGN 4 /* log2 minimum alignment */
134
135 #else
136 #error Unsupported arch
137 #endif
138
139 #endif
140
141 #if defined (__arm__)
142
143 #define VM_MIN_ADDRESS ((vm_address_t) 0x00000000)
144 #define VM_MAX_ADDRESS ((vm_address_t) 0x80000000)
145
146 /* system-wide values */
147 #define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0)
148 #define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_ADDRESS)
149
150 #elif defined (__arm64__)
151
152 #define VM_MIN_ADDRESS ((vm_address_t) 0x0000000000000000ULL)
153 #define VM_MAX_ADDRESS ((vm_address_t) 0x0000000080000000ULL)
154
155 /* system-wide values */
156 #define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0x0ULL)
157 #define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) 0x0000000FC0000000ULL)
158
159 #else
160 #error architecture not supported
161 #endif
162
163 #define VM_MAP_MIN_ADDRESS VM_MIN_ADDRESS
164 #define VM_MAP_MAX_ADDRESS VM_MAX_ADDRESS
165
166 #ifdef KERNEL
167
168 #if defined (__arm__)
169 #define VM_MIN_KERNEL_ADDRESS ((vm_address_t) 0x80000000)
170 #define VM_MAX_KERNEL_ADDRESS ((vm_address_t) 0xFFFEFFFF)
171 #define VM_HIGH_KERNEL_WINDOW ((vm_address_t) 0xFFFE0000)
172 #elif defined (__arm64__)
173 /*
174 * The minimum and maximum kernel address; some configurations may
175 * constrain the address space further.
176 */
177 #define VM_MIN_KERNEL_ADDRESS ((vm_address_t) 0xffffffe000000000ULL)
178 #define VM_MAX_KERNEL_ADDRESS ((vm_address_t) 0xfffffff3ffffffffULL)
179 #else
180 #error architecture not supported
181 #endif
182
183 #define VM_MIN_KERNEL_AND_KEXT_ADDRESS \
184 VM_MIN_KERNEL_ADDRESS
185
186 #define VM_KERNEL_ADDRESS(va) ((((vm_address_t)(va))>=VM_MIN_KERNEL_ADDRESS) && \
187 (((vm_address_t)(va))<=VM_MAX_KERNEL_ADDRESS))
188
189 #ifdef MACH_KERNEL_PRIVATE
190 /*
191 * Physical memory is mapped linearly at an offset virtual memory.
192 */
193 extern unsigned long gVirtBase, gPhysBase, gPhysSize;
194
195 #define isphysmem(a) (((vm_address_t)(a) - gPhysBase) < gPhysSize)
196 #define phystokv(a) ((vm_address_t)(a) - gPhysBase + gVirtBase)
197
198 #if KASAN
199 /* Increase the stack sizes to account for the redzones that get added to every
200 * stack object. */
201 # define KERNEL_STACK_SIZE (4*4*4096)
202 # define INTSTACK_SIZE (4*4*4096)
203 #else
204 # define KERNEL_STACK_SIZE (4*4096)
205 # define INTSTACK_SIZE (4*4096)
206 #endif
207
208 #if defined (__arm__)
209 #define HIGH_EXC_VECTORS ((vm_address_t) 0xFFFF0000)
210 #endif
211
212 #endif /* MACH_KERNEL_PRIVATE */
213 #endif /* KERNEL */
214
215 #endif /* !__ASSEMBLER__ */
216
217 #define SWI_SYSCALL 0x80
218
219 #endif /* _MACH_ARM_VM_PARAM_H_ */