]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/i386/vm_param.h
0a3a2127c8ffd424695c953a0fa707e624c79cd9
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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. 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
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
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.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
34 * Mach Operating System
35 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
36 * All Rights Reserved.
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.
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.
48 * Carnegie Mellon requests users of this software to return to
50 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
51 * School of Computer Science
52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
55 * any improvements or extensions that they make and grant Carnegie Mellon
56 * the rights to redistribute these changes.
60 * Copyright (c) 1994 The University of Utah and
61 * the Computer Systems Laboratory at the University of Utah (CSL).
62 * All rights reserved.
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.''
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.
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.
83 * Author: Avadis Tevanian, Jr.
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
92 #ifndef _MACH_I386_VM_PARAM_H_
93 #define _MACH_I386_VM_PARAM_H_
95 #define BYTE_SIZE 8 /* byte size in bits */
97 #define I386_PGBYTES 4096 /* bytes per 80386 page */
98 #define I386_PGSHIFT 12 /* number of bits to shift for pages */
100 #define PAGE_SIZE I386_PGBYTES
101 #define PAGE_SHIFT I386_PGSHIFT
102 #define PAGE_MASK (PAGE_SIZE - 1)
105 * Convert bytes to pages and convert pages to bytes.
106 * No rounding is used.
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)
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
119 #define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \
121 #define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1))
125 #define VM_MIN_ADDRESS64 ((user_addr_t) 0x0000000000000000ULL)
127 * default top of user stack... it grows down from here
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)
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
137 #define VM_MAX_PAGE_ADDRESS ((user_addr_t) 0x00007FFFFFE00000ULL)
139 * canonical end of user address space for limits checking
141 #define VM_MAX_USER_PAGE_ADDRESS ((user_addr_t)0x00007FFFFFFFF000ULL)
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)
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)
157 #ifdef KERNEL_PRIVATE
159 /* Kernel-wide values */
160 #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0x00001000U)
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.
169 #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFE7FFFFF)
170 #define KERNEL_STACK_SIZE (I386_PGBYTES*4)
172 #define VM_MAP_MIN_ADDRESS MACH_VM_MIN_ADDRESS
173 #define VM_MAP_MAX_ADDRESS MACH_VM_MAX_ADDRESS
175 /* FIXME - always leave like this? */
176 #define INTSTACK_SIZE (I386_PGBYTES*4)
178 #ifdef MACH_KERNEL_PRIVATE
180 /* For implementing legacy 32-bit interfaces */
182 #define VM32_MIN_ADDRESS ((vm32_offset_t) 0)
183 #define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
185 #define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0x00000000)
187 #define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x00000000U)
188 #define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU)
190 #define NCOPY_WINDOWS 4
193 * Conversion between 80386 pages and VM pages
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)))
200 #define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \
202 pmap_t __pmap = (pmap); \
203 vm_page_t __page = (page); \
204 vm_prot_t __prot__ = \
205 (protection) & ~(page)->page_lock; \
207 if (__pmap == kernel_pmap) { \
208 __prot__ |= VM_PROT_WRITE; \
210 assert(!__page->encrypted); \
223 #define IS_USERADDR64_CANONICAL(addr) \
224 ((addr) < (VM_MAX_USER_PAGE_ADDRESS + PAGE_SIZE))
226 #endif /* MACH_KERNEL_PRIVATE */
228 #endif /* KERNEL_PRIVATE */
230 #endif /* _MACH_I386_VM_PARAM_H_ */