refactor(mm): replace max level with root level
The name `mm_max_level()` is misleading, since it is not actually the
maximum value that the level can be (since the root level is the "max"
level plus 1).
The use of `mm_max_level()` in `mm.c` was also inconsistent: sometimes
they call `mm_max_level() + 1` to calculate the root level, sometimes
they just pass `mm_max_level()` to recursive subcalls to process the
next level down. This made it hard to know when a plus or minus one was
needed and so ended up introducing off-by-one errors. Now, you always
start at `mm_root_level()` and pass `root_level - 1` to recursive
subcalls.
Also add explanatory comments explaining the level-related arithmetic.
Change-Id: I7b701d6d2c908db03c2853a008565126890e7959
Signed-off-by: Karl Meakin <karl.meakin@arm.com>
diff --git a/inc/hf/arch/mm.h b/inc/hf/arch/mm.h
index 5a5f249..ea9daab 100644
--- a/inc/hf/arch/mm.h
+++ b/inc/hf/arch/mm.h
@@ -136,17 +136,17 @@
/**
* Sets the maximum level allowed in the page table for stage-1.
*/
-void arch_mm_stage1_max_level_set(uint32_t pa_bits);
+void arch_mm_stage1_root_level_set(uint32_t pa_bits);
/**
* Gets the maximum level allowed in the page table for stage-1.
*/
-mm_level_t arch_mm_stage1_max_level(void);
+mm_level_t arch_mm_stage1_root_level(void);
/**
* Gets the maximum level allowed in the page table for stage-2.
*/
-mm_level_t arch_mm_stage2_max_level(void);
+mm_level_t arch_mm_stage2_root_level(void);
/**
* Gets the number of concatenated page tables used at the root for stage-1.