feat(zynqmp): add hooks for mmap and early setup
authorAmit Nagal <amit.nagal@amd.com>
Thu, 23 Feb 2023 16:07:23 +0000 (21:37 +0530)
committerAmit Nagal <amit.nagal@amd.com>
Fri, 24 Feb 2023 05:57:32 +0000 (11:27 +0530)
Add early setup hooks (via custom_early_setup()) and provide a way
to cover custom memory mapping which includes extending memory map
via custom_mmap_add().

This likely also require to align MAX_XLAT_TABLE, MAX_XLAT_TABLES
macros. It can be done for example by defining these macros in
custom_pkg.mk
MAX_MMAP_REGIONS := XY
$(eval $(call add_define,MAX_MMAP_REGIONS))
MAX_XLAT_TABLES := XZ
$(eval $(call add_define,MAX_XLAT_TABLES))

custom_early_setup() can be used for early low level operations
related to setting up the system to correct state.

Signed-off-by: Amit Nagal <amit.nagal@amd.com>
Change-Id: I61df6f9ba5af0bc97c430974fb10a2edde44f23d

plat/xilinx/zynqmp/bl31_zynqmp_setup.c
plat/xilinx/zynqmp/custom_sip_svc.c
plat/xilinx/zynqmp/include/custom_svc.h
plat/xilinx/zynqmp/include/platform_def.h

index 6bc57166922cdb5de553dcc8b567277bc08172dc..1d963e82ad982d8173d4a63c5eb58b85f150cab1 100644 (file)
@@ -17,6 +17,7 @@
 #include <plat/common/platform.h>
 #include <lib/mmio.h>
 
+#include <custom_svc.h>
 #include <plat_startup.h>
 #include <plat_private.h>
 #include <zynqmp_def.h>
@@ -129,6 +130,9 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
        if (bl33_image_ep_info.pc != 0) {
                VERBOSE("BL31: Non secure code at 0x%lx\n", bl33_image_ep_info.pc);
        }
+
+       custom_early_setup();
+
 }
 
 #if ZYNQMP_WDT_RESTART
@@ -262,6 +266,8 @@ void bl31_plat_arch_setup(void)
                {0}
        };
 
+       custom_mmap_add();
+
        setup_page_tables(bl_regions, plat_arm_get_mmap());
        enable_mmu_el3(0);
 }
index 459aa39f22011be9a7e1e809c0ed7fa2c3688b2b..fbb0a33f75b80c4fd5d86f09f571829987cc5aee 100644 (file)
@@ -15,3 +15,11 @@ uint64_t custom_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2,
        WARN("Unimplemented SiP Service Call: 0x%x\n", smc_fid);
        SMC_RET1(handle, SMC_UNK);
 }
+
+void custom_early_setup(void)
+{
+}
+
+void custom_mmap_add(void)
+{
+}
index 389a7bcd71e9aacf4a359c05b706d2f4850c501c..ef0eb675cb2c37e18720c49288c6c2c959c4f85b 100644 (file)
@@ -13,4 +13,7 @@ uint64_t custom_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2,
                            uint64_t x3, uint64_t x4, void *cookie,
                            void *handle, uint64_t flags);
 
+void custom_early_setup(void);
+void custom_mmap_add(void);
+
 #endif /* CUSTOM_SVC_H */
index ffed0eee7eb7b308818b66c91b944f498a55102e..b46eb636ed6981d1fcca2e3d0760656950664251 100644 (file)
 
 #define PLAT_PHY_ADDR_SPACE_SIZE       (1ULL << 32)
 #define PLAT_VIRT_ADDR_SPACE_SIZE      (1ULL << 32)
+
+#ifndef MAX_MMAP_REGIONS
 #if (BL31_LIMIT < PLAT_DDR_LOWMEM_MAX)
 #define MAX_MMAP_REGIONS               8
-#define MAX_XLAT_TABLES                        8
 #else
 #define MAX_MMAP_REGIONS               7
+#endif
+#endif
+
+#ifndef MAX_XLAT_TABLES
+#if (BL31_LIMIT < PLAT_DDR_LOWMEM_MAX)
+#define MAX_XLAT_TABLES                        8
+#else
 #define MAX_XLAT_TABLES                        5
 #endif
+#endif
 
 #define CACHE_WRITEBACK_SHIFT   6
 #define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)