Merge changes from topic "xlnx_versal_custom_sip" into integration
* changes:
feat(versal): add hooks for mmap and early setup
refactor(zynqmp): refactor custom sip service
diff --git a/docs/plat/xilinx-versal.rst b/docs/plat/xilinx-versal.rst
index 7185d91..a654a0b 100644
--- a/docs/plat/xilinx-versal.rst
+++ b/docs/plat/xilinx-versal.rst
@@ -59,6 +59,57 @@
- `6` : SGI 6 (Default)
- `7` : SGI 7
+Configurable Stack Size
+-----------------------
+
+The stack size in TF-A for the Versal platform is configurable.
+The custom package can define the desired stack size as per the requirement in
+the makefile as follows:
+
+.. code-block:: shell
+
+ PLATFORM_STACK_SIZE := <value>
+
+ $(eval $(call add_define,PLATFORM_STACK_SIZE))
+
+CUSTOM SIP Service Support
+--------------------------
+
+- Dedicated SMC FID ``VERSAL_SIP_SVC_CUSTOM(0x82002000)`` (32-bit) /
+ ``(0xC2002000)`` (64-bit) is used by a custom package for providing
+ CUSTOM SIP service.
+
+- By default, the platform provides a bare minimum definition for
+ ``custom_smc_handler`` in this service.
+
+- To use this service, the custom package should implement its own SMC handler
+ named ``custom_smc_handler``. Once the custom package is included in the
+ TF-A build, its definition of ``custom_smc_handler`` is enabled.
+
+Custom Package Makefile Fragment Inclusion in TF-A Build
+--------------------------------------------------------
+
+- Custom package is not directly part of the TF-A source.
+
+- ``<CUSTOM_PKG_PATH>`` is the location where the user clones a
+ custom package locally.
+
+- The custom package must implement a makefile fragment named
+ ``custom_pkg.mk`` so it can be included in the TF-A build.
+
+- ``custom_pkg.mk`` should specify all the rules to include custom package
+ specific header files, dependent libraries, and source files that are
+ required to be part of the TF-A build.
+
+- When ``<CUSTOM_PKG_PATH>`` is specified in the TF-A build command,
+ ``custom_pkg.mk`` is included from ``<CUSTOM_PKG_PATH>``.
+
+- Example TF-A build command:
+
+.. code-block:: shell
+
+ make CROSS_COMPILE=aarch64-none-elf- PLAT=versal RESET_TO_BL31=1 bl31 CUSTOM_PKG_PATH=<...>
+
# PLM->TF-A Parameter Passing
------------------------------
The PLM populates a data structure with image information for the TF-A. The TF-A
diff --git a/plat/xilinx/zynqmp/custom_sip_svc.c b/plat/xilinx/common/custom_sip_svc.c
similarity index 90%
rename from plat/xilinx/zynqmp/custom_sip_svc.c
rename to plat/xilinx/common/custom_sip_svc.c
index c39e4be..2cefb78 100644
--- a/plat/xilinx/zynqmp/custom_sip_svc.c
+++ b/plat/xilinx/common/custom_sip_svc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
+ * Copyright (c) 2022-2025, Advanced Micro Devices, Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
diff --git a/plat/xilinx/zynqmp/include/custom_svc.h b/plat/xilinx/common/include/custom_svc.h
similarity index 71%
rename from plat/xilinx/zynqmp/include/custom_svc.h
rename to plat/xilinx/common/include/custom_svc.h
index 242f3eb..2884b69 100644
--- a/plat/xilinx/zynqmp/include/custom_svc.h
+++ b/plat/xilinx/common/include/custom_svc.h
@@ -1,13 +1,13 @@
/*
- * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
+ * Copyright (c) 2022-2025, Advanced Micro Devices, Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef CUSTOM_SVC_H
#define CUSTOM_SVC_H
-#define ZYNQMP_SIP_SVC_CUSTOM U(0x82002000)
-#define ZYNQMP_SIP_SVC64_CUSTOM U(0xC2002000)
+#define SOC_SIP_SVC_CUSTOM U(0x82002000)
+#define SOC_SIP_SVC64_CUSTOM U(0xC2002000)
uint64_t custom_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2,
uint64_t x3, uint64_t x4, void *cookie,
diff --git a/plat/xilinx/versal/bl31_versal_setup.c b/plat/xilinx/versal/bl31_versal_setup.c
index befe36c..70b0fa6 100644
--- a/plat/xilinx/versal/bl31_versal_setup.c
+++ b/plat/xilinx/versal/bl31_versal_setup.c
@@ -18,8 +18,9 @@
#include <plat/common/platform.h>
#include <plat_arm.h>
#include <plat_console.h>
-#include <plat_clkfunc.h>
+#include <custom_svc.h>
+#include <plat_clkfunc.h>
#include <plat_fdt.h>
#include <plat_private.h>
#include <plat_startup.h>
@@ -143,6 +144,8 @@
NOTICE("BL31: Secure code at 0x%lx\n", bl32_image_ep_info.pc);
NOTICE("BL31: Non secure code at 0x%lx\n", bl33_image_ep_info.pc);
+
+ custom_early_setup();
}
static versal_intr_info_type_el3_t type_el3_interrupt_table[MAX_INTR_EL3];
@@ -220,6 +223,8 @@
if (rc != 0) {
panic();
}
+
+ custom_runtime_setup();
}
/*
@@ -248,6 +253,8 @@
{0}
};
+ custom_mmap_add();
+
setup_page_tables(bl_regions, plat_get_mmap());
enable_mmu(0);
}
diff --git a/plat/xilinx/versal/include/platform_def.h b/plat/xilinx/versal/include/platform_def.h
index a3886a4..d8b334a 100644
--- a/plat/xilinx/versal/include/platform_def.h
+++ b/plat/xilinx/versal/include/platform_def.h
@@ -17,7 +17,9 @@
******************************************************************************/
/* Size of cacheable stacks */
+#ifndef PLATFORM_STACK_SIZE
#define PLATFORM_STACK_SIZE U(0x440)
+#endif
#define PLATFORM_CORE_COUNT U(2)
#define PLAT_MAX_PWR_LVL U(1)
diff --git a/plat/xilinx/versal/platform.mk b/plat/xilinx/versal/platform.mk
index 8be4be6..83d2d6f 100644
--- a/plat/xilinx/versal/platform.mk
+++ b/plat/xilinx/versal/platform.mk
@@ -144,3 +144,9 @@
CORTEX_A72_H_INC := 1
$(eval $(call add_define, CORTEX_A72_H_INC))
endif
+
+ifdef CUSTOM_PKG_PATH
+include $(CUSTOM_PKG_PATH)/custom_pkg.mk
+else
+BL31_SOURCES += plat/xilinx/common/custom_sip_svc.c
+endif
diff --git a/plat/xilinx/versal/sip_svc_setup.c b/plat/xilinx/versal/sip_svc_setup.c
index bb3f728..5e7ce9e 100644
--- a/plat/xilinx/versal/sip_svc_setup.c
+++ b/plat/xilinx/versal/sip_svc_setup.c
@@ -13,6 +13,7 @@
#include <common/runtime_svc.h>
#include <tools_share/uuid.h>
+#include <custom_svc.h>
#include "ipi_mailbox_svc.h"
#include "pm_svc_main.h"
@@ -105,6 +106,11 @@
case VERSAL_SIP_SVC_VERSION:
SMC_RET2(handle, SIP_SVC_VERSION_MAJOR, SIP_SVC_VERSION_MINOR);
+ case SOC_SIP_SVC_CUSTOM:
+ case SOC_SIP_SVC64_CUSTOM:
+ return custom_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
+ handle, flags);
+
default:
WARN("Unimplemented SiP Service Call: 0x%x\n", smc_fid);
SMC_RET1(handle, SMC_UNK);
diff --git a/plat/xilinx/zynqmp/platform.mk b/plat/xilinx/zynqmp/platform.mk
index 27e5427..d2cb220 100644
--- a/plat/xilinx/zynqmp/platform.mk
+++ b/plat/xilinx/zynqmp/platform.mk
@@ -162,7 +162,7 @@
ifdef CUSTOM_PKG_PATH
include $(CUSTOM_PKG_PATH)/custom_pkg.mk
else
-BL31_SOURCES += plat/xilinx/zynqmp/custom_sip_svc.c
+BL31_SOURCES += plat/xilinx/common/custom_sip_svc.c
endif
ifneq (${RESET_TO_BL31},1)
diff --git a/plat/xilinx/zynqmp/sip_svc_setup.c b/plat/xilinx/zynqmp/sip_svc_setup.c
index 1baefb3..6d94422 100644
--- a/plat/xilinx/zynqmp/sip_svc_setup.c
+++ b/plat/xilinx/zynqmp/sip_svc_setup.c
@@ -105,8 +105,8 @@
case ZYNQMP_SIP_SVC_VERSION:
SMC_RET2(handle, SIP_SVC_VERSION_MAJOR, SIP_SVC_VERSION_MINOR);
- case ZYNQMP_SIP_SVC_CUSTOM:
- case ZYNQMP_SIP_SVC64_CUSTOM:
+ case SOC_SIP_SVC_CUSTOM:
+ case SOC_SIP_SVC64_CUSTOM:
return custom_smc_handler(smc_fid, x1, x2, x3, x4, cookie,
handle, flags);