]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/mach/i386/vm_param.h
xnu-792.13.8.tar.gz
[apple/xnu.git] / osfmk / mach / i386 / vm_param.h
index 84f4a3063424a4b93726fc9d2329e7fda5a17227..0a3a2127c8ffd424695c953a0fa707e624c79cd9 100644 (file)
@@ -1,26 +1,31 @@
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
  * 
- * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
- * 
- * 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
+ * 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.  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
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
+ *
+ * The Original Code and all software distributed under the License are 
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
+ * Please see the License for the specific language governing rights and 
  * limitations under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
+ *
+ * @APPLE_LICENSE_OSREFERENCE_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_MAX_PAGE_ADDRESS     0x00000000C0000000ULL
 
+#define VM_MIN_ADDRESS64       ((user_addr_t) 0x0000000000000000ULL)
+/*
+ * default top of user stack... it grows down from here
+ */
+#define VM_USRSTACK64          ((user_addr_t) 0x00007FFF5FC00000ULL)
+#define VM_DYLD64              ((user_addr_t) 0x00007FFF5FC00000ULL)
+#define VM_LIB64_SHR_DATA      ((user_addr_t) 0x00007FFF60000000ULL)
+#define VM_LIB64_SHR_TEXT      ((user_addr_t) 0x00007FFF80000000ULL)
+/*
+ * the end of the usable user address space , for now about 47 bits.
+ * the 64 bit commpage is past the end of this
+ */
+#define VM_MAX_PAGE_ADDRESS    ((user_addr_t) 0x00007FFFFFE00000ULL)
+/*
+ * canonical end of user address space for limits checking
+ */
+#define VM_MAX_USER_PAGE_ADDRESS ((user_addr_t)0x00007FFFFFFFF000ULL)
+
+
+
+/* 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)
+
+/* 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_USRSTACK32          ((vm_offset_t) 0xC0000000)
+#define VM_MAX_ADDRESS         ((vm_offset_t) 0xFFE00000)
 
-#define LINEAR_KERNEL_ADDRESS  ((vm_offset_t) 0xc0000000)
 
-#define VM_MIN_KERNEL_ADDRESS  ((vm_offset_t) 0x00000000U)
-#define VM_MAX_KERNEL_ADDRESS  ((vm_offset_t) 0x3fffffffU)
 
-#define VM_MIN_KERNEL_LOADED_ADDRESS   ((vm_offset_t) 0x0c000000U)
-#define VM_MAX_KERNEL_LOADED_ADDRESS   ((vm_offset_t) 0x1fffffffU)
 
-/* FIXME  - always leave like this? */
-#define        INTSTACK_SIZE   (I386_PGBYTES*4)
-#define        KERNEL_STACK_SIZE       (I386_PGBYTES*4)
+#ifdef KERNEL_PRIVATE 
 
+/* Kernel-wide values */
+#define VM_MIN_KERNEL_ADDRESS  ((vm_offset_t) 0x00001000U)
 /*
- *     Conversion between 80386 pages and VM pages
+ * XXX
+ * The kernel max VM address is limited to 0xFF3FFFFF for now because
+ * some data structures are explicitly allocated at 0xFF400000 without
+ * VM's knowledge (see osfmk/i386/locore.s for the allocation of PTmap and co.).
+ * We can't let VM allocate memory from there.
  */
 
-#define trunc_i386_to_vm(p)    (atop(trunc_page(i386_ptob(p))))
-#define round_i386_to_vm(p)    (atop(round_page(i386_ptob(p))))
-#define vm_to_i386(p)          (i386_btop(ptoa(p)))
+#define VM_MAX_KERNEL_ADDRESS  ((vm_offset_t) 0xFE7FFFFF)
+#define KERNEL_STACK_SIZE              (I386_PGBYTES*4)
 
-/*
- *     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)
+#define VM_MAP_MIN_ADDRESS     MACH_VM_MIN_ADDRESS
+#define VM_MAP_MAX_ADDRESS     MACH_VM_MAX_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.)
- */
+/* FIXME  - always leave like this? */
+#define        INTSTACK_SIZE   (I386_PGBYTES*4)
+
+#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))
 
-/*#if defined(AT386)
+#define LINEAR_KERNEL_ADDRESS  ((vm_offset_t) 0x00000000)
 
-#define PMAP_ENTER_386_CHECK \
-       if (cpuid_family == CPUID_FAMILY_386)
+#define VM_MIN_KERNEL_LOADED_ADDRESS   ((vm_offset_t) 0x00000000U)
+#define VM_MAX_KERNEL_LOADED_ADDRESS   ((vm_offset_t) 0x1fffffffU)
 
-#else -- FIXME? We're only running on Pentiums or better */
+#define NCOPY_WINDOWS  4
 
-#define PMAP_ENTER_386_CHECK
+/*
+ *     Conversion between 80386 pages and VM pages
+ */
 
-/*#endif*/
+#define trunc_i386_to_vm(p)    (atop(trunc_page(i386_ptob(p))))
+#define round_i386_to_vm(p)    (atop(round_page(i386_ptob(p))))
+#define vm_to_i386(p)          (i386_btop(ptoa(p)))
 
 #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_page,                      \
+               __page->phys_page,                      \
                __prot__,                               \
                flags,                                  \
                (wired)                                 \
         );                                             \
        MACRO_END
 
+#define IS_USERADDR64_CANONICAL(addr)                  \
+       ((addr) < (VM_MAX_USER_PAGE_ADDRESS + PAGE_SIZE))
+
+#endif /* MACH_KERNEL_PRIVATE */
+
+#endif /* KERNEL_PRIVATE */
+
 #endif /* _MACH_I386_VM_PARAM_H_ */