diff options
-rw-r--r-- | product/n1sdp/module/n1sdp_system/include/mod_n1sdp_system.h | 13 | ||||
-rw-r--r-- | product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c | 55 | ||||
-rw-r--r-- | product/n1sdp/scp_ramfw/config_armv7m_mpu.c | 8 |
3 files changed, 54 insertions, 22 deletions
diff --git a/product/n1sdp/module/n1sdp_system/include/mod_n1sdp_system.h b/product/n1sdp/module/n1sdp_system/include/mod_n1sdp_system.h index bd56147f..1830132d 100644 --- a/product/n1sdp/module/n1sdp_system/include/mod_n1sdp_system.h +++ b/product/n1sdp/module/n1sdp_system/include/mod_n1sdp_system.h @@ -31,10 +31,15 @@ * firmware to internal/external memory and set the RVBAR register of the * AP cores to corresponding memory's base address and then switch ON * the PPU of primary core to release from reset. This macro specifies the - * base address of the memory (DDR) to which AP firmware will be copied to - * and therefore the value to set in the RVBAR of all AP cores. + * base address of the Trusted AP SRAM to which AP firmware will be copied + * to and therefore the value to set in the RVBAR of all AP cores. */ -#define AP_CPU_RESET_ADDR UINT64_C(0xFF000000) + +/*! Offset of the Trusted SRAM between AP and SCP Address Space*/ +#define AP_SCP_SRAM_OFFSET UINT32_C(0xA0000000) + +/*! AP Cores Reset Address in SCP Address Space */ +#define AP_CORE_RESET_ADDR UINT64_C(0xA4040000) /*! DDR Base address where AP BL33 (UEFI) will be copied to. */ #define AP_BL33_BASE_ADDR UINT64_C(0xE0000000) @@ -46,7 +51,7 @@ * Number of bits to shift in AP's memory map address to map to SCP's * 1MB window. */ -#define SCP_AP_1MB_WINDOW_ADDR_SHIFT 20 +#define SCP_AP_1MB_WINDOW_ADDR_SHIFT 20 /*! * \brief API indices. diff --git a/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c b/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c index 6f5375d7..6041dd92 100644 --- a/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c +++ b/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c @@ -157,9 +157,35 @@ struct mod_n1sdp_system_ap_memory_access_api .disable_ap_memory_access = n1sdp_system_disable_ap_memory_access, }; -static int n1sdp_system_copy_to_ap_memory(uint64_t dram_address, - uint32_t spi_address, - uint32_t size) +/* + * Function to copy into AP SRAM. + */ +static int n1sdp_system_copy_to_ap_sram(uint64_t sram_address, + uint32_t spi_address, + uint32_t size) +{ + uint32_t target_addr = (uint32_t)sram_address; + + memcpy((void *)target_addr, (void *)spi_address, size); + + if (memcmp((void *)target_addr, (void *)spi_address, size) != 0) { + n1sdp_system_ctx.log_api->log(MOD_LOG_GROUP_INFO, + "[N1SDP SYSTEM] Copy failed at destination address: 0x%08x\n", + target_addr); + return FWK_E_DATA; + } + n1sdp_system_ctx.log_api->log(MOD_LOG_GROUP_INFO, + "[N1SDP SYSTEM] Copied binary to SRAM address: 0x%08x\n", + sram_address); + return FWK_SUCCESS; +} + +/* + * Function to copy into DRAM location + */ +static int n1sdp_system_copy_to_ap_ddr(uint64_t dram_address, + uint32_t spi_address, + uint32_t size) { uint32_t scp_address = 0; uint32_t copy_size = 0; @@ -179,9 +205,9 @@ static int n1sdp_system_copy_to_ap_memory(uint64_t dram_address, /* Get the size for this copy operation. */ if (size > (SCP_AP_1MB_WINDOW_SIZE - addr_offset)) { /* - * If the copy operation will wrap around the end of the 1MB window - * we need to cut it off at the wrap around point and change the - * the window address. + * If the copy operation will wrap around the end of the + * 1MB window we need to cut it off at the wrap around + * point and change the window address. */ copy_size = (uint32_t)(SCP_AP_1MB_WINDOW_SIZE - addr_offset); } else { @@ -366,9 +392,9 @@ static int n1sdp_system_process_notification(const struct fwk_event *event, n1sdp_system_ctx.log_api->log(MOD_LOG_GROUP_INFO, "[N1SDP SYSTEM] Copying AP BL31 to address 0x%x...\n", - AP_CPU_RESET_ADDR); + AP_CORE_RESET_ADDR); - status = n1sdp_system_copy_to_ap_memory(AP_CPU_RESET_ADDR, + status = n1sdp_system_copy_to_ap_sram(AP_CORE_RESET_ADDR, fip_desc_table[fip_index_bl31].address, fip_desc_table[fip_index_bl31].size); if (status != FWK_SUCCESS) @@ -378,7 +404,7 @@ static int n1sdp_system_process_notification(const struct fwk_event *event, "[N1SDP SYSTEM] Copying AP BL33 to address 0x%x...\n", AP_BL33_BASE_ADDR); - status = n1sdp_system_copy_to_ap_memory(AP_BL33_BASE_ADDR, + status = n1sdp_system_copy_to_ap_ddr(AP_BL33_BASE_ADDR, fip_desc_table[fip_index_bl33].address, fip_desc_table[fip_index_bl33].size); if (status != FWK_SUCCESS) @@ -388,17 +414,18 @@ static int n1sdp_system_process_notification(const struct fwk_event *event, n1sdp_system_ctx.log_api->log(MOD_LOG_GROUP_INFO, "[N1SDP SYSTEM] Setting AP Reset Address to 0x%x\n", - AP_CPU_RESET_ADDR); + AP_CORE_RESET_ADDR); cluster_count = n1sdp_core_get_cluster_count(); for (cluster_idx = 0; cluster_idx < cluster_count; cluster_idx++) { for (core_idx = 0; - core_idx < n1sdp_core_get_core_per_cluster_count(cluster_idx); - core_idx++) { + core_idx < n1sdp_core_get_core_per_cluster_count(cluster_idx); + core_idx++) { PIK_CLUSTER(cluster_idx)->STATIC_CONFIG[core_idx].RVBARADDR_LW - = (uint32_t)(AP_CPU_RESET_ADDR); + = (uint32_t)(AP_CORE_RESET_ADDR - AP_SCP_SRAM_OFFSET); PIK_CLUSTER(cluster_idx)->STATIC_CONFIG[core_idx].RVBARADDR_UP - = (uint32_t)(AP_CPU_RESET_ADDR >> 32); + = (uint32_t) + ((AP_CORE_RESET_ADDR - AP_SCP_SRAM_OFFSET) >> 32); } } diff --git a/product/n1sdp/scp_ramfw/config_armv7m_mpu.c b/product/n1sdp/scp_ramfw/config_armv7m_mpu.c index 84a92d5f..4149b197 100644 --- a/product/n1sdp/scp_ramfw/config_armv7m_mpu.c +++ b/product/n1sdp/scp_ramfw/config_armv7m_mpu.c @@ -27,20 +27,20 @@ static const ARM_MPU_Region_t regions[] = { .RASR = ARM_MPU_RASR( 1, ARM_MPU_AP_PRIV, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_256KB), }, - { /* 0xA400_0000 - 0xA400_0FFF*/ + { /* 0xA400_0000 - 0xA407_FFFF*/ .RBAR = ARM_MPU_RBAR(3, SCP_TRUSTED_RAM_BASE), .RASR = ARM_MPU_RASR( - 1, ARM_MPU_AP_PRIV, 0, 1, 1, 1, 0, ARM_MPU_REGION_SIZE_4KB), + 1, ARM_MPU_AP_PRIV, 0, 1, 1, 1, 0, ARM_MPU_REGION_SIZE_512KB), }, { /* 0x6540_0000 - 0x6540_00FF */ .RBAR = ARM_MPU_RBAR(4, SCP_AP_SHARED_SECURE_RAM), .RASR = ARM_MPU_RASR( 1, ARM_MPU_AP_PRIV, 0, 1, 1, 1, 0, ARM_MPU_REGION_SIZE_256B), }, - { /* 0x6520_0000 - 0x6520_00FF */ + { /* 0x6520_0000 - 0x6520_FFFF */ .RBAR = ARM_MPU_RBAR(5, SCP_AP_SHARED_NONSECURE_RAM), .RASR = ARM_MPU_RASR( - 1, ARM_MPU_AP_PRIV, 0, 1, 1, 1, 0, ARM_MPU_REGION_SIZE_256B), + 1, ARM_MPU_AP_PRIV, 0, 1, 1, 1, 0, ARM_MPU_REGION_SIZE_64KB), }, }; |