]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/i386/vm_param.h
xnu-792.12.6.tar.gz
[apple/xnu.git] / osfmk / mach / i386 / vm_param.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
8ad349bb 4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
1c79356b 5 *
8ad349bb
A
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
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
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.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
1c79356b
A
29 */
30/*
31 * @OSF_COPYRIGHT@
32 */
33/*
34 * Mach Operating System
35 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
36 * All Rights Reserved.
37 *
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.
43 *
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.
47 *
48 * Carnegie Mellon requests users of this software to return to
49 *
50 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
51 * School of Computer Science
52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
54 *
55 * any improvements or extensions that they make and grant Carnegie Mellon
56 * the rights to redistribute these changes.
57 */
58
59/*
60 * Copyright (c) 1994 The University of Utah and
61 * the Computer Systems Laboratory at the University of Utah (CSL).
62 * All rights reserved.
63 *
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.''
71 *
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.
75 *
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.
78 *
79 */
80
81/*
82 * File: vm_param.h
83 * Author: Avadis Tevanian, Jr.
84 * Date: 1985
85 *
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
89 * them.
90 */
91
92#ifndef _MACH_I386_VM_PARAM_H_
93#define _MACH_I386_VM_PARAM_H_
94
91447636 95#define BYTE_SIZE 8 /* byte size in bits */
1c79356b
A
96
97#define I386_PGBYTES 4096 /* bytes per 80386 page */
91447636
A
98#define I386_PGSHIFT 12 /* number of bits to shift for pages */
99
100#define PAGE_SIZE I386_PGBYTES
101#define PAGE_SHIFT I386_PGSHIFT
102#define PAGE_MASK (PAGE_SIZE - 1)
1c79356b
A
103
104/*
105 * Convert bytes to pages and convert pages to bytes.
106 * No rounding is used.
107 */
108
91447636 109#define i386_btop(x) (((pmap_paddr_t)(x)) >> I386_PGSHIFT)
1c79356b 110#define machine_btop(x) i386_btop(x)
91447636 111#define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT)
1c79356b
A
112
113/*
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
116 * bytes.
117 */
118
91447636 119#define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \
1c79356b 120 ~(I386_PGBYTES-1))
91447636 121#define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1))
1c79356b 122
8ad349bb 123#define VM_MAX_PAGE_ADDRESS 0x00000000C0000000ULL
55e303ae 124
91447636
A
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)
128
129/* process-relative values (all 32-bit legacy only for now) */
1c79356b 130#define VM_MIN_ADDRESS ((vm_offset_t) 0)
8ad349bb 131#define VM_MAX_ADDRESS ((vm_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
1c79356b 132
91447636 133#ifdef KERNEL_PRIVATE
1c79356b 134
91447636 135/* Kernel-wide values */
8ad349bb
A
136#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0xC0000000U)
137#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFfffffffU)
91447636 138#define KERNEL_STACK_SIZE (I386_PGBYTES*4)
1c79356b
A
139
140/* FIXME - always leave like this? */
141#define INTSTACK_SIZE (I386_PGBYTES*4)
91447636
A
142
143#ifdef MACH_KERNEL_PRIVATE
144
145/* For implementing legacy 32-bit interfaces */
146#define VM32_SUPPORT
147#define VM32_MIN_ADDRESS ((vm32_offset_t) 0)
148#define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
149
8ad349bb 150#define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0xc0000000)
91447636 151
8ad349bb 152#define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x0c000000U)
91447636 153#define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU)
1c79356b 154
1c79356b
A
155/*
156 * Conversion between 80386 pages and VM pages
157 */
158
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)))
162
9bccf70c 163#define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \
1c79356b 164 MACRO_BEGIN \
91447636
A
165 pmap_t __pmap = (pmap); \
166 vm_page_t __page = (page); \
1c79356b
A
167 vm_prot_t __prot__ = \
168 (protection) & ~(page)->page_lock; \
169 \
91447636 170 if (__pmap == kernel_pmap) { \
1c79356b 171 __prot__ |= VM_PROT_WRITE; \
91447636
A
172 } else { \
173 assert(!__page->encrypted); \
174 } \
175 \
1c79356b 176 pmap_enter( \
91447636 177 __pmap, \
1c79356b 178 (virtual_address), \
91447636 179 __page->phys_page, \
1c79356b 180 __prot__, \
9bccf70c 181 flags, \
1c79356b
A
182 (wired) \
183 ); \
184 MACRO_END
185
91447636
A
186#endif /* MACH_KERNEL_PRIVATE */
187
188#endif /* KERNEL_PRIVATE */
189
1c79356b 190#endif /* _MACH_I386_VM_PARAM_H_ */