- if (machine_type("X86"))
+ if (machine_type("ARM"))
+ dd->machine_type = EM_ARM;
+ else if (machine_type("X86"))
dd->machine_type = EM_386;
else if (machine_type("X86_64"))
dd->machine_type = EM_X86_64;
@@ -516,6 +521,33 @@ page_is_cached(physaddr_t paddr)
}
/*
+ * Translate physical address in paddr to PFN number. This means normally that
+ * we just shift paddr by some constant. Some architectures need special
+ * handling for this, however.
+ */
+static ulong
+paddr_to_pfn(physaddr_t paddr)
+{
+ ulong pfn;
+
+ switch (dd->machine_type) {
+ case EM_ARM:
+ /*
+ * In ARM, PFN 0 means first page in kernel direct-mapped view.
+ * This is also first page in mem_map as well.
+ */
+ pfn = (paddr - machdep->machspec->phys_base) >> dd->block_shift;
+ break;
+
+ default:
+ pfn = paddr >> dd->block_shift;
+ break;
+ }
+
+ return pfn;
+}
+
+/*
* Cache the page's data.
*
* If an empty page cache location is available, take it. Otherwise, evict
@@ -560,7 +592,7 @@ cache_page(physaddr_t paddr)
dd->page_cache_hdr[i].pg_hit_count++;