1#------------------------------------------------------------------------------- 2# Copyright (c) 2020-2024, Arm Limited. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6#------------------------------------------------------------------------------- 7 8cmake_policy(SET CMP0076 NEW) 9set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) 10 11#========================= Platform region defs ===============================# 12 13target_include_directories(platform_region_defs 14 INTERFACE 15 partition 16) 17 18target_compile_definitions(platform_region_defs 19 INTERFACE 20 $<$<BOOL:${PLATFORM_PSA_ADAC_SECURE_DEBUG}>:PLATFORM_PSA_ADAC_SECURE_DEBUG> 21) 22 23#========================= Platform common defs ===============================# 24 25# Specify the location of platform specific build dependencies. 26target_sources(tfm_s 27 PRIVATE 28 Device/Source/startup_musca.c 29) 30 31# Use a common scatter file for Isolation L1 and L2, a dedicated one for Isolation L3 32# IAR is not supported for L3 33target_add_scatter_file(tfm_s 34 $<$<AND:$<VERSION_LESS:${TFM_ISOLATION_LEVEL},3>,$<C_COMPILER_ID:ARMClang>>:${PLATFORM_DIR}/ext/common/armclang/tfm_common_s.sct> 35 $<$<AND:$<VERSION_LESS:${TFM_ISOLATION_LEVEL},3>,$<C_COMPILER_ID:GNU>>:${PLATFORM_DIR}/ext/common/gcc/tfm_common_s.ld> 36 $<$<AND:$<VERSION_LESS:${TFM_ISOLATION_LEVEL},3>,$<C_COMPILER_ID:IAR>>:${PLATFORM_DIR}/ext/common/iar/tfm_common_s.icf> 37 $<$<AND:$<VERSION_EQUAL:${TFM_ISOLATION_LEVEL},3>,$<C_COMPILER_ID:ARMClang>>:${CMAKE_BINARY_DIR}/generated/platform/ext/common/armclang/tfm_isolation_l3.sct> 38 $<$<AND:$<VERSION_EQUAL:${TFM_ISOLATION_LEVEL},3>,$<C_COMPILER_ID:GNU>>:${CMAKE_BINARY_DIR}/generated/platform/ext/common/gcc/tfm_isolation_l3.ld> 39 $<$<AND:$<VERSION_EQUAL:${TFM_ISOLATION_LEVEL},3>,$<C_COMPILER_ID:IAR>>:${CMAKE_BINARY_DIR}/generated/platform/ext/common/iar/tfm_isolation_l3.icf> 40) 41 42if(BL2) 43 target_sources(bl2 44 PRIVATE 45 Device/Source/startup_musca.c 46 ) 47 target_add_scatter_file(bl2 48 $<$<C_COMPILER_ID:ARMClang>:Device/Source/armclang/musca_bl2.sct> 49 $<$<C_COMPILER_ID:GNU>:Device/Source/gcc/musca_bl2.ld> 50 $<$<C_COMPILER_ID:IAR>:Device/Source/iar/musca_bl2.icf> 51 ) 52endif() 53 54#========================= Platform Secure ====================================# 55 56target_include_directories(platform_s 57 PUBLIC 58 . 59 CMSIS_Driver 60 CMSIS_Driver/Config 61 Device/Config 62 Device/Include 63 Native_Driver 64 partition 65 services/include 66 Libraries 67 ${PLATFORM_DIR}/ext/target/arm/drivers/usart/pl011 68 INTERFACE 69 cc312 70) 71 72target_sources(platform_s 73 PRIVATE 74 CMSIS_Driver/Driver_QSPI_Flash.c 75 CMSIS_Driver/Driver_MPC.c 76 CMSIS_Driver/Driver_PPC.c 77 CMSIS_Driver/Driver_USART.c 78 Device/Source/device_definition.c 79 Device/Source/system_core_init.c 80 Native_Driver/mpc_sie200_drv.c 81 Native_Driver/mpu_armv8m_drv.c 82 Native_Driver/gpio_cmsdk_drv.c 83 Libraries/mt25ql_flash_lib.c 84 Native_Driver/qspi_ip6514e_drv.c 85 Native_Driver/musca_b1_scc_drv.c 86 Native_Driver/ppc_sse200_drv.c 87 ${PLATFORM_DIR}/ext/target/arm/drivers/usart/pl011/uart_pl011_drv.c 88 $<$<NOT:$<BOOL:${TFM_PARTITION_SLIH_TEST}>>:${CMAKE_CURRENT_SOURCE_DIR}/Native_Driver/timer_cmsdk_drv.c> 89 $<$<OR:$<BOOL:${TFM_S_REG_TEST}>,$<BOOL:${TFM_NS_REG_TEST}>>:${CMAKE_CURRENT_SOURCE_DIR}/plat_test.c> 90 $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${CMAKE_CURRENT_SOURCE_DIR}/services/src/tfm_platform_system.c> 91) 92 93target_compile_options(platform_s 94 PUBLIC 95 ${COMPILER_CMSE_FLAG} 96) 97 98target_sources(tfm_sprt 99 PRIVATE 100 # The SLIH test Partition accesses the timer as ARoT Partitions. 101 # Put the driver to SPRT so that the SLIH tests can access it. 102 $<$<BOOL:${TFM_PARTITION_SLIH_TEST}>:${CMAKE_CURRENT_SOURCE_DIR}/Native_Driver/timer_cmsdk_drv.c> 103) 104 105#========================= Platform BL2 =======================================# 106 107if(BL2) 108 target_sources(platform_bl2 109 PRIVATE 110 Device/Source/system_core_init.c 111 Device/Source/device_definition.c 112 ${PLATFORM_DIR}/ext/target/arm/drivers/usart/pl011/uart_pl011_drv.c 113 CMSIS_Driver/Driver_USART.c 114 Native_Driver/musca_b1_scc_drv.c 115 ) 116 117 target_include_directories(platform_bl2 118 PUBLIC 119 partition 120 Device/Include 121 INTERFACE 122 cc312 123 PRIVATE 124 . 125 CMSIS_Driver/Config 126 Device/Config 127 Native_Driver 128 ${PLATFORM_DIR}/ext/target/arm/drivers/usart/pl011 129 ${CMAKE_SOURCE_DIR}/bl2/ext/mcuboot/include # for fih.h interop only 130 ${MCUBOOT_PATH}/boot/bootutil/include # for fault_injection_hardening.h only 131 ${CMAKE_BINARY_DIR}/bl2/ext/mcuboot # for mcuboot_config.h only 132 Libraries 133 ) 134 135endif() 136 137#========================= tfm_adac ============================================# 138 139if (${PLATFORM_PSA_ADAC_SECURE_DEBUG}) 140 target_sources(platform_bl2 141 PRIVATE 142 systick_microsecond_timer.c 143 bl2/boot_hal_bl2.c 144 ) 145 146 target_compile_definitions(platform_bl2 147 PRIVATE 148 PLATFORM_PSA_ADAC_SECURE_DEBUG 149 ) 150 151 target_link_libraries(platform_bl2 152 PRIVATE 153 trusted-firmware-m-psa-adac 154 ) 155 156 target_link_libraries(trusted-firmware-m-psa-adac 157 PRIVATE 158 psa_adac_cc312 159 ) 160 161endif() 162 163#========================= tfm_spm ============================================# 164 165target_sources(tfm_spm 166 PRIVATE 167 target_cfg.c 168 tfm_hal_isolation.c 169 tfm_hal_platform.c 170 faults.c 171 $<$<OR:$<BOOL:${CONFIG_TFM_FLIH_API}>,$<BOOL:${CONFIG_TFM_SLIH_API}>>:${CMAKE_CURRENT_SOURCE_DIR}/tfm_interrupts.c> 172) 173 174#========================= Flash driver definition ===========================# 175 176add_library(flash_drivers STATIC) 177 178target_include_directories(flash_drivers 179 PRIVATE 180 ${PLATFORM_DIR}/ext/target/arm/drivers/usart/pl011 181 ${PLATFORM_DIR}/ext/driver 182 ${PLATFORM_DIR}/ext/common 183 ${PLATFORM_DIR}/include 184 Native_Driver 185 CMSIS_Driver/Config 186 Device/Config 187 Device/Include 188 Libraries 189 . 190) 191 192target_sources(flash_drivers 193 PRIVATE 194 CMSIS_Driver/Driver_GFC100_EFlash.c 195 Native_Driver/gfc100_eflash_drv.c 196 Native_Driver/musca_b1_eflash_drv.c 197 Device/Source/gfc100_eflash_definition.c 198) 199 200target_link_libraries(flash_drivers 201 PRIVATE 202 cmsis 203) 204 205if(BL2) 206 target_link_libraries(platform_bl2 207 PRIVATE 208 flash_drivers 209 ) 210endif() 211 212target_link_libraries(platform_s 213 PRIVATE 214 flash_drivers 215) 216 217#========================= Files for building NS side platform ================# 218install(FILES ${PLATFORM_DIR}/ext/driver/Driver_Common.h 219 ${PLATFORM_DIR}/ext/driver/Driver_Flash.h 220 ${PLATFORM_DIR}/ext/driver/Driver_USART.h 221 DESTINATION ${INSTALL_PLATFORM_NS_DIR}/ext/driver) 222 223install(FILES Device/Source/startup_musca.c 224 Device/Source/system_core_init.c 225 Device/Source/device_definition.c 226 DESTINATION ${INSTALL_PLATFORM_NS_DIR}/Device/Source 227) 228 229install(FILES ${PLATFORM_DIR}/ext/target/arm/drivers/usart/pl011/uart_pl011_drv.c 230 CMSIS_Driver/Driver_USART.c 231 Libraries/mt25ql_flash_lib.c 232 DESTINATION ${INSTALL_PLATFORM_NS_DIR} 233) 234 235install(DIRECTORY CMSIS_Driver/Config 236 DESTINATION ${INSTALL_PLATFORM_NS_DIR}/CMSIS_Driver 237) 238 239install(DIRECTORY Device/Config 240 Device/Include 241 DESTINATION ${INSTALL_PLATFORM_NS_DIR}/Device 242) 243 244install(DIRECTORY partition 245 Native_Driver 246 DESTINATION ${INSTALL_PLATFORM_NS_DIR} 247) 248 249install(FILES target_cfg.h 250 Libraries/mt25ql_flash_lib.h 251 tfm_peripherals_def.h 252 ${PLATFORM_DIR}/include/tfm_plat_defs.h 253 ${PLATFORM_DIR}/ext/target/arm/drivers/usart/pl011/uart_pl011_drv.h 254 ${PLATFORM_DIR}/ext/accelerator/cc312/crypto_accelerator_config.h 255 DESTINATION ${INSTALL_PLATFORM_NS_DIR}/include) 256 257# copy all files from active platform directory 258install(DIRECTORY ${TARGET_PLATFORM_PATH}/ns/ 259 DESTINATION ${INSTALL_PLATFORM_NS_DIR}) 260 261install(FILES ${TARGET_PLATFORM_PATH}/cpuarch.cmake 262 ${TARGET_PLATFORM_PATH}/config.cmake 263 DESTINATION ${INSTALL_PLATFORM_NS_DIR}) 264 265# Install linker scripts 266install(FILES Device/Source/armclang/musca_ns.sct 267 Device/Source/gcc/musca_ns.ld 268 Device/Source/iar/musca_ns.icf 269 DESTINATION ${INSTALL_PLATFORM_NS_DIR}/linker_scripts) 270 271# Install test configs 272install(DIRECTORY ${TARGET_PLATFORM_PATH}/tests 273 DESTINATION ${INSTALL_PLATFORM_NS_DIR}) 274