mm: function to get the mode of a range of memory.

This supersedes mm_vm_is_mapped() since that is checking that the range
was not mapped with MM_MODE_INVALID.

Change-Id: Ic3d5018a6d207d092a7f6bf853b015eba22945bb
diff --git a/inc/hf/addr.h b/inc/hf/addr.h
index c37601d..08c7e12 100644
--- a/inc/hf/addr.h
+++ b/inc/hf/addr.h
@@ -53,6 +53,14 @@
 }
 
 /**
+ * Advances a physical address.
+ */
+static inline paddr_t pa_add(paddr_t pa, size_t n)
+{
+	return pa_init(pa_addr(pa) + n);
+}
+
+/**
  * Initializes an intermeditate physical address.
  */
 static inline ipaddr_t ipa_init(uintvaddr_t v)
@@ -69,6 +77,14 @@
 }
 
 /**
+ * Advances an intermediate physical address.
+ */
+static inline ipaddr_t ipa_add(ipaddr_t ipa, size_t n)
+{
+	return ipa_init(ipa_addr(ipa) + n);
+}
+
+/**
  * Initializes a virtual address.
  */
 static inline vaddr_t va_init(uintvaddr_t v)
@@ -85,14 +101,6 @@
 }
 
 /**
- * Advances a physical address.
- */
-static inline paddr_t pa_add(paddr_t pa, size_t n)
-{
-	return pa_init(pa_addr(pa) + n);
-}
-
-/**
  * Casts a physical address to a virtual address.
  */
 static inline vaddr_t va_from_pa(paddr_t pa)
diff --git a/inc/hf/arch/mm.h b/inc/hf/arch/mm.h
index fea5f65..d6c8211 100644
--- a/inc/hf/arch/mm.h
+++ b/inc/hf/arch/mm.h
@@ -134,6 +134,11 @@
 uint64_t arch_mm_mode_to_attrs(int mode);
 
 /**
+ * Converts the stage-2 block attributes back to the corresponding mode.
+ */
+int arch_mm_stage2_attrs_to_mode(uint64_t attrs);
+
+/**
  * Initializes the arch specific memory management state.
  */
 bool arch_mm_init(paddr_t table, bool first);
diff --git a/inc/hf/mm.h b/inc/hf/mm.h
index 8567acd..509d79e 100644
--- a/inc/hf/mm.h
+++ b/inc/hf/mm.h
@@ -109,7 +109,8 @@
 bool mm_vm_unmap(struct mm_ptable *t, paddr_t begin, paddr_t end, int mode,
 		 struct mpool *ppool);
 bool mm_vm_unmap_hypervisor(struct mm_ptable *t, int mode, struct mpool *ppool);
-bool mm_vm_is_mapped(struct mm_ptable *t, ipaddr_t ipa, int mode);
+bool mm_vm_get_mode(struct mm_ptable *t, ipaddr_t begin, ipaddr_t end,
+		    int *mode);
 
 bool mm_init(struct mpool *ppool);
 bool mm_cpu_init(void);