Map console with MM_MODE_D under hftests

When driving hftests over UART, EL1 needs direct access to the console,
i.e. not via HVCs to EL2. The corresponding MMIO pages need to be mapped
as device memory. To that end, we export the necessary stage1_locked and
mpool structs from hftest/mm.c and call plat_console_mm_init().

Change-Id: I170e391981b717d0ff787d9ef4eebe80241cfd29
diff --git a/test/hftest/ctrl_uart.c b/test/hftest/ctrl_uart.c
index da4d0d6..4bddf81 100644
--- a/test/hftest/ctrl_uart.c
+++ b/test/hftest/ctrl_uart.c
@@ -57,6 +57,9 @@
 {
 	(void)fdt;
 
+	/* Let the console driver map its memory as device memory. */
+	plat_console_mm_init(hftest_mm_get_stage1(), hftest_mm_get_ppool());
+
 	/* Initialize the console */
 	plat_console_init();
 
diff --git a/test/hftest/mm.c b/test/hftest/mm.c
index 7c78ab9..b31b387 100644
--- a/test/hftest/mm.c
+++ b/test/hftest/mm.c
@@ -27,11 +27,16 @@
 static struct mpool ppool;
 static struct mm_ptable ptable;
 
-static struct mm_stage1_locked get_stage1_locked(void)
+struct mm_stage1_locked hftest_mm_get_stage1(void)
 {
 	return (struct mm_stage1_locked){.ptable = &ptable};
 }
 
+struct mpool *hftest_mm_get_ppool(void)
+{
+	return &ppool;
+}
+
 bool hftest_mm_init(void)
 {
 	struct mm_stage1_locked stage1_locked;
@@ -45,7 +50,7 @@
 		HFTEST_FAIL(true, "Unable to allocate memory for page table.");
 	}
 
-	stage1_locked = get_stage1_locked();
+	stage1_locked = hftest_mm_get_stage1();
 	mm_identity_map(stage1_locked, pa_init(0),
 			pa_init(mm_ptable_addr_space_end(MM_FLAG_STAGE1)),
 			MM_MODE_R | MM_MODE_W | MM_MODE_X, &ppool);
@@ -61,7 +66,7 @@
 
 void hftest_mm_identity_map(const void *base, size_t size, uint32_t mode)
 {
-	struct mm_stage1_locked stage1_locked = get_stage1_locked();
+	struct mm_stage1_locked stage1_locked = hftest_mm_get_stage1();
 	paddr_t start = pa_from_va(va_from_ptr(base));
 	paddr_t end = pa_add(start, size);
 
diff --git a/test/inc/test/hftest.h b/test/inc/test/hftest.h
index 1dd65aa..6f141b9 100644
--- a/test/inc/test/hftest.h
+++ b/test/inc/test/hftest.h
@@ -107,6 +107,15 @@
 void hftest_mm_vcpu_init(void);
 
 /**
+ * Returns a pointer to stage-1 mappings.
+ * Note: There is no locking as all existing users are on the same vCPU.
+ */
+struct mm_stage1_locked hftest_mm_get_stage1(void);
+
+/** Returns a pointer to the page-table pool. */
+struct mpool *hftest_mm_get_ppool(void);
+
+/**
  * Inform a host that this is the start of a test run and obtain the command
  * line arguments for it.
  */