cactus: re-structure platform dependent files
This patch makes below changes to cactus:
- Platform dependent files are moved to spm/cactus/plat/arm/fvp
- Removes relative path dependency for cactus dts by copying it to build
directory.
- Platform dependent macros are defined in cactus_platform_def.h like
- Device base
- Console UART
- RX Base
- Execution context count
Change-Id: I59e3c3f8640e01e46fc91bee4d8ce4255eaf9737
Signed-off-by: Arunachalam Ganapathy <arunachalam.ganapathy@arm.com>
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index e6577c3..779fd38 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -7,6 +7,12 @@
include branch_protection.mk
include lib/xlat_tables_v2/xlat_tables.mk
+# Include cactus platform make file
+CACTUS_PLAT_PATH := $(shell find spm/cactus/plat -wholename '*/${PLAT}')
+ifneq (${CACTUS_PLAT_PATH},)
+ include ${CACTUS_PLAT_PATH}/platform.mk
+endif
+
CACTUS_DTB := $(BUILD_PLAT)/cactus.dtb
CACTUS_INCLUDES := \
@@ -69,16 +75,32 @@
$(eval $(call add_define,CACTUS_DEFINES,LOG_LEVEL))
$(eval $(call add_define,CACTUS_DEFINES,PLAT_${PLAT}))
-
$(CACTUS_DTB) : $(BUILD_PLAT)/cactus $(BUILD_PLAT)/cactus/cactus.elf
-$(CACTUS_DTB) : spm/cactus/cactus.dts
- @echo " DTBGEN spm/cactus/cactus.dts"
+$(CACTUS_DTB) : $(CACTUS_DTS)
+ @echo " DTBGEN $@"
${Q}tools/generate_dtb/generate_dtb.sh \
- cactus spm/cactus/cactus.dts $(BUILD_PLAT)
+ cactus ${CACTUS_DTS} $(BUILD_PLAT)
${Q}tools/generate_json/generate_json.sh \
- cactus $(PLAT) $(BUILD_TYPE)
+ cactus $(BUILD_PLAT)
@echo
@echo "Built $@ successfully"
@echo
cactus: $(CACTUS_DTB)
+
+# FDTS_CP copies flattened device tree sources
+# $(1) = output directory
+# $(2) = flattened device tree source file to copy
+define FDTS_CP
+ $(eval FDTS := $(addprefix $(1)/,$(notdir $(2))))
+FDTS_LIST += $(FDTS)
+$(FDTS): $(2) $(CACTUS_DTB)
+ @echo " CP $$<"
+ ${Q}cp $$< $$@
+endef
+
+ifdef FDTS_CP_LIST
+ $(eval files := $(filter %.dts,$(FDTS_CP_LIST)))
+ $(eval $(foreach file,$(files),$(call FDTS_CP,$(BUILD_PLAT),$(file))))
+cactus: $(FDTS_LIST)
+endif
diff --git a/spm/cactus/cactus_def.h b/spm/cactus/cactus_def.h
index be6f06a..83be35f 100644
--- a/spm/cactus/cactus_def.h
+++ b/spm/cactus/cactus_def.h
@@ -24,7 +24,7 @@
* RX/TX buffer used by VM's in SPM for memory sharing
* Each VM allocated 2 pages, one for RX and one for TX buffer.
*/
-#define CACTUS_RX_BASE ULL(0x7300000)
+#define CACTUS_RX_BASE PLAT_CACTUS_RX_BASE
#define CACTUS_TX_BASE CACTUS_RX_BASE + PAGE_SIZE
#define CACTUS_RX_TX_SIZE PAGE_SIZE * 2
diff --git a/spm/cactus/cactus_ffa_tests.c b/spm/cactus/cactus_ffa_tests.c
index a242e41..81970f7 100644
--- a/spm/cactus/cactus_ffa_tests.c
+++ b/spm/cactus/cactus_ffa_tests.c
@@ -6,6 +6,7 @@
#include <assert.h>
#include <debug.h>
#include <errno.h>
+#include <cactus_platform_def.h>
#include <cactus_def.h>
#include <ffa_helpers.h>
#include <sp_helpers.h>
@@ -121,9 +122,24 @@
const char *test_all = "Get all partitions info";
const struct ffa_partition_info expected_info[] = {
- {.id = SPM_VM_ID_FIRST, .exec_context = 8U, .properties = 0U}, /* Primary partition info */
- {.id = SPM_VM_ID_FIRST + 1U, .exec_context = 8U, .properties = 0U}, /* Secondary partition info */
- {.id = SPM_VM_ID_FIRST + 2U, .exec_context = 8U, .properties = 0U} /* Tertiary partition info */
+ /* Primary partition info */
+ {
+ .id = SPM_VM_ID_FIRST,
+ .exec_context = CACTUS_PRIMARY_EC_COUNT,
+ .properties = 0U
+ },
+ /* Secondary partition info */
+ {
+ .id = SPM_VM_ID_FIRST + 1U,
+ .exec_context = CACTUS_SECONDARY_EC_COUNT,
+ .properties = 0U
+ },
+ /* Tertiary partition info */
+ {
+ .id = SPM_VM_ID_FIRST + 2U,
+ .exec_context = CACTUS_TERTIARY_EC_COUNT,
+ .properties = 0U
+ }
};
announce_test_section_start(test_partition_info);
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index 0809716..acbe2af 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -9,6 +9,7 @@
#include "cactus.h"
#include "cactus_def.h"
+#include <cactus_platform_def.h>
#include "cactus_tests.h"
#include <debug.h>
#include <drivers/arm/pl011.h>
@@ -84,8 +85,9 @@
}
static const mmap_region_t cactus_mmap[] __attribute__((used)) = {
- /* DEVICE0 area includes UART2 necessary to console */
- MAP_REGION_FLAT(DEVICE0_BASE, DEVICE0_SIZE, MT_DEVICE | MT_RW),
+ /* PLAT_ARM_DEVICE0 area includes UART2 necessary to console */
+ MAP_REGION_FLAT(PLAT_ARM_DEVICE0_BASE, PLAT_ARM_DEVICE0_SIZE,
+ MT_DEVICE | MT_RW),
{0}
};
@@ -179,9 +181,9 @@
enable_mmu_el1(0);
if (ffa_id == SPM_VM_ID_FIRST) {
- console_init(PL011_UART2_BASE,
- PL011_UART2_CLK_IN_HZ,
- PL011_BAUDRATE);
+ console_init(CACTUS_PL011_UART_BASE,
+ CACTUS_PL011_UART_CLK_IN_HZ,
+ PL011_BAUDRATE);
set_putc_impl(PL011_AS_STDOUT);
diff --git a/spm/cactus/cactus-secondary.dts b/spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts
similarity index 100%
rename from spm/cactus/cactus-secondary.dts
rename to spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts
diff --git a/spm/cactus/cactus-tertiary.dts b/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts
similarity index 100%
rename from spm/cactus/cactus-tertiary.dts
rename to spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts
diff --git a/spm/cactus/cactus.dts b/spm/cactus/plat/arm/fvp/fdts/cactus.dts
similarity index 100%
rename from spm/cactus/cactus.dts
rename to spm/cactus/plat/arm/fvp/fdts/cactus.dts
diff --git a/spm/cactus/plat/arm/fvp/include/cactus_platform_def.h b/spm/cactus/plat/arm/fvp/include/cactus_platform_def.h
new file mode 100644
index 0000000..e879002
--- /dev/null
+++ b/spm/cactus/plat/arm/fvp/include/cactus_platform_def.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <platform_def.h>
+
+#ifndef CACTUS_PLATFORM_DEF_H
+#define CACTUS_PLATFORM_DEF_H
+
+#define PLAT_ARM_DEVICE0_BASE DEVICE0_BASE
+#define PLAT_ARM_DEVICE0_SIZE DEVICE0_SIZE
+
+#define CACTUS_PL011_UART_BASE PL011_UART2_BASE
+#define CACTUS_PL011_UART_CLK_IN_HZ PL011_UART2_CLK_IN_HZ
+
+#define PLAT_CACTUS_RX_BASE ULL(0x7300000)
+
+#define CACTUS_PRIMARY_EC_COUNT (8U)
+#define CACTUS_SECONDARY_EC_COUNT (8U)
+#define CACTUS_TERTIARY_EC_COUNT (8U)
+
+#endif /* CACTUS_PLATFORM_DEF_H */
diff --git a/spm/cactus/plat/arm/fvp/platform.mk b/spm/cactus/plat/arm/fvp/platform.mk
new file mode 100644
index 0000000..c7b01bb
--- /dev/null
+++ b/spm/cactus/plat/arm/fvp/platform.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (c) 2020, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+FVP_CACTUS_BASE = spm/cactus/plat/arm/fvp
+
+PLAT_INCLUDES += -I${FVP_CACTUS_BASE}/include/
+
+# Add the FDT source
+CACTUS_DTS = ${FVP_CACTUS_BASE}/fdts/cactus.dts
+
+# List of FDTS to copy
+FDTS_CP_LIST = ${FVP_CACTUS_BASE}/fdts/cactus.dts
+FDTS_CP_LIST += ${FVP_CACTUS_BASE}/fdts/cactus-secondary.dts
+FDTS_CP_LIST += ${FVP_CACTUS_BASE}/fdts/cactus-tertiary.dts