]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/i386/vm_param.h
0f18100e6710a7e776f4e0134dbbf01298ab311e
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
28 * All Rights Reserved.
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.
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.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
52 * Copyright (c) 1994 The University of Utah and
53 * the Computer Systems Laboratory at the University of Utah (CSL).
54 * All rights reserved.
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.''
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.
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.
75 * Author: Avadis Tevanian, Jr.
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
84 #ifndef _MACH_I386_VM_PARAM_H_
85 #define _MACH_I386_VM_PARAM_H_
87 #define BYTE_SIZE 8 /* byte size in bits */
89 #define I386_PGBYTES 4096 /* bytes per 80386 page */
90 #define I386_PGSHIFT 12 /* number of bits to shift for pages */
93 * Convert bytes to pages and convert pages to bytes.
94 * No rounding is used.
97 #define i386_btop(x) (((unsigned)(x)) >> I386_PGSHIFT)
98 #define machine_btop(x) i386_btop(x)
99 #define i386_ptob(x) (((unsigned)(x)) << I386_PGSHIFT)
102 * Round off or truncate to the nearest page. These will work
103 * for either addresses or counts. (i.e. 1 byte rounds to 1 page
107 #define i386_round_page(x) ((((unsigned)(x)) + I386_PGBYTES - 1) & \
109 #define i386_trunc_page(x) (((unsigned)(x)) & ~(I386_PGBYTES-1))
111 #define VM_MIN_ADDRESS ((vm_offset_t) 0)
112 #define VM_MAX_ADDRESS ((vm_offset_t) 0xc0000000U)
114 #define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0xc0000000)
116 #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0x00000000U)
117 #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0x3fffffffU)
119 #define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x0c000000U)
120 #define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU)
122 /* FIXME - always leave like this? */
123 #define INTSTACK_SIZE (I386_PGBYTES*4)
124 #define KERNEL_STACK_SIZE (I386_PGBYTES*4)
128 #include <norma_vm.h>
129 #include <task_swapper.h>
130 #include <thread_swapper.h>
133 #include <i386/cpuid.h>
137 #if !TASK_SWAPPER && !THREAD_SWAPPER
138 #define KERNEL_STACK_SIZE (I386_PGBYTES/2)
140 /* stack needs to be a multiple of page size to get unwired when swapped */
141 #define KERNEL_STACK_SIZE (I386_PGBYTES)
142 #endif /* TASK || THREAD SWAPPER */
143 #define INTSTACK_SIZE (I386_PGBYTES) /* interrupt stack size */
145 #define KERNEL_STACK_SIZE (I386_PGBYTES*2)
146 #define INTSTACK_SIZE (I386_PGBYTES*2) /* interrupt stack size */
147 #endif /* NORMA_VM */
148 #endif /* MACH_KERNEL */
151 * Conversion between 80386 pages and VM pages
154 #define trunc_i386_to_vm(p) (atop(trunc_page(i386_ptob(p))))
155 #define round_i386_to_vm(p) (atop(round_page(i386_ptob(p))))
156 #define vm_to_i386(p) (i386_btop(ptoa(p)))
159 * Physical memory is mapped 1-1 with virtual memory starting
160 * at VM_MIN_KERNEL_ADDRESS.
162 #define phystokv(a) ((vm_offset_t)(a) + VM_MIN_KERNEL_ADDRESS)
165 * For 386 only, ensure that pages are installed in the
166 * kernel_pmap with VM_PROT_WRITE enabled. This avoids
167 * code in pmap_enter that disallows a read-only mapping
168 * in the kernel's pmap. (See ri-osc CR1387.)
170 * An entry in kernel_pmap is made only by the kernel or
171 * a collocated server -- by definition (;-)), the requester
172 * is trusted code. If it asked for read-only access,
173 * it won't attempt a write. We don't have to enforce the
174 * restriction. (Naturally, this assumes that any collocated
175 * server will _not_ depend on trapping write accesses to pages
176 * mapped read-only; this cannot be made to work in the current
177 * i386-inspired pmap model.)
182 #define PMAP_ENTER_386_CHECK \
183 if (cpuid_family == CPUID_FAMILY_386)
185 #else -- FIXME? We're only running on Pentiums or better */
187 #define PMAP_ENTER_386_CHECK
191 #define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \
193 vm_prot_t __prot__ = \
194 (protection) & ~(page)->page_lock; \
196 PMAP_ENTER_386_CHECK \
197 if ((pmap) == kernel_pmap) \
198 __prot__ |= VM_PROT_WRITE; \
209 #endif /* _MACH_I386_VM_PARAM_H_ */