]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
6601e61a | 4 | * @APPLE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
6601e61a A |
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. | |
8f6c56a5 | 11 | * |
6601e61a A |
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 | |
8f6c56a5 A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
6601e61a A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
8f6c56a5 | 19 | * |
6601e61a | 20 | * @APPLE_LICENSE_HEADER_END@ |
1c79356b A |
21 | */ |
22 | /* | |
23 | * @OSF_COPYRIGHT@ | |
24 | */ | |
25 | /* | |
26 | * Mach Operating System | |
27 | * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University | |
28 | * All Rights Reserved. | |
29 | * | |
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. | |
35 | * | |
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. | |
39 | * | |
40 | * Carnegie Mellon requests users of this software to return to | |
41 | * | |
42 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
43 | * School of Computer Science | |
44 | * Carnegie Mellon University | |
45 | * Pittsburgh PA 15213-3890 | |
46 | * | |
47 | * any improvements or extensions that they make and grant Carnegie Mellon | |
48 | * the rights to redistribute these changes. | |
49 | */ | |
50 | ||
51 | /* | |
52 | * Copyright (c) 1994 The University of Utah and | |
53 | * the Computer Systems Laboratory at the University of Utah (CSL). | |
54 | * All rights reserved. | |
55 | * | |
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.'' | |
63 | * | |
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. | |
67 | * | |
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. | |
70 | * | |
71 | */ | |
72 | ||
73 | /* | |
74 | * File: vm_param.h | |
75 | * Author: Avadis Tevanian, Jr. | |
76 | * Date: 1985 | |
77 | * | |
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 | |
81 | * them. | |
82 | */ | |
83 | ||
84 | #ifndef _MACH_I386_VM_PARAM_H_ | |
85 | #define _MACH_I386_VM_PARAM_H_ | |
86 | ||
91447636 | 87 | #define BYTE_SIZE 8 /* byte size in bits */ |
1c79356b A |
88 | |
89 | #define I386_PGBYTES 4096 /* bytes per 80386 page */ | |
91447636 A |
90 | #define I386_PGSHIFT 12 /* number of bits to shift for pages */ |
91 | ||
92 | #define PAGE_SIZE I386_PGBYTES | |
93 | #define PAGE_SHIFT I386_PGSHIFT | |
94 | #define PAGE_MASK (PAGE_SIZE - 1) | |
1c79356b A |
95 | |
96 | /* | |
97 | * Convert bytes to pages and convert pages to bytes. | |
98 | * No rounding is used. | |
99 | */ | |
100 | ||
91447636 | 101 | #define i386_btop(x) (((pmap_paddr_t)(x)) >> I386_PGSHIFT) |
1c79356b | 102 | #define machine_btop(x) i386_btop(x) |
91447636 | 103 | #define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT) |
1c79356b A |
104 | |
105 | /* | |
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 | |
108 | * bytes. | |
109 | */ | |
110 | ||
91447636 | 111 | #define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \ |
1c79356b | 112 | ~(I386_PGBYTES-1)) |
91447636 | 113 | #define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1)) |
1c79356b | 114 | |
6601e61a | 115 | #define VM_MAX_PAGE_ADDRESS 0x00000000C0000000ULL |
55e303ae | 116 | |
91447636 A |
117 | /* system-wide values */ |
118 | #define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0) | |
119 | #define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_PAGE_ADDRESS) | |
120 | ||
121 | /* process-relative values (all 32-bit legacy only for now) */ | |
1c79356b | 122 | #define VM_MIN_ADDRESS ((vm_offset_t) 0) |
6601e61a | 123 | #define VM_MAX_ADDRESS ((vm_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF)) |
1c79356b | 124 | |
91447636 | 125 | #ifdef KERNEL_PRIVATE |
1c79356b | 126 | |
91447636 | 127 | /* Kernel-wide values */ |
6601e61a A |
128 | #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0xC0000000U) |
129 | #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFfffffffU) | |
91447636 | 130 | #define KERNEL_STACK_SIZE (I386_PGBYTES*4) |
1c79356b A |
131 | |
132 | /* FIXME - always leave like this? */ | |
133 | #define INTSTACK_SIZE (I386_PGBYTES*4) | |
91447636 A |
134 | |
135 | #ifdef MACH_KERNEL_PRIVATE | |
136 | ||
137 | /* For implementing legacy 32-bit interfaces */ | |
138 | #define VM32_SUPPORT | |
139 | #define VM32_MIN_ADDRESS ((vm32_offset_t) 0) | |
140 | #define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF)) | |
141 | ||
6601e61a | 142 | #define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0xc0000000) |
91447636 | 143 | |
6601e61a | 144 | #define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x0c000000U) |
91447636 | 145 | #define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU) |
1c79356b | 146 | |
1c79356b A |
147 | /* |
148 | * Conversion between 80386 pages and VM pages | |
149 | */ | |
150 | ||
151 | #define trunc_i386_to_vm(p) (atop(trunc_page(i386_ptob(p)))) | |
152 | #define round_i386_to_vm(p) (atop(round_page(i386_ptob(p)))) | |
153 | #define vm_to_i386(p) (i386_btop(ptoa(p))) | |
154 | ||
9bccf70c | 155 | #define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \ |
1c79356b | 156 | MACRO_BEGIN \ |
91447636 A |
157 | pmap_t __pmap = (pmap); \ |
158 | vm_page_t __page = (page); \ | |
1c79356b A |
159 | vm_prot_t __prot__ = \ |
160 | (protection) & ~(page)->page_lock; \ | |
161 | \ | |
91447636 | 162 | if (__pmap == kernel_pmap) { \ |
1c79356b | 163 | __prot__ |= VM_PROT_WRITE; \ |
91447636 A |
164 | } else { \ |
165 | assert(!__page->encrypted); \ | |
166 | } \ | |
167 | \ | |
1c79356b | 168 | pmap_enter( \ |
91447636 | 169 | __pmap, \ |
1c79356b | 170 | (virtual_address), \ |
91447636 | 171 | __page->phys_page, \ |
1c79356b | 172 | __prot__, \ |
9bccf70c | 173 | flags, \ |
1c79356b A |
174 | (wired) \ |
175 | ); \ | |
176 | MACRO_END | |
177 | ||
91447636 A |
178 | #endif /* MACH_KERNEL_PRIVATE */ |
179 | ||
180 | #endif /* KERNEL_PRIVATE */ | |
181 | ||
1c79356b | 182 | #endif /* _MACH_I386_VM_PARAM_H_ */ |