summaryrefslogtreecommitdiffstats
path: root/arch/arm/cpu
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2024-01-04 15:17:43 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2024-01-08 11:00:59 +0100
commit8034246f9b62ea0a78bdb23768728cc87d209112 (patch)
tree46750c44b1ea6a54f7ed3ac3300ba5f7596cb930 /arch/arm/cpu
parentf5f98467e9fc7edfb1aa077eb587ec364feef954 (diff)
downloadbarebox-8034246f9b62ea0a78bdb23768728cc87d209112.tar.gz
barebox-8034246f9b62ea0a78bdb23768728cc87d209112.tar.xz
ARM: atf: add bl31 v2 calling method
Newer bl31 binaries require a slightly different parameter structure. This patch adds support for it. The code is taken from U-Boot and changed to static initializers for improved readability. Link: https://lore.barebox.org/20240104141746.165014-17-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/cpu')
-rw-r--r--arch/arm/cpu/atf.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/arch/arm/cpu/atf.c b/arch/arm/cpu/atf.c
index ccd540d32a..d01e20508c 100644
--- a/arch/arm/cpu/atf.c
+++ b/arch/arm/cpu/atf.c
@@ -80,3 +80,97 @@ void bl31_entry(uintptr_t bl31_entry, uintptr_t bl32_entry,
atf_entry(&bl31_params, fdt_addr);
}
+
+struct bl2_to_bl31_params_mem_v2 *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry,
+ uintptr_t bl33_entry, uintptr_t fdt_addr)
+{
+ static struct bl2_to_bl31_params_mem_v2 p = {
+ .bl_params = {
+ .h = {
+ .type = ATF_PARAM_BL_PARAMS,
+ .version = ATF_VERSION_2,
+ .size = sizeof(struct bl_params),
+ .attr = 0,
+ },
+ .head = &p.bl31_params_node,
+ },
+ .bl31_params_node = {
+ .image_id = ATF_BL31_IMAGE_ID,
+ .image_info = &p.bl31_image_info,
+ .ep_info = &p.bl31_ep_info,
+ .next_params_info = &p.bl32_params_node,
+ },
+ .bl32_params_node = {
+ .image_id = ATF_BL32_IMAGE_ID,
+ .image_info = &p.bl32_image_info,
+ .ep_info = &p.bl32_ep_info,
+ .next_params_info = &p.bl33_params_node,
+ },
+ .bl33_params_node = {
+ .image_id = ATF_BL33_IMAGE_ID,
+ .image_info = &p.bl33_image_info,
+ .ep_info = &p.bl33_ep_info,
+ .next_params_info = NULL,
+ },
+ .bl32_ep_info = {
+ .h = {
+ .type = ATF_PARAM_EP,
+ .version = ATF_VERSION_2,
+ .size = sizeof(struct entry_point_info),
+ .attr = ATF_EP_SECURE,
+ },
+ .spsr = SPSR_64(MODE_EL1, MODE_SP_ELX, DISABLE_ALL_EXECPTIONS),
+ },
+ .bl33_ep_info = {
+ .h = {
+ .type = ATF_PARAM_EP,
+ .version = ATF_VERSION_2,
+ .size = sizeof(struct entry_point_info),
+ .attr = ATF_EP_NON_SECURE,
+ },
+ .spsr = SPSR_64(MODE_EL2, MODE_SP_ELX, DISABLE_ALL_EXECPTIONS),
+ },
+ .bl33_image_info = {
+ .h = {
+ .type = ATF_PARAM_IMAGE_BINARY,
+ .version = ATF_VERSION_2,
+ .size = sizeof(struct atf_image_info),
+ .attr = 0,
+ },
+ },
+ .bl32_image_info = {
+ .h = {
+ .type = ATF_PARAM_IMAGE_BINARY,
+ .version = ATF_VERSION_2,
+ .size = sizeof(struct atf_image_info),
+ .attr = ATF_EP_SECURE,
+ },
+ },
+ .bl31_image_info = {
+ .h = {
+ .type = ATF_PARAM_IMAGE_BINARY,
+ .version = ATF_VERSION_2,
+ .size = sizeof(struct atf_image_info),
+ .attr = 0,
+ },
+ },
+ };
+
+ p.bl33_ep_info.args.arg0 = 0xffff & read_mpidr();
+ p.bl33_ep_info.pc = bl33_entry;
+ p.bl32_ep_info.args.arg3 = fdt_addr;
+ p.bl32_ep_info.pc = bl32_entry;
+
+ return &p;
+}
+
+void bl31_entry_v2(uintptr_t bl31_entry, struct bl_params *params, void *fdt_addr)
+{
+ void (*atf_entry)(struct bl_params *params, uintptr_t plat_params);
+
+ raw_write_daif(SPSR_EXCEPTION_MASK);
+
+ atf_entry = (void *)bl31_entry;
+
+ atf_entry(params, (uintptr_t)fdt_addr);
+}