]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ppc/mappings.c
xnu-792.6.22.tar.gz
[apple/xnu.git] / osfmk / ppc / mappings.c
index ebeef928bfddb25784a077989b51243b0a8aef41..2f80bc88c150f617a8a86582d1f3921790964442 100644 (file)
@@ -272,7 +272,7 @@ addr64_t mapping_remove(pmap_t pmap, addr64_t va) {         /* Remove a single mapping
  *                     perm                                    Mapping is permanent
  *                     cache inhibited                 Cache inhibited (used if use attribute or block set )
  *                     guarded                                 Guarded access (used if use attribute or block set )
- *             size                                            size of block (not used if not block)
+ *             size                                            size of block in pages - 1 (not used if not block)
  *             prot                                            VM protection bits
  *             attr                                            Cachability/Guardedness    
  *
@@ -337,6 +337,12 @@ addr64_t mapping_make(pmap_t pmap, addr64_t va, ppnum_t pa, unsigned int flags,
                 
                pattr = flags & (mmFlgCInhib | mmFlgGuarded);                   /* Use requested attributes */
                mflags |= mpBlock;                                                                              /* Show that this is a block */
+       
+               if(size > pmapSmallBlock) {                                                             /* Is it one? */
+                       if(size & 0x00001FFF) return mapRtBadSz;                        /* Fail if bigger than 256MB and not a 32MB multiple */
+                       size = size >> 13;                                                                      /* Convert to 32MB chunks */
+                       mflags = mflags | mpBSu;                                                        /* Show 32MB basic size unit */
+               }
        }
        
        wimg = 0x2;                                                                                                     /* Set basic PPC wimg to 0b0010 - Coherent */
@@ -348,7 +354,7 @@ addr64_t mapping_make(pmap_t pmap, addr64_t va, ppnum_t pa, unsigned int flags,
        if(flags & mmFlgPerm) mflags |= mpPerm;                                         /* Set permanent mapping */
        
        size = size - 1;                                                                                        /* Change size to offset */
-       if(size > 0xFFFF) return 1;                                                                     /* Leave if size is too big */
+       if(size > 0xFFFF) return mapRtBadSz;                                            /* Leave if size is too big */
        
        nlists = mapSetLists(pmap);                                                                     /* Set number of lists this will be on */
        
@@ -371,7 +377,7 @@ addr64_t mapping_make(pmap_t pmap, addr64_t va, ppnum_t pa, unsigned int flags,
                
                switch (rc) {
                        case mapRtOK:
-                               return 0;                                                                               /* Mapping added successfully */
+                               return mapRtOK;                                                                 /* Mapping added successfully */
                                
                        case mapRtRemove:                                                                       /* Remove in progress */
                                (void)mapping_remove(pmap, colladdr);                   /* Lend a helping hand to another CPU doing block removal */
@@ -379,12 +385,12 @@ addr64_t mapping_make(pmap_t pmap, addr64_t va, ppnum_t pa, unsigned int flags,
                                
                        case mapRtMapDup:                                                                       /* Identical mapping already present */
                                mapping_free(mp);                                                               /* Free duplicate mapping */
-                               return 0;                                                                               /* Return success */
+                               return mapRtOK;                                                                         /* Return success */
                                
                        case mapRtSmash:                                                                        /* Mapping already present but does not match new mapping */
                                mapping_free(mp);                                                               /* Free duplicate mapping */
-                               return (colladdr | 1);                                                  /* Return colliding address, with some dirt added to avoid
-                                                                                                                                   confusion if effective address is 0 */
+                               return (colladdr | mapRtSmash);                                 /* Return colliding address, with some dirt added to avoid
+                                                                                                                                  confusion if effective address is 0 */
                        default:
                                panic("mapping_make: hw_add_map failed - collision addr = %016llX, code = %02X, pmap = %08X, va = %016llX, mapping = %08X\n",
                                        colladdr, rc, pmap, va, mp);                            /* Die dead */
@@ -1739,6 +1745,23 @@ void mapping_phys_unused(ppnum_t pa) {
        
 }
        
+void mapping_hibernate_flush(void)
+{
+    int bank;
+    unsigned int page;
+    struct phys_entry * entry;
+
+    for (bank = 0; bank < pmap_mem_regions_count; bank++)
+    {
+       entry = (struct phys_entry *) pmap_mem_regions[bank].mrPhysTab;
+       for (page = pmap_mem_regions[bank].mrStart; page <= pmap_mem_regions[bank].mrEnd; page++)
+       {
+           hw_walk_phys(entry, hwpNoop, hwpNoop, hwpNoop, 0, hwpPurgePTE);
+           entry++;
+       }
+    }
+}
+