Initial IOMMU driver hooks.

This is intentially stripped back to initialization and a hook to the
driver when the VM's memory map is changing. This will work as the
baseline from which changes can be made to fit the needs of the drivers.

Change-Id: I904279f511e2d6e4b1c062fb49a2892042b79005
diff --git a/src/mm_test.cc b/src/mm_test.cc
index 839a6e7..887d16c 100644
--- a/src/mm_test.cc
+++ b/src/mm_test.cc
@@ -28,6 +28,8 @@
 #include <span>
 #include <vector>
 
+#include "mm_test.hh"
+
 namespace
 {
 using namespace ::std::placeholders;
@@ -40,6 +42,8 @@
 using ::testing::SizeIs;
 using ::testing::Truly;
 
+using ::mm_test::get_ptable;
+
 constexpr size_t TEST_HEAP_SIZE = PAGE_SIZE * 16;
 const int TOP_LEVEL = arch_mm_stage2_max_level();
 const paddr_t VM_MEM_END = pa_init(0x200'0000'0000);
@@ -73,21 +77,6 @@
 	return std::span<pte_t>(table->entries, std::end(table->entries));
 }
 
-/**
- * Get an STL representation of the ptable.
- */
-std::vector<std::span<pte_t, MM_PTE_PER_PAGE>> get_ptable(
-	const struct mm_ptable &ptable)
-{
-	std::vector<std::span<pte_t, MM_PTE_PER_PAGE>> all;
-	const uint8_t root_table_count = arch_mm_stage2_root_table_count();
-	for (uint8_t i = 0; i < root_table_count; ++i) {
-		all.push_back(get_table(
-			pa_add(ptable.root, i * sizeof(struct mm_page_table))));
-	}
-	return all;
-}
-
 class mm : public ::testing::Test
 {
 	void SetUp() override
@@ -698,20 +687,6 @@
 }
 
 /**
- * If nothing is mapped, unmapping the hypervisor has no effect.
- */
-TEST_F(mm, vm_unmap_hypervisor_not_mapped)
-{
-	struct mm_ptable ptable;
-	ASSERT_TRUE(mm_vm_init(&ptable, &ppool));
-	EXPECT_TRUE(mm_vm_unmap_hypervisor(&ptable, &ppool));
-	EXPECT_THAT(
-		get_ptable(ptable),
-		AllOf(SizeIs(4), Each(Each(arch_mm_absent_pte(TOP_LEVEL)))));
-	mm_vm_fini(&ptable, &ppool);
-}
-
-/**
  * If range is not mapped, unmapping has no effect.
  */
 TEST_F(mm, unmap_not_mapped)
@@ -1199,3 +1174,22 @@
 }
 
 } /* namespace */
+
+namespace mm_test
+{
+/**
+ * Get an STL representation of the ptable.
+ */
+std::vector<std::span<pte_t, MM_PTE_PER_PAGE>> get_ptable(
+	const struct mm_ptable &ptable)
+{
+	std::vector<std::span<pte_t, MM_PTE_PER_PAGE>> all;
+	const uint8_t root_table_count = arch_mm_stage2_root_table_count();
+	for (uint8_t i = 0; i < root_table_count; ++i) {
+		all.push_back(get_table(
+			pa_add(ptable.root, i * sizeof(struct mm_page_table))));
+	}
+	return all;
+}
+
+} /* namespace mm_test */