refactor(mm): use typedefs
* Add typedefs for memory modes and attrs
* Add typedef for page table levels
* Add typedef for the ptable ASID
* Rewrite `MM_MODE_` macros to use shifts instead of writing the
value manually.
Change-Id: I783825777b4897692d48287fc689026a04ecba50
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/src/load.c b/src/load.c
index b2dc996..4f4c410 100644
--- a/src/load.c
+++ b/src/load.c
@@ -479,9 +479,9 @@
/**
* Convert the manifest memory region attributes to mode consumed by mm layer.
*/
-static uint32_t memory_region_attributes_to_mode(uint32_t attributes)
+static mm_mode_t memory_region_attributes_to_mode(uint32_t attributes)
{
- uint32_t mode = 0U;
+ mm_mode_t mode = 0U;
if ((attributes & MANIFEST_REGION_ATTR_READ) != 0U) {
mode |= MM_MODE_R;
@@ -499,7 +499,7 @@
(mode == (MM_MODE_R | MM_MODE_X)));
if ((attributes & MANIFEST_REGION_ATTR_SECURITY) != 0U) {
- mode |= arch_mm_extra_attributes_from_vm(HF_HYPERVISOR_VM_ID);
+ mode |= arch_mm_extra_mode_from_vm(HF_HYPERVISOR_VM_ID);
}
return mode;
@@ -508,9 +508,9 @@
/**
* Convert the manifest device region attributes to mode consumed by mm layer.
*/
-static uint32_t device_region_attributes_to_mode(uint32_t attributes)
+static mm_mode_t device_region_attributes_to_mode(uint32_t attributes)
{
- uint32_t mode = 0U;
+ mm_mode_t mode = 0U;
if ((attributes & MANIFEST_REGION_ATTR_READ) != 0U) {
mode |= MM_MODE_R;
@@ -523,7 +523,7 @@
assert((mode == (MM_MODE_R | MM_MODE_W)) || (mode == MM_MODE_R));
if ((attributes & MANIFEST_REGION_ATTR_SECURITY) != 0U) {
- mode |= arch_mm_extra_attributes_from_vm(HF_HYPERVISOR_VM_ID);
+ mode |= arch_mm_extra_mode_from_vm(HF_HYPERVISOR_VM_ID);
}
return mode | MM_MODE_D;
@@ -541,7 +541,7 @@
paddr_t region_begin;
paddr_t region_end;
size_t size;
- uint32_t map_mode;
+ mm_mode_t map_mode;
uint32_t attributes;
/* Map memory-regions */
@@ -673,7 +673,7 @@
bool has_fdt;
size_t kernel_size = 0;
const size_t mem_size = pa_difference(mem_begin, mem_end);
- uint32_t map_mode;
+ mm_mode_t map_mode;
bool is_el0_partition = manifest_vm->partition.run_time_el == S_EL0 ||
manifest_vm->partition.run_time_el == EL0;
size_t n;