]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/i386/vm_param.h
772f3ef5dda21f4bd5a3421310d0f562e75654e7
[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_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 * @OSF_COPYRIGHT@
25 */
26 /*
27 * Mach Operating System
28 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
29 * All Rights Reserved.
30 *
31 * Permission to use, copy, modify and distribute this software and its
32 * documentation is hereby granted, provided that both the copyright
33 * notice and this permission notice appear in all copies of the
34 * software, derivative works or modified versions, and any portions
35 * thereof, and that both notices appear in supporting documentation.
36 *
37 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
38 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 *
41 * Carnegie Mellon requests users of this software to return to
42 *
43 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
44 * School of Computer Science
45 * Carnegie Mellon University
46 * Pittsburgh PA 15213-3890
47 *
48 * any improvements or extensions that they make and grant Carnegie Mellon
49 * the rights to redistribute these changes.
50 */
51
52 /*
53 * Copyright (c) 1994 The University of Utah and
54 * the Computer Systems Laboratory at the University of Utah (CSL).
55 * All rights reserved.
56 *
57 * Permission to use, copy, modify and distribute this software is hereby
58 * granted provided that (1) source code retains these copyright, permission,
59 * and disclaimer notices, and (2) redistributions including binaries
60 * reproduce the notices in supporting documentation, and (3) all advertising
61 * materials mentioning features or use of this software display the following
62 * acknowledgement: ``This product includes software developed by the
63 * Computer Systems Laboratory at the University of Utah.''
64 *
65 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
66 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
67 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
68 *
69 * CSL requests users of this software to return to csl-dist@cs.utah.edu any
70 * improvements that they make and grant CSL redistribution rights.
71 *
72 */
73
74 /*
75 * File: vm_param.h
76 * Author: Avadis Tevanian, Jr.
77 * Date: 1985
78 *
79 * I386 machine dependent virtual memory parameters.
80 * Most of the declarations are preceeded by I386_ (or i386_)
81 * which is OK because only I386 specific code will be using
82 * them.
83 */
84
85 #ifndef _MACH_I386_VM_PARAM_H_
86 #define _MACH_I386_VM_PARAM_H_
87
88 #define BYTE_SIZE 8 /* byte size in bits */
89
90 #define I386_PGBYTES 4096 /* bytes per 80386 page */
91 #define I386_PGSHIFT 12 /* number of bits to shift for pages */
92
93 #define PAGE_SIZE I386_PGBYTES
94 #define PAGE_SHIFT I386_PGSHIFT
95 #define PAGE_MASK (PAGE_SIZE - 1)
96
97 /*
98 * Convert bytes to pages and convert pages to bytes.
99 * No rounding is used.
100 */
101
102 #define i386_btop(x) (((pmap_paddr_t)(x)) >> I386_PGSHIFT)
103 #define machine_btop(x) i386_btop(x)
104 #define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT)
105
106 /*
107 * Round off or truncate to the nearest page. These will work
108 * for either addresses or counts. (i.e. 1 byte rounds to 1 page
109 * bytes.
110 */
111
112 #define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \
113 ~(I386_PGBYTES-1))
114 #define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1))
115
116 #define VM_MAX_PAGE_ADDRESS 0x00000000C0000000ULL
117
118 /* system-wide values */
119 #define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0)
120 #define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_PAGE_ADDRESS)
121
122 /* process-relative values (all 32-bit legacy only for now) */
123 #define VM_MIN_ADDRESS ((vm_offset_t) 0)
124 #define VM_MAX_ADDRESS ((vm_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
125
126 #ifdef KERNEL_PRIVATE
127
128 /* Kernel-wide values */
129 #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0xC0000000U)
130 #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFfffffffU)
131 #define KERNEL_STACK_SIZE (I386_PGBYTES*4)
132
133 /* FIXME - always leave like this? */
134 #define INTSTACK_SIZE (I386_PGBYTES*4)
135
136 #ifdef MACH_KERNEL_PRIVATE
137
138 /* For implementing legacy 32-bit interfaces */
139 #define VM32_SUPPORT
140 #define VM32_MIN_ADDRESS ((vm32_offset_t) 0)
141 #define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
142
143 #define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0xc0000000)
144
145 #define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x0c000000U)
146 #define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU)
147
148 /*
149 * Conversion between 80386 pages and VM pages
150 */
151
152 #define trunc_i386_to_vm(p) (atop(trunc_page(i386_ptob(p))))
153 #define round_i386_to_vm(p) (atop(round_page(i386_ptob(p))))
154 #define vm_to_i386(p) (i386_btop(ptoa(p)))
155
156 #define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \
157 MACRO_BEGIN \
158 pmap_t __pmap = (pmap); \
159 vm_page_t __page = (page); \
160 vm_prot_t __prot__ = \
161 (protection) & ~(page)->page_lock; \
162 \
163 if (__pmap == kernel_pmap) { \
164 __prot__ |= VM_PROT_WRITE; \
165 } else { \
166 assert(!__page->encrypted); \
167 } \
168 \
169 pmap_enter( \
170 __pmap, \
171 (virtual_address), \
172 __page->phys_page, \
173 __prot__, \
174 flags, \
175 (wired) \
176 ); \
177 MACRO_END
178
179 #endif /* MACH_KERNEL_PRIVATE */
180
181 #endif /* KERNEL_PRIVATE */
182
183 #endif /* _MACH_I386_VM_PARAM_H_ */