#------------------------------------------------------------------------------- # Copyright (c) 2020-2021, Arm Limited. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # #------------------------------------------------------------------------------- cmake_minimum_required(VERSION 3.15) cmake_policy(SET CMP0076 NEW) cmake_policy(SET CMP0079 NEW) add_library(platform_s STATIC) add_library(platform_region_defs INTERFACE) add_library(platform_common_interface INTERFACE) # under the multicore topology, NS is declared in the same place as the PSA # interface so that it picks up the compiler definitions for the NS CPU if(NOT TFM_MULTI_CORE_TOPOLOGY) add_library(platform_ns STATIC EXCLUDE_FROM_ALL) endif() if (BL2) add_library(platform_bl2 STATIC) endif() set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR}) add_subdirectory(ext/target/${TFM_PLATFORM} target) #========================= Platform Common interface ==========================# target_include_directories(platform_common_interface INTERFACE ./ext ./ext/cmsis ./ext/common ./ext/driver ./include ) #========================= Platform Secure ====================================# target_include_directories(platform_s PUBLIC $<$:${CMAKE_CURRENT_SOURCE_DIR}/ext/accelerator/interface> ) target_sources(platform_s PRIVATE $<$:${CMAKE_CURRENT_SOURCE_DIR}/ext/common/tfm_hal_ps.c> $<$:${CMAKE_CURRENT_SOURCE_DIR}/ext/common/tfm_hal_its.c> ext/common/tfm_platform.c $<$:${CMAKE_CURRENT_SOURCE_DIR}/ext/common/uart_stdout.c> $<$:ext/common/tfm_hal_spm_logdev_peripheral.c> ext/common/tfm_hal_memory_symbols.c $<$:ext/common/template/attest_hal.c> $<$:ext/common/template/nv_counters.c> $<$,$>:ext/common/template/crypto_keys.c> $<$:ext/common/template/tfm_rotpk.c> $<$:ext/common/template/crypto_nv_seed.c> $<$>,$>,$>:ext/common/template/tfm_initial_attest_pub_key.c> $<$,$>:ext/common/template/flash_otp_nv_counters_backend.c> $<$:ext/common/template/otp_flash.c> $<$:ext/common/provisioning.c> ) target_link_libraries(platform_s PUBLIC platform_common_interface platform_region_defs tfm_fih PRIVATE psa_interface tfm_secure_api tfm_arch tfm_partition_defs $<$:tfm_sprt> $<$,$>:crypto_service_mbedtls> ) target_compile_definitions(platform_s PUBLIC TFM_SPM_LOG_LEVEL=${TFM_SPM_LOG_LEVEL} $<$:OTP_NV_COUNTERS_RAM_EMULATION> CONFIG_TFM_SPE_FP=${CONFIG_TFM_SPE_FP} $<$:CONFIG_TFM_LAZY_STACKING_SPE> PRIVATE $<$:SYMMETRIC_INITIAL_ATTESTATION> $<$,$>:CONFIG_TFM_ENABLE_MEMORY_PROTECT> $<$,$>:TFM_PXN_ENABLE> $<$:PLATFORM_DEFAULT_OTP> $<$:TFM_DUMMY_PROVISIONING> $<$:ATTEST_INCLUDE_COSE_KEY_ID> $<$:PLATFORM_DEFAULT_NV_COUNTERS> $<$:PLATFORM_DEFAULT_OTP> $<$:OTP_WRITEABLE> ) target_compile_options(platform_s PUBLIC ${COMPILER_CP_FLAG} ) #========================= Platform Non-Secure ================================# target_sources(platform_ns PRIVATE $<$:${CMAKE_CURRENT_SOURCE_DIR}/ext/common/uart_stdout.c> $<$>,$>,$>:${CMAKE_CURRENT_SOURCE_DIR}/ext/common/template/tfm_initial_attest_pub_key.c> ) target_link_libraries(platform_ns PUBLIC platform_common_interface platform_region_defs tfm_ns_interface ) target_compile_definitions(platform_ns PRIVATE $<$:TEST_NS_SLIH_IRQ> ) #========================= Platform BL2 =======================================# if(BL2) #TODO import policy target_include_directories(platform_bl2 PUBLIC $<$:${CMAKE_CURRENT_SOURCE_DIR}/ext/accelerator/interface> ) target_sources(platform_bl2 PRIVATE ext/common/boot_hal.c $<$:${CMAKE_CURRENT_SOURCE_DIR}/ext/common/uart_stdout.c> $<$:ext/common/template/nv_counters.c> $<$:ext/common/template/tfm_rotpk.c> $<$,$>:ext/common/template/flash_otp_nv_counters_backend.c> $<$:ext/common/template/otp_flash.c> ) target_link_libraries(platform_bl2 PUBLIC platform_common_interface platform_region_defs PRIVATE psa_interface bl2_hal tfm_arch ) target_compile_definitions(platform_bl2 PUBLIC BL2 MCUBOOT_${MCUBOOT_UPGRADE_STRATEGY} $<$:MCUBOOT_DIRECT_XIP_REVERT> $<$:SYMMETRIC_INITIAL_ATTESTATION> $<$:MCUBOOT_HW_KEY> MCUBOOT_FIH_PROFILE_${MCUBOOT_FIH_PROFILE} $<$:PLATFORM_DEFAULT_OTP> $<$:OTP_NV_COUNTERS_RAM_EMULATION> $<$:TFM_DUMMY_PROVISIONING> $<$:ATTEST_INCLUDE_COSE_KEY_ID> $<$:PLATFORM_DEFAULT_NV_COUNTERS> $<$:OTP_WRITEABLE> ) endif() #========================= Platform region defs ===============================# #TODO maybe just link the other platforms to this target_compile_definitions(platform_region_defs INTERFACE $<$:BL1> $<$:BL2> BL2_HEADER_SIZE=${BL2_HEADER_SIZE} BL2_TRAILER_SIZE=${BL2_TRAILER_SIZE} $<$:SECURE_UART1> DAUTH_${DEBUG_AUTHENTICATION} $<$:MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}> $<$:MCUBOOT_SIGN_RSA> $<$:MCUBOOT_SIGN_RSA_LEN=${MCUBOOT_SIGNATURE_KEY_LEN}> $<$:LINK_TO_SECONDARY_PARTITION> $<$:PSA_API_TEST_${TEST_PSA_API}> $<$:FORWARD_PROT_MSG=${FORWARD_PROT_MSG}> $<$:CODE_SHARING> )