/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
- *
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* Please see the License for the specific language governing rights and
* limitations under the License.
*
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
#ifndef _MACH_I386_VM_PARAM_H_
#define _MACH_I386_VM_PARAM_H_
-#define BYTE_SIZE 8 /* byte size in bits */
+#define BYTE_SIZE 8 /* byte size in bits */
#define I386_PGBYTES 4096 /* bytes per 80386 page */
-#define I386_PGSHIFT 12 /* number of bits to shift for pages */
+#define I386_PGSHIFT 12 /* number of bits to shift for pages */
+
+#define PAGE_SIZE I386_PGBYTES
+#define PAGE_SHIFT I386_PGSHIFT
+#define PAGE_MASK (PAGE_SIZE - 1)
/*
* Convert bytes to pages and convert pages to bytes.
* No rounding is used.
*/
-#define i386_btop(x) (((unsigned)(x)) >> I386_PGSHIFT)
+#define i386_btop(x) (((pmap_paddr_t)(x)) >> I386_PGSHIFT)
#define machine_btop(x) i386_btop(x)
-#define i386_ptob(x) (((unsigned)(x)) << I386_PGSHIFT)
+#define i386_ptob(x) (((pmap_paddr_t)(x)) << I386_PGSHIFT)
/*
* Round off or truncate to the nearest page. These will work
* bytes.
*/
-#define i386_round_page(x) ((((unsigned)(x)) + I386_PGBYTES - 1) & \
+#define i386_round_page(x) ((((pmap_paddr_t)(x)) + I386_PGBYTES - 1) & \
~(I386_PGBYTES-1))
-#define i386_trunc_page(x) (((unsigned)(x)) & ~(I386_PGBYTES-1))
+#define i386_trunc_page(x) (((pmap_paddr_t)(x)) & ~(I386_PGBYTES-1))
-#define VM_MIN_ADDRESS ((vm_offset_t) 0)
-#define VM_MAX_ADDRESS ((vm_offset_t) 0xc0000000U)
+#define VM_MAX_PAGE_ADDRESS 0x00000000C0000000ULL
-#define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0xc0000000)
+/* system-wide values */
+#define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0)
+#define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_PAGE_ADDRESS)
-#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0x00000000U)
-#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0x3fffffffU)
+/* process-relative values (all 32-bit legacy only for now) */
+#define VM_MIN_ADDRESS ((vm_offset_t) 0)
+#define VM_MAX_ADDRESS ((vm_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
-#define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x0c000000U)
-#define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU)
+#ifdef KERNEL_PRIVATE
+
+/* Kernel-wide values */
+#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t) 0xC0000000U)
+#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t) 0xFfffffffU)
+#define KERNEL_STACK_SIZE (I386_PGBYTES*4)
/* FIXME - always leave like this? */
#define INTSTACK_SIZE (I386_PGBYTES*4)
-#define KERNEL_STACK_SIZE (I386_PGBYTES*4)
-
-#if 0 /* FIXME */
-
-#include <norma_vm.h>
-#include <task_swapper.h>
-#include <thread_swapper.h>
-
-#if defined(AT386)
-#include <i386/cpuid.h>
-#endif
-
-#if !NORMA_VM
-#if !TASK_SWAPPER && !THREAD_SWAPPER
-#define KERNEL_STACK_SIZE (I386_PGBYTES/2)
-#else
-/* stack needs to be a multiple of page size to get unwired when swapped */
-#define KERNEL_STACK_SIZE (I386_PGBYTES)
-#endif /* TASK || THREAD SWAPPER */
-#define INTSTACK_SIZE (I386_PGBYTES) /* interrupt stack size */
-#else /* NORMA_VM */
-#define KERNEL_STACK_SIZE (I386_PGBYTES*2)
-#define INTSTACK_SIZE (I386_PGBYTES*2) /* interrupt stack size */
-#endif /* NORMA_VM */
-#endif /* MACH_KERNEL */
+
+#ifdef MACH_KERNEL_PRIVATE
+
+/* For implementing legacy 32-bit interfaces */
+#define VM32_SUPPORT
+#define VM32_MIN_ADDRESS ((vm32_offset_t) 0)
+#define VM32_MAX_ADDRESS ((vm32_offset_t) (VM_MAX_PAGE_ADDRESS & 0xFFFFFFFF))
+
+#define LINEAR_KERNEL_ADDRESS ((vm_offset_t) 0xc0000000)
+
+#define VM_MIN_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x0c000000U)
+#define VM_MAX_KERNEL_LOADED_ADDRESS ((vm_offset_t) 0x1fffffffU)
/*
* Conversion between 80386 pages and VM pages
#define round_i386_to_vm(p) (atop(round_page(i386_ptob(p))))
#define vm_to_i386(p) (i386_btop(ptoa(p)))
-/*
- * Physical memory is mapped 1-1 with virtual memory starting
- * at VM_MIN_KERNEL_ADDRESS.
- */
-#define phystokv(a) ((vm_offset_t)(a) + VM_MIN_KERNEL_ADDRESS)
-
-/*
- * For 386 only, ensure that pages are installed in the
- * kernel_pmap with VM_PROT_WRITE enabled. This avoids
- * code in pmap_enter that disallows a read-only mapping
- * in the kernel's pmap. (See ri-osc CR1387.)
- *
- * An entry in kernel_pmap is made only by the kernel or
- * a collocated server -- by definition (;-)), the requester
- * is trusted code. If it asked for read-only access,
- * it won't attempt a write. We don't have to enforce the
- * restriction. (Naturally, this assumes that any collocated
- * server will _not_ depend on trapping write accesses to pages
- * mapped read-only; this cannot be made to work in the current
- * i386-inspired pmap model.)
- */
-
-/*#if defined(AT386)
-
-#define PMAP_ENTER_386_CHECK \
- if (cpuid_family == CPUID_FAMILY_386)
-
-#else -- FIXME? We're only running on Pentiums or better */
-
-#define PMAP_ENTER_386_CHECK
-
-/*#endif*/
-
#define PMAP_ENTER(pmap, virtual_address, page, protection, flags, wired) \
MACRO_BEGIN \
+ pmap_t __pmap = (pmap); \
+ vm_page_t __page = (page); \
vm_prot_t __prot__ = \
(protection) & ~(page)->page_lock; \
\
- PMAP_ENTER_386_CHECK \
- if ((pmap) == kernel_pmap) \
+ if (__pmap == kernel_pmap) { \
__prot__ |= VM_PROT_WRITE; \
+ } else { \
+ assert(!__page->encrypted); \
+ } \
+ \
pmap_enter( \
- (pmap), \
+ __pmap, \
(virtual_address), \
- (page)->phys_addr, \
+ __page->phys_page, \
__prot__, \
flags, \
(wired) \
); \
MACRO_END
+#endif /* MACH_KERNEL_PRIVATE */
+
+#endif /* KERNEL_PRIVATE */
+
#endif /* _MACH_I386_VM_PARAM_H_ */