fix(gpt): fix RME GPT library bug
This patch fixes fill_l1_tbl() function bug
for RME_GPT_MAX_BLOCK build option set to 0
disabling filling L1 tables with Contiguous
descriptors.
Change-Id: I3eedd6c1bb55b7c207bb3630d1ab2fda8f72eb17
Signed-off-by: AlexeiFedorov <Alexei.Fedorov@arm.com>
diff --git a/lib/gpt_rme/gpt_rme.c b/lib/gpt_rme/gpt_rme.c
index 4d80373..ee502de 100644
--- a/lib/gpt_rme/gpt_rme.c
+++ b/lib/gpt_rme/gpt_rme.c
@@ -700,8 +700,8 @@
* Return
* Address of next granule in range.
*/
-static uintptr_t fill_l1_cont_desc(uint64_t *l1, uintptr_t first,
- size_t length, unsigned int gpi)
+__unused static uintptr_t fill_l1_cont_desc(uint64_t *l1, uintptr_t first,
+ size_t length, unsigned int gpi)
{
/*
* Look up table for contiguous blocks and descriptors.
@@ -826,8 +826,10 @@
/*
* Helper function to fill out GPI entries in a single L1 table.
- * This function fills out an entire L1 table with either Contiguous
- * or Granules descriptors depending on region length and alignment.
+ * This function fills out an entire L1 table with either Granules or Contiguous
+ * (RME_GPT_MAX_BLOCK != 0) descriptors depending on region length and alignment.
+ * Note. If RME_GPT_MAX_BLOCK == 0, then the L1 tables are filled with regular
+ * Granules descriptors.
*
* Parameters
* l1 Pointer to L1 table to fill out
@@ -844,13 +846,14 @@
assert((last & (GPT_PGS_ACTUAL_SIZE(gpt_config.p) - 1UL)) == 0UL);
assert(GPT_L0_IDX(first) == GPT_L0_IDX(last));
+#if (RME_GPT_MAX_BLOCK != 0)
while (first < last) {
/* Region length */
size_t length = last - first + GPT_PGS_ACTUAL_SIZE(gpt_config.p);
if (length < SZ_2M) {
/*
- * Fill with Granule descriptor in case of
+ * Fill with Granule descriptors in case of
* region length < 2MB.
*/
first = fill_l1_gran_desc(l1, first, last, gpi);
@@ -874,7 +877,10 @@
first = fill_l1_gran_desc(l1, first, new_last, gpi);
}
}
-
+#else
+ /* Fill with Granule descriptors */
+ first = fill_l1_gran_desc(l1, first, last, gpi);
+#endif
assert(first == (last + GPT_PGS_ACTUAL_SIZE(gpt_config.p)));
}