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