]>
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_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))
123 #define VM_MAX_PAGE_ADDRESS 0x00000000C0000000ULL
125 /* system-wide values */
126 #define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0)
127 #define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_PAGE_ADDRESS)
129 /* process-relative values (all 32-bit legacy only for now) */
130 #define VM_MIN_ADDRESS ((vm_offset_t) 0)
131 #define VM_MAX_ADDRESS ((vm_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
133 #ifdef KERNEL_PRIVATE
135 /* Kernel-wide values */
136 #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0xC0000000U)
137 #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFfffffffU)
138 #define KERNEL_STACK_SIZE (I386_PGBYTES*4)
140 /* FIXME - always leave like this? */
141 #define INTSTACK_SIZE (I386_PGBYTES*4)
143 #ifdef MACH_KERNEL_PRIVATE
145 /* For implementing legacy 32-bit interfaces */
147 #define VM32_MIN_ADDRESS ((vm32_offset_t) 0)
148 #define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
150 #define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0xc0000000)
152 #define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x0c000000U)
153 #define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU)
156 * Conversion between 80386 pages and VM pages
159 #define trunc_i386_to_vm(p) (atop(trunc_page(i386_ptob(p))))
160 #define round_i386_to_vm(p) (atop(round_page(i386_ptob(p))))
161 #define vm_to_i386(p) (i386_btop(ptoa(p)))
163 #define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \
165 pmap_t __pmap = (pmap); \
166 vm_page_t __page = (page); \
167 vm_prot_t __prot__ = \
168 (protection) & ~(page)->page_lock; \
170 if (__pmap == kernel_pmap) { \
171 __prot__ |= VM_PROT_WRITE; \
173 assert(!__page->encrypted); \
186 #endif /* MACH_KERNEL_PRIVATE */
188 #endif /* KERNEL_PRIVATE */
190 #endif /* _MACH_I386_VM_PARAM_H_ */