]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/i386/vm_param.h
10350ab9f8131ed1ff895e97f415ae66eade479f
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
23 * @APPLE_LICENSE_HEADER_END@
29 * Mach Operating System
30 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
31 * All Rights Reserved.
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.
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.
43 * Carnegie Mellon requests users of this software to return to
45 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
46 * School of Computer Science
47 * Carnegie Mellon University
48 * Pittsburgh PA 15213-3890
50 * any improvements or extensions that they make and grant Carnegie Mellon
51 * the rights to redistribute these changes.
55 * Copyright (c) 1994 The University of Utah and
56 * the Computer Systems Laboratory at the University of Utah (CSL).
57 * All rights reserved.
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.''
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.
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.
78 * Author: Avadis Tevanian, Jr.
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
87 #ifndef _MACH_I386_VM_PARAM_H_
88 #define _MACH_I386_VM_PARAM_H_
90 #define BYTE_SIZE 8 /* byte size in bits */
92 #define I386_PGBYTES 4096 /* bytes per 80386 page */
93 #define I386_PGSHIFT 12 /* number of bits to shift for pages */
96 * Convert bytes to pages and convert pages to bytes.
97 * No rounding is used.
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)
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
110 #define i386_round_page(x) ((((unsigned)(x)) + I386_PGBYTES - 1) & \
112 #define i386_trunc_page(x) (((unsigned)(x)) & ~(I386_PGBYTES-1))
114 #define VM_MIN_ADDRESS ((vm_offset_t) 0)
115 #define VM_MAX_ADDRESS ((vm_offset_t) 0xc0000000U)
117 #define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0xc0000000)
119 #define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0x00000000U)
120 #define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0x3fffffffU)
122 #define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x0c000000U)
123 #define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU)
125 /* FIXME - always leave like this? */
126 #define INTSTACK_SIZE (I386_PGBYTES*4)
127 #define KERNEL_STACK_SIZE (I386_PGBYTES*4)
131 #include <norma_vm.h>
132 #include <task_swapper.h>
133 #include <thread_swapper.h>
136 #include <i386/cpuid.h>
140 #if !TASK_SWAPPER && !THREAD_SWAPPER
141 #define KERNEL_STACK_SIZE (I386_PGBYTES/2)
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 */
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 */
154 * Conversion between 80386 pages and VM pages
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)))
162 * Physical memory is mapped 1-1 with virtual memory starting
163 * at VM_MIN_KERNEL_ADDRESS.
165 #define phystokv(a) ((vm_offset_t)(a) + VM_MIN_KERNEL_ADDRESS)
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.)
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.)
185 #define PMAP_ENTER_386_CHECK \
186 if (cpuid_family == CPUID_FAMILY_386)
188 #else -- FIXME? We're only running on Pentiums or better */
190 #define PMAP_ENTER_386_CHECK
194 #define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \
196 vm_prot_t __prot__ = \
197 (protection) & ~(page)->page_lock; \
199 PMAP_ENTER_386_CHECK \
200 if ((pmap) == kernel_pmap) \
201 __prot__ |= VM_PROT_WRITE; \
212 #endif /* _MACH_I386_VM_PARAM_H_ */