aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorYann Gautier <yann.gautier@st.com>2018-06-14 18:35:33 +0200
committerYann Gautier <yann.gautier@st.com>2018-06-14 18:35:33 +0200
commit39676357af8318b7ec624f8a26bcc7ea0fbc7040 (patch)
treea09c5775ab61614dba2402eaadca9f3ad06658c6 /include
parent1ebdbe79c7c04d62e870eadedd615bd2dcebe8bf (diff)
downloadplatform_external_arm-trusted-firmware-39676357af8318b7ec624f8a26bcc7ea0fbc7040.tar.gz
platform_external_arm-trusted-firmware-39676357af8318b7ec624f8a26bcc7ea0fbc7040.tar.bz2
platform_external_arm-trusted-firmware-39676357af8318b7ec624f8a26bcc7ea0fbc7040.zip
Add GENMASK macros
Import GENMASK_32 and GENMASK_64 macros from optee-os (permissive license). And default GENMASK is set to GENMASK_32 for AARCH32, and to GENMASK_64 for 64bit arch. fixes arm-software/tf-issues#596 Signed-off-by: Yann Gautier <yann.gautier@st.com> Signed-off-by: Nicolas Le Bayon <nicolas.le.bayon@st.com>
Diffstat (limited to 'include')
-rw-r--r--include/lib/utils_def.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/lib/utils_def.h b/include/lib/utils_def.h
index 31b129454..2975103f5 100644
--- a/include/lib/utils_def.h
+++ b/include/lib/utils_def.h
@@ -19,6 +19,23 @@
#define BIT(nr) (ULL(1) << (nr))
/*
+ * Create a contiguous bitmask starting at bit position @l and ending at
+ * position @h. For example
+ * GENMASK_64(39, 21) gives us the 64bit vector 0x000000ffffe00000.
+ */
+#define GENMASK_32(h, l) \
+ (((~UINT32_C(0)) << (l)) & (~UINT32_C(0) >> (32 - 1 - (h))))
+
+#define GENMASK_64(h, l) \
+ (((~UINT64_C(0)) << (l)) & (~UINT64_C(0) >> (64 - 1 - (h))))
+
+#ifdef AARCH32
+#define GENMASK GENMASK_32
+#else
+#define GENMASK GENMASK_64
+#endif
+
+/*
* This variant of div_round_up can be used in macro definition but should not
* be used in C code as the `div` parameter is evaluated twice.
*/