]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/pmap.h
xnu-1228.15.4.tar.gz
[apple/xnu.git] / osfmk / i386 / pmap.h
index 67bccdd41fdacdc13f01d1e33b6df2d85c4a6708..90f9ff8d77474d23faa3c92a07fb51f59f8fd98d 100644 (file)
@@ -1,23 +1,29 @@
 /*
  * Copyright (c) 2000-2007 Apple 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@
@@ -167,7 +173,7 @@ pmap_store_pte(pt_entry_t *entryp, pt_entry_t value)
         * If the compare succeeds, the new value will have been stored.
         * Otherwise, the old value changed and reloaded, so try again.
         */
-       asm volatile(
+       __asm__ volatile(
                "       movl    (%0), %%eax     \n\t"
                "       movl    4(%0), %%edx    \n\t"
                "1:                             \n\t"
@@ -212,6 +218,7 @@ pmap_cmpx_pte(pt_entry_t *entryp, pt_entry_t old, pt_entry_t new)
 #define pmap_update_pte(entryp, old, new) \
        while (!pmap_cmpx_pte((entryp), (old), (new)))
 
+
 /* in 64 bit spaces, the number of each type of page in the page tables */
 #define NPML4PGS        (1ULL * (PAGE_SIZE/(sizeof (pml4_entry_t))))
 #define NPDPTPGS        (NPML4PGS * (PAGE_SIZE/(sizeof (pdpt_entry_t))))
@@ -385,6 +392,10 @@ extern pdpt_entry_t *IdlePDPT64;
 extern addr64_t     kernel64_cr3;
 extern boolean_t    no_shared_cr3;
 
+extern uint64_t pmap_pv_hashlist_walks;
+extern uint64_t pmap_pv_hashlist_cnts;
+extern uint32_t pmap_pv_hashlist_max;
+
 /*
  * virtual address to page table entry and
  * to physical address. Likewise for alternate address space.
@@ -415,9 +426,7 @@ struct pmap {
         vm_object_t     pm_obj;         /* object to hold pde's */
        int             ref_count;      /* reference count */
         int            nx_enabled;
-        boolean_t       pm_64bit;
-        boolean_t       pm_kernel_cr3;
-        boolean_t       pm_shared;
+        task_map_t      pm_task_map;
        decl_simple_lock_data(,lock)    /* lock on map */
        struct pmap_statistics  stats;  /* map statistics */
        vm_offset_t     pm_hold;        /* true pdpt zalloc addr */
@@ -427,6 +436,7 @@ struct pmap {
        vm_object_t     pm_obj_pdpt;    /* holds pdpt pages */
        vm_object_t     pm_obj_pml4;    /* holds pml4 pages */
        vm_object_t     pm_obj_top;     /* holds single top level page */
+        boolean_t       pm_shared;
 };
 
 
@@ -455,6 +465,8 @@ typedef struct cpu_pmap {
 
 
 extern mapwindow_t *pmap_get_mapwindow(pt_entry_t pentry);
+extern void         pmap_put_mapwindow(mapwindow_t *map);
+
 
 typedef struct pmap_memory_regions {
   ppnum_t base;
@@ -472,7 +484,7 @@ extern pmap_memory_region_t pmap_memory_regions[];
 
 static inline void set_dirbase(pmap_t tpmap, __unused int tcpu) {
        current_cpu_datap()->cpu_task_cr3 = (pmap_paddr_t)((tpmap)->pm_cr3);
-       current_cpu_datap()->cpu_task_map = tpmap->pm_64bit ? TASK_MAP_64BIT : TASK_MAP_32BIT;
+       current_cpu_datap()->cpu_task_map = tpmap->pm_task_map;
 }
 
 /*
@@ -489,6 +501,10 @@ extern void                pmap_update_interrupt(void);
 extern addr64_t                (kvtophys)(
                                vm_offset_t     addr);
 
+extern void            pmap_expand(
+                               pmap_t          pmap,
+                               vm_map_offset_t addr);
+
 extern pt_entry_t      *pmap_pte(
                                struct pmap     *pmap,
                                vm_map_offset_t addr);
@@ -557,13 +573,8 @@ extern void                pmap_map_block(
 extern void invalidate_icache(vm_offset_t addr, unsigned cnt, int phys);
 extern void flush_dcache(vm_offset_t addr, unsigned count, int phys);
 extern ppnum_t          pmap_find_phys(pmap_t map, addr64_t va);
-extern void pmap_sync_page_data_phys(ppnum_t pa);
-extern void pmap_sync_page_attributes_phys(ppnum_t pa);
 
-extern kern_return_t pmap_nest(pmap_t grand, pmap_t subord, addr64_t vstart, addr64_t nstart, uint64_t size);
-extern kern_return_t pmap_unnest(pmap_t grand, addr64_t vaddr);
-extern void pmap_map_sharedpage(task_t task, pmap_t pmap);
-extern void pmap_unmap_sharedpage(pmap_t pmap);
+extern void pmap_cpu_init(void);
 extern void pmap_disable_NX(pmap_t pmap);
 extern void pmap_set_4GB_pagezero(pmap_t pmap);
 extern void pmap_clear_4GB_pagezero(pmap_t pmap);
@@ -618,9 +629,10 @@ extern void pt_fake_zone_info(int *, vm_size_t *, vm_size_t *, vm_size_t *, vm_s
         set_dirbase(tpmap, my_cpu);                                    \
 }
 
-#define PMAP_DEACTIVATE_MAP(map, my_cpu)                                \
-        if (current_cpu_datap()->cpu_task_map == TASK_MAP_64BIT_SHARED) \
-            pmap_load_kernel_cr3();
+#define PMAP_DEACTIVATE_MAP(map, my_cpu)                               \
+       if (vm_map_pmap(map)->pm_task_map == TASK_MAP_64BIT_SHARED)     \
+               pmap_load_kernel_cr3();
+       
 
 #define PMAP_ACTIVATE_USER(th, my_cpu)  {                              \
         spl_t          spl;                                            \
@@ -651,7 +663,7 @@ extern void pt_fake_zone_info(int *, vm_size_t *, vm_size_t *, vm_size_t *, vm_s
                 if (new_th->machine.copy_window[i].user_base != (user_addr_t)-1) {     \
                        updp = pmap_pde(new_th->map->pmap,              \
                               new_th->machine.copy_window[i].user_base);\
-                       pmap_store_pte(kpdp,  updp ? *updp : 0);        \
+                        pmap_store_pte(kpdp, updp ? *updp : 0);                \
                 }                                                      \
                 kpdp++;                                                        \
         }                                                              \
@@ -661,8 +673,8 @@ extern void pt_fake_zone_info(int *, vm_size_t *, vm_size_t *, vm_size_t *, vm_s
         else                                                           \
                 new_th->machine.copyio_state = WINDOWS_DIRTY;          \
         if (new_th->machine.physwindow_pte) {                          \
-                pmap_store_pte((current_cpu_datap()->cpu_physwindow_ptep),     \
-                                new_th->machine.physwindow_pte);       \
+         pmap_store_pte((current_cpu_datap()->cpu_physwindow_ptep),    \
+                              new_th->machine.physwindow_pte);         \
                 if (need_flush == 0)                                   \
                         invlpg((uintptr_t)current_cpu_datap()->cpu_physwindow_base);\
         }                                                              \
@@ -697,8 +709,8 @@ extern void pt_fake_zone_info(int *, vm_size_t *, vm_size_t *, vm_size_t *, vm_s
 #define CPU_CR3_IS_ACTIVE(cpu)                                         \
        ((cpu_datap(cpu)->cpu_active_cr3 & 1) == 0)
 
-#define CPU_GET_ACTIVE_CR3(cpu)                                         \
-        (cpu_datap(cpu)->cpu_active_cr3 & ~1)
+#define CPU_GET_ACTIVE_CR3(cpu)                                                \
+       (cpu_datap(cpu)->cpu_active_cr3 & ~1)
 
 #define MARK_CPU_IDLE(my_cpu)  {                                       \
        /*                                                              \
@@ -747,12 +759,18 @@ extern void pt_fake_zone_info(int *, vm_size_t *, vm_size_t *, vm_size_t *, vm_s
 
 
 #define pmap_resident_count(pmap)      ((pmap)->stats.resident_count)
+#define pmap_resident_max(pmap)                ((pmap)->stats.resident_max)
 #define        pmap_copy(dst_pmap,src_pmap,dst_addr,len,src_addr)
 #define        pmap_attribute(pmap,addr,size,attr,value) \
                                        (KERN_INVALID_ADDRESS)
 #define        pmap_attribute_cache_sync(addr,size,attr,value) \
                                        (KERN_INVALID_ADDRESS)
 
+#define MACHINE_PMAP_IS_EMPTY 1
+extern boolean_t pmap_is_empty(pmap_t          pmap,
+                              vm_map_offset_t  start,
+                              vm_map_offset_t  end);
+
 #endif /* ASSEMBLER */