Better use of address types in mm.h.
These functions are called to map physical pages in and out of the
address space. It makes more sense for the APIs to use those physical
addresses and avoid mistakes or confusion in the conversions.
Once the physical address has been mapped it will be available as a
virtual address or pointer in the hypervisor and an intermediate
physical address in the VMs. The corresponding type is now returned from
the mapping functions to avoid complication or mistakes in conversion by
the caller and the vast majority of the address type conversions now
happen within mm.
Internally to mm, the stage 1 and stage 2 tables still share the same
management code so that is made generic for the type of input address
being used.
Change-Id: I9201b98b7329ead304903b8b8968c4378eb5a4db
diff --git a/inc/mm.h b/inc/mm.h
index 74158a7..6c539df 100644
--- a/inc/mm.h
+++ b/inc/mm.h
@@ -42,39 +42,21 @@
bool mm_ptable_init(struct mm_ptable *t, uint32_t id, int mode);
void mm_ptable_dump(struct mm_ptable *t, int mode);
-bool mm_ptable_identity_map(struct mm_ptable *t, vaddr_t begin, vaddr_t end,
- int mode);
-bool mm_ptable_identity_map_page(struct mm_ptable *t, vaddr_t va, int mode);
-bool mm_ptable_unmap(struct mm_ptable *t, vaddr_t begin, vaddr_t end, int mode);
-bool mm_ptable_is_mapped(struct mm_ptable *t, vaddr_t addr, int mode);
void mm_ptable_defrag(struct mm_ptable *t, int mode);
bool mm_ptable_unmap_hypervisor(struct mm_ptable *t, int mode);
+bool mm_vm_identity_map(struct mm_ptable *t, paddr_t begin, paddr_t end,
+ int mode, ipaddr_t *ipa);
+bool mm_vm_identity_map_page(struct mm_ptable *t, paddr_t begin, int mode,
+ ipaddr_t *ipa);
+bool mm_vm_unmap(struct mm_ptable *t, paddr_t begin, paddr_t end, int mode);
+bool mm_vm_is_mapped(struct mm_ptable *t, ipaddr_t ipa, int mode);
+bool mm_vm_translate(struct mm_ptable *t, ipaddr_t ipa, paddr_t *pa);
+
bool mm_init(void);
bool mm_cpu_init(void);
-bool mm_identity_map(vaddr_t begin, vaddr_t end, int mode);
-bool mm_unmap(vaddr_t begin, vaddr_t end, int mode);
+void *mm_identity_map(paddr_t begin, paddr_t end, int mode);
+bool mm_unmap(paddr_t begin, paddr_t end, int mode);
void mm_defrag(void);
-/**
- * Converts an intermediate physical address to a physical address. Addresses
- * are currently identity mapped so this is a simple type convertion. Returns
- * true if the address was mapped in the table and the address was converted.
- */
-static inline bool mm_ptable_translate_ipa(struct mm_ptable *t, ipaddr_t ipa,
- paddr_t *pa)
-{
- /* TODO: the ptable functions map physical to virtual addresses but they
- * should really be mapping to intermediate physical addresses.
- * It might be better to have different interfaces to the mm functions?
- * This might also mean ipaddr_t should be used when building the VM
- * tables too?
- * */
- if (mm_ptable_is_mapped(t, va_init(ipa_addr(ipa)), 0)) {
- *pa = pa_init(ipa_addr(ipa));
- return true;
- }
- return false;
-}
-
#endif /* _MM_H */