summaryrefslogtreecommitdiff
path: root/include/lib/utils.h
diff options
context:
space:
mode:
authorRoberto Vargas <roberto.vargas@arm.com>2017-08-03 08:56:38 +0100
committerRoberto Vargas <roberto.vargas@arm.com>2017-09-25 13:32:20 +0100
commit43cbaf061587e7e8b3529e4b1d30de3ab1b52d3e (patch)
tree5927fdd0deaf47d55ac8b33df63cc193a1966e14 /include/lib/utils.h
parentd4c596be87e0b04404fc10ee49544eda33c0f625 (diff)
Add mem_region utility functions
This commit introduces a new type (mem_region_t) used to describe memory regions and it adds two utility functions: - clear_mem_regions: This function clears (write 0) to a set of regions described with an array of mem_region_t. - mem_region_in_array_chk This function checks if a region is covered by some of the regions described with an array of mem_region_t. Change-Id: I12ce549f5e81dd15ac0981645f6e08ee7c120811 Signed-off-by: Roberto Vargas <roberto.vargas@arm.com>
Diffstat (limited to 'include/lib/utils.h')
-rw-r--r--include/lib/utils.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/lib/utils.h b/include/lib/utils.h
index b75813f7..cfc83022 100644
--- a/include/lib/utils.h
+++ b/include/lib/utils.h
@@ -19,6 +19,25 @@
#include <types.h>
+typedef struct mem_region_t {
+ uintptr_t base;
+ size_t nbytes;
+} mem_region_t;
+
+/*
+ * zero_normalmem all the regions defined in tbl.
+ */
+void clear_mem_regions(mem_region_t *tbl, size_t nregions);
+
+
+/*
+ * checks that a region (addr + nbytes-1) of memory is totally covered by
+ * one of the regions defined in tbl. Caller must ensure that (addr+nbytes-1)
+ * doesn't overflow.
+ */
+int mem_region_in_array_chk(mem_region_t *tbl, size_t nregions,
+ uintptr_t addr, size_t nbytes);
+
/*
* Fill a region of normal memory of size "length" in bytes with zero bytes.
*