summaryrefslogtreecommitdiff
path: root/lib/xlat_tables_v2
diff options
context:
space:
mode:
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-06-21 14:39:16 +0100
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>2018-06-22 08:36:21 +0100
commit3a1b7b108aec527597075b48aa929a622fff23da (patch)
treec39255926ad02695b329b03263efb55db370a3de /lib/xlat_tables_v2
parent6d769420b098f36717c99d4a6a2455fd6bd8fd23 (diff)
xlat: Remove mmap_attr_t enum type
The values defined in this type are used in logical operations, which goes against MISRA Rule 10.1: "Operands shall not be of an inappropriate essential type". Now, `unsigned int` is used instead. This also allows us to move the dynamic mapping bit from 30 to 31. It was an undefined behaviour in the past because an enum is signed by default, and bit 31 corresponds to the sign bit. It is undefined behaviour to modify the sign bit. Now, bit 31 is free to use as it was originally meant to be. mmap_attr_t is now defined as an `unsigned int` for backwards compatibility. Change-Id: I6b31218c14b9c7fdabebe432de7fae6e90a97f34 Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Diffstat (limited to 'lib/xlat_tables_v2')
-rw-r--r--lib/xlat_tables_v2/xlat_tables_internal.c10
-rw-r--r--lib/xlat_tables_v2/xlat_tables_private.h27
2 files changed, 17 insertions, 20 deletions
diff --git a/lib/xlat_tables_v2/xlat_tables_internal.c b/lib/xlat_tables_v2/xlat_tables_internal.c
index 3b586b2a..5beb51e9 100644
--- a/lib/xlat_tables_v2/xlat_tables_internal.c
+++ b/lib/xlat_tables_v2/xlat_tables_internal.c
@@ -823,10 +823,8 @@ void mmap_add_region_ctx(xlat_ctx_t *ctx, const mmap_region_t *mm)
ctx->max_va = end_va;
}
-void mmap_add_region(unsigned long long base_pa,
- uintptr_t base_va,
- size_t size,
- mmap_attr_t attr)
+void mmap_add_region(unsigned long long base_pa, uintptr_t base_va, size_t size,
+ unsigned int attr)
{
mmap_region_t mm = MAP_REGION(base_pa, base_va, size, attr);
mmap_add_region_ctx(&tf_xlat_ctx, &mm);
@@ -947,8 +945,8 @@ int mmap_add_dynamic_region_ctx(xlat_ctx_t *ctx, mmap_region_t *mm)
return 0;
}
-int mmap_add_dynamic_region(unsigned long long base_pa,
- uintptr_t base_va, size_t size, mmap_attr_t attr)
+int mmap_add_dynamic_region(unsigned long long base_pa, uintptr_t base_va,
+ size_t size, unsigned int attr)
{
mmap_region_t mm = MAP_REGION(base_pa, base_va, size, attr);
return mmap_add_dynamic_region_ctx(&tf_xlat_ctx, &mm);
diff --git a/lib/xlat_tables_v2/xlat_tables_private.h b/lib/xlat_tables_v2/xlat_tables_private.h
index 07963b18..157dd039 100644
--- a/lib/xlat_tables_v2/xlat_tables_private.h
+++ b/lib/xlat_tables_v2/xlat_tables_private.h
@@ -12,27 +12,26 @@
#if PLAT_XLAT_TABLES_DYNAMIC
/*
- * Shifts and masks to access fields of an mmap_attr_t
+ * Private shifts and masks to access fields of an mmap attribute
*/
/* Dynamic or static */
-#define MT_DYN_SHIFT 30 /* 31 would cause undefined behaviours */
+#define MT_DYN_SHIFT U(31)
/*
* Memory mapping private attributes
*
- * Private attributes not exposed in the mmap_attr_t enum.
+ * Private attributes not exposed in the public header.
*/
-typedef enum {
- /*
- * Regions mapped before the MMU can't be unmapped dynamically (they are
- * static) and regions mapped with MMU enabled can be unmapped. This
- * behaviour can't be overridden.
- *
- * Static regions can overlap each other, dynamic regions can't.
- */
- MT_STATIC = 0 << MT_DYN_SHIFT,
- MT_DYNAMIC = 1 << MT_DYN_SHIFT
-} mmap_priv_attr_t;
+
+/*
+ * Regions mapped before the MMU can't be unmapped dynamically (they are
+ * static) and regions mapped with MMU enabled can be unmapped. This
+ * behaviour can't be overridden.
+ *
+ * Static regions can overlap each other, dynamic regions can't.
+ */
+#define MT_STATIC (U(0) << MT_DYN_SHIFT)
+#define MT_DYNAMIC (U(1) << MT_DYN_SHIFT)
#endif /* PLAT_XLAT_TABLES_DYNAMIC */