@@ -45,6 +45,14 @@ void phys_alloc_set_minimum_alignment(phys_addr_t align)
align_min = align;
}
+void phys_alloc_perform_cache_maintenance(cache_maint_fn maint_fn)
+{
+ maint_fn((unsigned long)&base);
+ maint_fn((unsigned long)&used);
+ maint_fn((unsigned long)&top);
+ maint_fn((unsigned long)&align_min);
+}
+
static void *memalign_early(size_t alignment, size_t sz)
{
phys_addr_t align = (phys_addr_t)alignment;
@@ -15,6 +15,8 @@
*/
#include "libcflat.h"
+typedef void (*cache_maint_fn)(unsigned long addr);
+
/*
* phys_alloc_init creates the initial free memory region of size @size
* at @base. The minimum alignment is set to DEFAULT_MINIMUM_ALIGNMENT.
@@ -27,6 +29,12 @@ extern void phys_alloc_init(phys_addr_t base, phys_addr_t size);
*/
extern void phys_alloc_set_minimum_alignment(phys_addr_t align);
+/*
+ * Perform cache maintenance on the internal structures that the physical
+ * allocator maintains.
+ */
+extern void phys_alloc_perform_cache_maintenance(cache_maint_fn maint_fn);
+
/*
* phys_alloc_show outputs all currently allocated regions with the
* following format, where <end_addr> is non-inclusive:
Some architectures, like arm and arm64, require explicit cache maintenance to maintain the caches in sync with memory when toggling the caches. Add the function to do the required maintenance on the internal structures that the allocator maintains. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> --- lib/alloc_phys.c | 8 ++++++++ lib/alloc_phys.h | 8 ++++++++ 2 files changed, 16 insertions(+)