Merge "fix(fdt): reserved memory: detect existing region" into integration
diff --git a/common/fdt_fixup.c b/common/fdt_fixup.c
index 1bad74f..59b7543 100644
--- a/common/fdt_fixup.c
+++ b/common/fdt_fixup.c
@@ -197,6 +197,7 @@
uintptr_t base, size_t size)
{
int offs = fdt_path_offset(dtb, "/reserved-memory");
+ int node;
uint32_t addresses[4];
int ac, sc;
unsigned int idx = 0;
@@ -213,6 +214,24 @@
fdt_setprop(dtb, offs, "ranges", NULL, 0);
}
+ /* Check for existing regions */
+ fdt_for_each_subnode(node, dtb, offs) {
+ uintptr_t c_base;
+ size_t c_size;
+ int ret;
+
+ ret = fdt_get_reg_props_by_index(dtb, node, 0, &c_base, &c_size);
+ /* Ignore illegal subnodes */
+ if (ret != 0) {
+ continue;
+ }
+
+ /* existing region entirely contains the new region */
+ if (base >= c_base && (base + size) <= (c_base + c_size)) {
+ return 0;
+ }
+ }
+
if (ac > 1) {
addresses[idx] = cpu_to_fdt32(HIGH_BITS(base));
idx++;
diff --git a/plat/amd/versal2/platform.mk b/plat/amd/versal2/platform.mk
index c07fc36..1c977a3 100644
--- a/plat/amd/versal2/platform.mk
+++ b/plat/amd/versal2/platform.mk
@@ -116,6 +116,7 @@
plat/xilinx/common/versal.c \
${PLAT_PATH}/bl31_setup.c \
common/fdt_fixup.c \
+ common/fdt_wrappers.c \
${LIBFDT_SRCS} \
${PLAT_PATH}/sip_svc_setup.c \
${PLAT_PATH}/gicv3.c
diff --git a/plat/rpi/rpi4/platform.mk b/plat/rpi/rpi4/platform.mk
index cbfa6f2..c39a587 100644
--- a/plat/rpi/rpi4/platform.mk
+++ b/plat/rpi/rpi4/platform.mk
@@ -31,6 +31,7 @@
plat/common/plat_psci_common.c \
plat/rpi/common/rpi3_topology.c \
common/fdt_fixup.c \
+ common/fdt_wrappers.c \
${LIBFDT_SRCS} \
${GICV2_SOURCES}