+/*
+ * unsigned int mapping_tst_refmod(ppnum_t pa) - tests the reference and change bits of a physical page
+ *
+ * This routine takes a physical entry and runs through all mappings attached to it and tests
+ * their reference and changed bits.
+ */
+
+unsigned int mapping_tst_refmod(ppnum_t pa) { /* Tests the reference and change bits of a physical page */
+
+ unsigned int pindex, rc;
+ phys_entry_t *physent;
+
+ physent = mapping_phys_lookup(pa, &pindex); /* Get physical entry */
+ if (!physent) { /* Did we find the physical page? */
+ panic("mapping_tst_refmod: invalid physical page %08X\n", pa);
+ }
+
+ rc = hw_walk_phys(physent, hwpTRefCngPhy, hwpTRefCngMap, hwpNoop,
+ 0, hwpMergePTE); /* Test reference and change bits in page and mappings */
+ return (((rc & ppC)? VM_MEM_MODIFIED : 0) | ((rc & ppR)? VM_MEM_REFERENCED : 0));
+ /* Convert bits to generic format and return */
+
+}
+
+
+/*
+ * void mapping_clr_refmod(ppnum_t pa, unsigned int mask) - clears the reference and change bits specified
+ * by mask of a physical page
+ *
+ * This routine takes a physical entry and runs through all mappings attached to it and turns
+ * off all the reference and change bits.
+ */
+
+void mapping_clr_refmod(ppnum_t pa, unsigned int mask) { /* Clears the reference and change bits of a physical page */
+
+ unsigned int pindex;
+ phys_entry_t *physent;
+ unsigned int ppcMask;
+
+ physent = mapping_phys_lookup(pa, &pindex); /* Get physical entry */
+ if(!physent) { /* Did we find the physical page? */
+ panic("mapping_clr_refmod: invalid physical page %08X\n", pa);
+ }
+
+ ppcMask = (((mask & VM_MEM_MODIFIED)? ppC : 0) | ((mask & VM_MEM_REFERENCED)? ppR : 0));
+ /* Convert mask bits to PPC-specific format */
+ hw_walk_phys(physent, hwpNoop, hwpCRefCngMap, hwpCRefCngPhy,
+ ppcMask, hwpPurgePTE); /* Clear reference and change bits for page and mappings */
+ return; /* Leave... */
+}
+
+
+