1#-------------------------------------------------------------------------------
2# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
3# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
4# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
5#
6# SPDX-License-Identifier: BSD-3-Clause
7#
8#-------------------------------------------------------------------------------
9
10cmake_minimum_required(VERSION 3.15)
11cmake_policy(SET CMP0076 NEW)
12cmake_policy(SET CMP0079 NEW)
13
14# Generate framework feature
15set(PSA_FRAMEWORK_ISOLATION_LEVEL   ${TFM_ISOLATION_LEVEL})
16configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/psa/framework_feature.h.in
17               ${CMAKE_BINARY_DIR}/generated/interface/include/psa/framework_feature.h
18               @ONLY)
19
20if (EXISTS ${TARGET_PLATFORM_PATH}/preload_ns.cmake)
21    include(${TARGET_PLATFORM_PATH}/preload_ns.cmake)
22    tfm_toolchain_reload_compiler()
23endif()
24
25###################### PSA interface (header only) #############################
26
27add_library(psa_interface INTERFACE)
28
29target_include_directories(psa_interface
30    INTERFACE
31        ${CMAKE_CURRENT_SOURCE_DIR}/include
32        ${CMAKE_BINARY_DIR}/generated/interface/include
33        $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:${CMAKE_CURRENT_SOURCE_DIR}/include/multi_core>
34)
35
36target_link_libraries(psa_interface
37    INTERFACE
38        tfm_config
39        tfm_partition_defs
40)
41
42target_compile_definitions(psa_interface
43    INTERFACE
44        $<$<BOOL:${CONFIG_TFM_ENABLE_CTX_MGMT}>:CONFIG_TFM_ENABLE_CTX_MGMT>
45        $<$<BOOL:${TFM_ISOLATION_LEVEL}>:TFM_LVL=${TFM_ISOLATION_LEVEL}>
46        $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:CONFIG_TFM_USE_TRUSTZONE>
47        $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:TFM_MULTI_CORE_TOPOLOGY>
48        $<$<BOOL:${CONFIG_TFM_PARTITION_META}>:CONFIG_TFM_PARTITION_META>
49)
50
51###################### PSA api (S lib) #########################################
52
53target_sources(tfm_sprt
54    PRIVATE
55        $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_attest_api.c>
56        $<$<BOOL:${TFM_PARTITION_CRYPTO}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_crypto_api.c>
57        $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_fwu_api.c>
58        $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_its_api.c>
59        $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_platform_api.c>
60        $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_ps_api.c>
61        ${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_psa_call_pack.c
62)
63
64###################### Export configurations to NS #############################
65
66if (TFM_MULTI_CORE_TOPOLOGY)
67    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/multi_core/tfm_mailbox_config.h.in
68                   ${CMAKE_BINARY_DIR}/generated/interface/include/tfm_mailbox_config.h
69                   NEWLINE_STYLE UNIX
70    )
71endif()
72