]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
d7e50217 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
d7e50217 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
d7e50217 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | */ | |
28 | /* | |
29 | * Mach Operating System | |
30 | * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University | |
31 | * All Rights Reserved. | |
32 | * | |
33 | * Permission to use, copy, modify and distribute this software and its | |
34 | * documentation is hereby granted, provided that both the copyright | |
35 | * notice and this permission notice appear in all copies of the | |
36 | * software, derivative works or modified versions, and any portions | |
37 | * thereof, and that both notices appear in supporting documentation. | |
38 | * | |
39 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
40 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
41 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
42 | * | |
43 | * Carnegie Mellon requests users of this software to return to | |
44 | * | |
45 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
46 | * School of Computer Science | |
47 | * Carnegie Mellon University | |
48 | * Pittsburgh PA 15213-3890 | |
49 | * | |
50 | * any improvements or extensions that they make and grant Carnegie Mellon | |
51 | * the rights to redistribute these changes. | |
52 | */ | |
53 | ||
54 | /* | |
55 | * Copyright (c) 1994 The University of Utah and | |
56 | * the Computer Systems Laboratory at the University of Utah (CSL). | |
57 | * All rights reserved. | |
58 | * | |
59 | * Permission to use, copy, modify and distribute this software is hereby | |
60 | * granted provided that (1) source code retains these copyright, permission, | |
61 | * and disclaimer notices, and (2) redistributions including binaries | |
62 | * reproduce the notices in supporting documentation, and (3) all advertising | |
63 | * materials mentioning features or use of this software display the following | |
64 | * acknowledgement: ``This product includes software developed by the | |
65 | * Computer Systems Laboratory at the University of Utah.'' | |
66 | * | |
67 | * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS | |
68 | * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF | |
69 | * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
70 | * | |
71 | * CSL requests users of this software to return to csl-dist@cs.utah.edu any | |
72 | * improvements that they make and grant CSL redistribution rights. | |
73 | * | |
74 | */ | |
75 | ||
76 | /* | |
77 | * File: vm_param.h | |
78 | * Author: Avadis Tevanian, Jr. | |
79 | * Date: 1985 | |
80 | * | |
81 | * I386 machine dependent virtual memory parameters. | |
82 | * Most of the declarations are preceeded by I386_ (or i386_) | |
83 | * which is OK because only I386 specific code will be using | |
84 | * them. | |
85 | */ | |
86 | ||
87 | #ifndef _MACH_I386_VM_PARAM_H_ | |
88 | #define _MACH_I386_VM_PARAM_H_ | |
89 | ||
90 | #define BYTE_SIZE 8 /* byte size in bits */ | |
91 | ||
92 | #define I386_PGBYTES 4096 /* bytes per 80386 page */ | |
93 | #define I386_PGSHIFT 12 /* number of bits to shift for pages */ | |
94 | ||
95 | /* | |
96 | * Convert bytes to pages and convert pages to bytes. | |
97 | * No rounding is used. | |
98 | */ | |
99 | ||
100 | #define i386_btop(x) (((unsigned)(x)) >> I386_PGSHIFT) | |
101 | #define machine_btop(x) i386_btop(x) | |
102 | #define i386_ptob(x) (((unsigned)(x)) << I386_PGSHIFT) | |
103 | ||
104 | /* | |
105 | * Round off or truncate to the nearest page. These will work | |
106 | * for either addresses or counts. (i.e. 1 byte rounds to 1 page | |
107 | * bytes. | |
108 | */ | |
109 | ||
110 | #define i386_round_page(x) ((((unsigned)(x)) + I386_PGBYTES - 1) & \ | |
111 | ~(I386_PGBYTES-1)) | |
112 | #define i386_trunc_page(x) (((unsigned)(x)) & ~(I386_PGBYTES-1)) | |
113 | ||
114 | #define VM_MIN_ADDRESS ((vm_offset_t) 0) | |
115 | #define VM_MAX_ADDRESS ((vm_offset_t) 0xc0000000U) | |
116 | ||
117 | #define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0xc0000000) | |
118 | ||
119 | #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0x00000000U) | |
120 | #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0x3fffffffU) | |
121 | ||
122 | #define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x0c000000U) | |
123 | #define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU) | |
124 | ||
125 | /* FIXME - always leave like this? */ | |
126 | #define INTSTACK_SIZE (I386_PGBYTES*4) | |
127 | #define KERNEL_STACK_SIZE (I386_PGBYTES*4) | |
128 | ||
129 | #if 0 /* FIXME */ | |
130 | ||
131 | #include <norma_vm.h> | |
132 | #include <task_swapper.h> | |
133 | #include <thread_swapper.h> | |
134 | ||
135 | #if defined(AT386) | |
136 | #include <i386/cpuid.h> | |
137 | #endif | |
138 | ||
139 | #if !NORMA_VM | |
140 | #if !TASK_SWAPPER && !THREAD_SWAPPER | |
141 | #define KERNEL_STACK_SIZE (I386_PGBYTES/2) | |
142 | #else | |
143 | /* stack needs to be a multiple of page size to get unwired when swapped */ | |
144 | #define KERNEL_STACK_SIZE (I386_PGBYTES) | |
145 | #endif /* TASK || THREAD SWAPPER */ | |
146 | #define INTSTACK_SIZE (I386_PGBYTES) /* interrupt stack size */ | |
147 | #else /* NORMA_VM */ | |
148 | #define KERNEL_STACK_SIZE (I386_PGBYTES*2) | |
149 | #define INTSTACK_SIZE (I386_PGBYTES*2) /* interrupt stack size */ | |
150 | #endif /* NORMA_VM */ | |
151 | #endif /* MACH_KERNEL */ | |
152 | ||
153 | /* | |
154 | * Conversion between 80386 pages and VM pages | |
155 | */ | |
156 | ||
157 | #define trunc_i386_to_vm(p) (atop(trunc_page(i386_ptob(p)))) | |
158 | #define round_i386_to_vm(p) (atop(round_page(i386_ptob(p)))) | |
159 | #define vm_to_i386(p) (i386_btop(ptoa(p))) | |
160 | ||
161 | /* | |
162 | * Physical memory is mapped 1-1 with virtual memory starting | |
163 | * at VM_MIN_KERNEL_ADDRESS. | |
164 | */ | |
165 | #define phystokv(a) ((vm_offset_t)(a) + VM_MIN_KERNEL_ADDRESS) | |
166 | ||
167 | /* | |
168 | * For 386 only, ensure that pages are installed in the | |
169 | * kernel_pmap with VM_PROT_WRITE enabled. This avoids | |
170 | * code in pmap_enter that disallows a read-only mapping | |
171 | * in the kernel's pmap. (See ri-osc CR1387.) | |
172 | * | |
173 | * An entry in kernel_pmap is made only by the kernel or | |
174 | * a collocated server -- by definition (;-)), the requester | |
175 | * is trusted code. If it asked for read-only access, | |
176 | * it won't attempt a write. We don't have to enforce the | |
177 | * restriction. (Naturally, this assumes that any collocated | |
178 | * server will _not_ depend on trapping write accesses to pages | |
179 | * mapped read-only; this cannot be made to work in the current | |
180 | * i386-inspired pmap model.) | |
181 | */ | |
182 | ||
183 | /*#if defined(AT386) | |
184 | ||
185 | #define PMAP_ENTER_386_CHECK \ | |
186 | if (cpuid_family == CPUID_FAMILY_386) | |
187 | ||
188 | #else -- FIXME? We're only running on Pentiums or better */ | |
189 | ||
190 | #define PMAP_ENTER_386_CHECK | |
191 | ||
192 | /*#endif*/ | |
193 | ||
9bccf70c | 194 | #define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \ |
1c79356b A |
195 | MACRO_BEGIN \ |
196 | vm_prot_t __prot__ = \ | |
197 | (protection) & ~(page)->page_lock; \ | |
198 | \ | |
199 | PMAP_ENTER_386_CHECK \ | |
200 | if ((pmap) == kernel_pmap) \ | |
201 | __prot__ |= VM_PROT_WRITE; \ | |
202 | pmap_enter( \ | |
203 | (pmap), \ | |
204 | (virtual_address), \ | |
d7e50217 | 205 | (page)->phys_page, \ |
1c79356b | 206 | __prot__, \ |
9bccf70c | 207 | flags, \ |
1c79356b A |
208 | (wired) \ |
209 | ); \ | |
210 | MACRO_END | |
211 | ||
212 | #endif /* _MACH_I386_VM_PARAM_H_ */ |