]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/phys.c
xnu-1228.15.4.tar.gz
[apple/xnu.git] / osfmk / i386 / phys.c
index 76e5028691a80f9cff24347a72b4c871dcad5e63..7269aa283004e69e53fc190dab622baadfa6e24e 100644 (file)
@@ -1,23 +1,29 @@
 /*
  * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * 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.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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 OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * 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_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
@@ -80,7 +86,6 @@
 #include <i386/tss.h>
 #include <i386/user_ldt.h>
 #include <i386/fpu.h>
-#include <i386/iopb_entries.h>
 #include <i386/misc_protos.h>
 
 /*
@@ -91,6 +96,7 @@ pmap_zero_page(
               ppnum_t pn)
 {
        assert(pn != vm_page_fictitious_addr);
+       assert(pn != vm_page_guard_addr);
        bzero_phys((addr64_t)i386_ptob(pn), PAGE_SIZE);
 }
 
@@ -105,6 +111,7 @@ pmap_zero_part_page(
        vm_size_t       len)
 {
        assert(pn != vm_page_fictitious_addr);
+       assert(pn != vm_page_guard_addr);
        assert(offset + len <= PAGE_SIZE);
        bzero_phys((addr64_t)(i386_ptob(pn) + offset), len);
 }
@@ -124,6 +131,8 @@ pmap_copy_part_page(
 
        assert(psrc != vm_page_fictitious_addr);
        assert(pdst != vm_page_fictitious_addr);
+       assert(psrc != vm_page_guard_addr);
+       assert(pdst != vm_page_guard_addr);
 
        src = i386_ptob(psrc);
        dst = i386_ptob(pdst);
@@ -150,19 +159,17 @@ pmap_copy_part_lpage(
         mapwindow_t *map;
 
        assert(pdst != vm_page_fictitious_addr);
+       assert(pdst != vm_page_guard_addr);
        assert((dst_offset + len) <= PAGE_SIZE);
 
         mp_disable_preemption();
 
         map = pmap_get_mapwindow(INTEL_PTE_VALID | INTEL_PTE_RW | (i386_ptob(pdst) & PG_FRAME) | 
                                  INTEL_PTE_REF | INTEL_PTE_MOD);
-       if (map == 0) {
-               panic("pmap_copy_part_lpage");
-        }
-       invlpg((uintptr_t)map->prv_CADDR);
 
        memcpy((void *) (map->prv_CADDR + (dst_offset & INTEL_OFFMASK)), (void *) src, len);
-       *map->prv_CMAP = 0;
+
+       pmap_put_mapwindow(map);
 
        mp_enable_preemption();
 }
@@ -181,19 +188,17 @@ pmap_copy_part_rpage(
         mapwindow_t *map;
 
        assert(psrc != vm_page_fictitious_addr);
+       assert(psrc != vm_page_guard_addr);
        assert((src_offset + len) <= PAGE_SIZE);
 
         mp_disable_preemption();
 
         map = pmap_get_mapwindow(INTEL_PTE_VALID | INTEL_PTE_RW | (i386_ptob(psrc) & PG_FRAME) | 
                                  INTEL_PTE_REF);
-       if (map == 0) {
-               panic("pmap_copy_part_rpage");
-        }
-       invlpg((uintptr_t) map->prv_CADDR);
 
        memcpy((void *) dst, (void *) (map->prv_CADDR + (src_offset & INTEL_OFFMASK)), len);
-       *map->prv_CMAP = 0;
+
+       pmap_put_mapwindow(map);
 
        mp_enable_preemption();
 }
@@ -209,12 +214,14 @@ kvtophys(
 {
         pt_entry_t *ptep;
        pmap_paddr_t pa;
-
+       mp_disable_preemption();
        if ((ptep = pmap_pte(kernel_pmap, (vm_map_offset_t)addr)) == PT_ENTRY_NULL) {
-               pa = 0;
+         pa = 0;
        } else {
-               pa =  pte_to_pa(*ptep) | (addr & INTEL_OFFMASK);
+         pa =  pte_to_pa(*ptep) | (addr & INTEL_OFFMASK);
        }
+       mp_enable_preemption_no_check();
 
        return ((addr64_t)pa);
 }