Add alignment macros.
Introduces align_up, align_down and is_aligned macros that use compiler
builtins if available.
Note: when we fallback to the non-builtin case we could cast back from
uintptr_t to the original type using __typeof() if we accept the
non-standard extension.
Change-Id: Ie0c56f19cb0edc8a211d8c1182b9af5eb329cd8c
diff --git a/src/fdt_handler.c b/src/fdt_handler.c
index 4b0adf9..7afb2b4 100644
--- a/src/fdt_handler.c
+++ b/src/fdt_handler.c
@@ -286,8 +286,9 @@
}
/* Patch fdt to reserve primary VM memory. */
- fdt_add_mem_reservation(fdt, pa_addr(layout_primary_begin()) & ~0xfffff,
- 0x80000);
+ fdt_add_mem_reservation(
+ fdt, align_down(pa_addr(layout_primary_begin()), 0x100000),
+ 0x80000);
/* Patch fdt to reserve memory for secondary VMs. */
for (i = 0; i < p->reserved_ranges_count; ++i) {