* 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
*
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 */
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 */
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 */
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 */
}
+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++;
+ }
+ }
+}
+