]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/i386/vm_param.h
0a3a2127c8ffd424695c953a0fa707e624c79cd9
[apple/xnu.git] / osfmk / mach / i386 / vm_param.h
1 /*
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * @OSF_COPYRIGHT@
32 */
33 /*
34 * Mach Operating System
35 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
36 * All Rights Reserved.
37 *
38 * Permission to use, copy, modify and distribute this software and its
39 * documentation is hereby granted, provided that both the copyright
40 * notice and this permission notice appear in all copies of the
41 * software, derivative works or modified versions, and any portions
42 * thereof, and that both notices appear in supporting documentation.
43 *
44 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
45 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
46 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
47 *
48 * Carnegie Mellon requests users of this software to return to
49 *
50 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
51 * School of Computer Science
52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
54 *
55 * any improvements or extensions that they make and grant Carnegie Mellon
56 * the rights to redistribute these changes.
57 */
58
59 /*
60 * Copyright (c) 1994 The University of Utah and
61 * the Computer Systems Laboratory at the University of Utah (CSL).
62 * All rights reserved.
63 *
64 * Permission to use, copy, modify and distribute this software is hereby
65 * granted provided that (1) source code retains these copyright, permission,
66 * and disclaimer notices, and (2) redistributions including binaries
67 * reproduce the notices in supporting documentation, and (3) all advertising
68 * materials mentioning features or use of this software display the following
69 * acknowledgement: ``This product includes software developed by the
70 * Computer Systems Laboratory at the University of Utah.''
71 *
72 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
73 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
74 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
75 *
76 * CSL requests users of this software to return to csl-dist@cs.utah.edu any
77 * improvements that they make and grant CSL redistribution rights.
78 *
79 */
80
81 /*
82 * File: vm_param.h
83 * Author: Avadis Tevanian, Jr.
84 * Date: 1985
85 *
86 * I386 machine dependent virtual memory parameters.
87 * Most of the declarations are preceeded by I386_ (or i386_)
88 * which is OK because only I386 specific code will be using
89 * them.
90 */
91
92 #ifndef _MACH_I386_VM_PARAM_H_
93 #define _MACH_I386_VM_PARAM_H_
94
95 #define BYTE_SIZE 8 /* byte size in bits */
96
97 #define I386_PGBYTES 4096 /* bytes per 80386 page */
98 #define I386_PGSHIFT 12 /* number of bits to shift for pages */
99
100 #define PAGE_SIZE I386_PGBYTES
101 #define PAGE_SHIFT I386_PGSHIFT
102 #define PAGE_MASK (PAGE_SIZE - 1)
103
104 /*
105 * Convert bytes to pages and convert pages to bytes.
106 * No rounding is used.
107 */
108
109 #define i386_btop(x) (((pmap_paddr_t)(x)) >> I386_PGSHIFT)
110 #define machine_btop(x) i386_btop(x)
111 #define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT)
112
113 /*
114 * Round off or truncate to the nearest page. These will work
115 * for either addresses or counts. (i.e. 1 byte rounds to 1 page
116 * bytes.
117 */
118
119 #define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \
120 ~(I386_PGBYTES-1))
121 #define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1))
122
123
124
125 #define VM_MIN_ADDRESS64 ((user_addr_t) 0x0000000000000000ULL)
126 /*
127 * default top of user stack... it grows down from here
128 */
129 #define VM_USRSTACK64 ((user_addr_t) 0x00007FFF5FC00000ULL)
130 #define VM_DYLD64 ((user_addr_t) 0x00007FFF5FC00000ULL)
131 #define VM_LIB64_SHR_DATA ((user_addr_t) 0x00007FFF60000000ULL)
132 #define VM_LIB64_SHR_TEXT ((user_addr_t) 0x00007FFF80000000ULL)
133 /*
134 * the end of the usable user address space , for now about 47 bits.
135 * the 64 bit commpage is past the end of this
136 */
137 #define VM_MAX_PAGE_ADDRESS ((user_addr_t) 0x00007FFFFFE00000ULL)
138 /*
139 * canonical end of user address space for limits checking
140 */
141 #define VM_MAX_USER_PAGE_ADDRESS ((user_addr_t)0x00007FFFFFFFF000ULL)
142
143
144
145 /* system-wide values */
146 #define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0)
147 #define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_PAGE_ADDRESS)
148
149 /* process-relative values (all 32-bit legacy only for now) */
150 #define VM_MIN_ADDRESS ((vm_offset_t) 0)
151 #define VM_USRSTACK32 ((vm_offset_t) 0xC0000000)
152 #define VM_MAX_ADDRESS ((vm_offset_t) 0xFFE00000)
153
154
155
156
157 #ifdef KERNEL_PRIVATE
158
159 /* Kernel-wide values */
160 #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0x00001000U)
161 /*
162 * XXX
163 * The kernel max VM address is limited to 0xFF3FFFFF for now because
164 * some data structures are explicitly allocated at 0xFF400000 without
165 * VM's knowledge (see osfmk/i386/locore.s for the allocation of PTmap and co.).
166 * We can't let VM allocate memory from there.
167 */
168
169 #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFE7FFFFF)
170 #define KERNEL_STACK_SIZE (I386_PGBYTES*4)
171
172 #define VM_MAP_MIN_ADDRESS MACH_VM_MIN_ADDRESS
173 #define VM_MAP_MAX_ADDRESS MACH_VM_MAX_ADDRESS
174
175 /* FIXME - always leave like this? */
176 #define INTSTACK_SIZE (I386_PGBYTES*4)
177
178 #ifdef MACH_KERNEL_PRIVATE
179
180 /* For implementing legacy 32-bit interfaces */
181 #define VM32_SUPPORT
182 #define VM32_MIN_ADDRESS ((vm32_offset_t) 0)
183 #define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
184
185 #define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0x00000000)
186
187 #define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x00000000U)
188 #define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU)
189
190 #define NCOPY_WINDOWS 4
191
192 /*
193 * Conversion between 80386 pages and VM pages
194 */
195
196 #define trunc_i386_to_vm(p) (atop(trunc_page(i386_ptob(p))))
197 #define round_i386_to_vm(p) (atop(round_page(i386_ptob(p))))
198 #define vm_to_i386(p) (i386_btop(ptoa(p)))
199
200 #define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \
201 MACRO_BEGIN \
202 pmap_t __pmap = (pmap); \
203 vm_page_t __page = (page); \
204 vm_prot_t __prot__ = \
205 (protection) & ~(page)->page_lock; \
206 \
207 if (__pmap == kernel_pmap) { \
208 __prot__ |= VM_PROT_WRITE; \
209 } else { \
210 assert(!__page->encrypted); \
211 } \
212 \
213 pmap_enter( \
214 __pmap, \
215 (virtual_address), \
216 __page->phys_page, \
217 __prot__, \
218 flags, \
219 (wired) \
220 ); \
221 MACRO_END
222
223 #define IS_USERADDR64_CANONICAL(addr) \
224 ((addr) < (VM_MAX_USER_PAGE_ADDRESS + PAGE_SIZE))
225
226 #endif /* MACH_KERNEL_PRIVATE */
227
228 #endif /* KERNEL_PRIVATE */
229
230 #endif /* _MACH_I386_VM_PARAM_H_ */