]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/i386/vm_param.h
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
28 * All Rights Reserved.
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.
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.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
52 * Copyright (c) 1994 The University of Utah and
53 * the Computer Systems Laboratory at the University of Utah (CSL).
54 * All rights reserved.
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.''
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.
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.
75 * Author: Avadis Tevanian, Jr.
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
84 #ifndef _MACH_I386_VM_PARAM_H_
85 #define _MACH_I386_VM_PARAM_H_
87 #define BYTE_SIZE 8 /* byte size in bits */
89 #define I386_PGBYTES 4096 /* bytes per 80386 page */
90 #define I386_PGSHIFT 12 /* number of bits to shift for pages */
92 #define PAGE_SIZE I386_PGBYTES
93 #define PAGE_SHIFT I386_PGSHIFT
94 #define PAGE_MASK (PAGE_SIZE - 1)
97 * Convert bytes to pages and convert pages to bytes.
98 * No rounding is used.
101 #define i386_btop(x) (((pmap_paddr_t)(x)) >> I386_PGSHIFT)
102 #define machine_btop(x) i386_btop(x)
103 #define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT)
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
111 #define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \
113 #define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1))
117 #define VM_MIN_ADDRESS64 ((user_addr_t) 0x0000000000000000ULL)
119 * default top of user stack... it grows down from here
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)
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
129 #define VM_MAX_PAGE_ADDRESS ((user_addr_t) 0x00007FFFFFE00000ULL)
131 * canonical end of user address space for limits checking
133 #define VM_MAX_USER_PAGE_ADDRESS ((user_addr_t)0x00007FFFFFFFF000ULL)
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)
141 /* process-relative values (all 32-bit legacy only for now) */
142 #define VM_MIN_ADDRESS ((vm_offset_t) 0)
143 #define VM_USRSTACK32 ((vm_offset_t) 0xC0000000)
144 #define VM_MAX_ADDRESS ((vm_offset_t) 0xFFE00000)
149 #ifdef KERNEL_PRIVATE
151 /* Kernel-wide values */
152 #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0x00001000U)
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.
161 #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFE7FFFFF)
162 #define KERNEL_STACK_SIZE (I386_PGBYTES*4)
164 #define VM_MAP_MIN_ADDRESS MACH_VM_MIN_ADDRESS
165 #define VM_MAP_MAX_ADDRESS MACH_VM_MAX_ADDRESS
167 /* FIXME - always leave like this? */
168 #define INTSTACK_SIZE (I386_PGBYTES*4)
170 #ifdef MACH_KERNEL_PRIVATE
172 /* For implementing legacy 32-bit interfaces */
174 #define VM32_MIN_ADDRESS ((vm32_offset_t) 0)
175 #define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
177 #define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0x00000000)
179 #define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x00000000U)
180 #define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU)
182 #define NCOPY_WINDOWS 4
185 * Conversion between 80386 pages and VM pages
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)))
192 #define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \
194 pmap_t __pmap = (pmap); \
195 vm_page_t __page = (page); \
196 vm_prot_t __prot__ = \
197 (protection) & ~(page)->page_lock; \
199 if (__pmap == kernel_pmap) { \
200 __prot__ |= VM_PROT_WRITE; \
202 assert(!__page->encrypted); \
215 #define IS_USERADDR64_CANONICAL(addr) \
216 ((addr) < (VM_MAX_USER_PAGE_ADDRESS + PAGE_SIZE))
218 #endif /* MACH_KERNEL_PRIVATE */
220 #endif /* KERNEL_PRIVATE */
222 #endif /* _MACH_I386_VM_PARAM_H_ */