1#-------------------------------------------------------------------------------
2# SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
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.21)
11
12# Generate framework feature
13set(PSA_FRAMEWORK_ISOLATION_LEVEL   ${TFM_ISOLATION_LEVEL})
14configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/psa/framework_feature.h.in
15               ${CMAKE_BINARY_DIR}/generated/interface/include/psa/framework_feature.h
16               @ONLY)
17
18###################### PSA interface (header only) #############################
19
20add_library(psa_interface INTERFACE)
21
22target_include_directories(psa_interface
23    INTERFACE
24        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
25        $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/generated/interface/include>
26        $<BUILD_INTERFACE:$<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:${CMAKE_CURRENT_SOURCE_DIR}/include/multi_core>>
27)
28
29target_link_libraries(psa_interface
30    INTERFACE
31        tfm_config
32)
33
34target_compile_definitions(psa_interface
35    INTERFACE
36        $<$<BOOL:${CONFIG_TFM_ENABLE_CTX_MGMT}>:CONFIG_TFM_ENABLE_CTX_MGMT>
37        $<$<BOOL:${TFM_ISOLATION_LEVEL}>:TFM_ISOLATION_LEVEL=${TFM_ISOLATION_LEVEL}>
38        $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:CONFIG_TFM_USE_TRUSTZONE>
39        $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:TFM_MULTI_CORE_TOPOLOGY>
40        $<$<BOOL:${CONFIG_TFM_PARTITION_META}>:CONFIG_TFM_PARTITION_META>
41        $<$<BOOL:${TEST_NS_MULTI_CORE}>:TFM_MULTI_CORE_TEST>
42        $<$<BOOL:${TFM_HYBRID_PLATFORM_API_BROKER}>:TFM_HYBRID_PLATFORM_API_BROKER>
43)
44
45add_dependencies(psa_interface manifest_tool)
46
47###################### PSA api (S lib) #########################################
48
49target_sources(tfm_sprt
50    PRIVATE
51        $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_attest_api.c>
52        $<$<BOOL:${TFM_PARTITION_CRYPTO}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_crypto_api.c>
53        $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_fwu_api.c>
54        $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_its_api.c>
55        $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_platform_api.c>
56        $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_ps_api.c>
57        ${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_psa_call.c
58)
59
60###################### Export configurations to NS #############################
61
62if (TFM_MULTI_CORE_TOPOLOGY)
63    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/multi_core/tfm_mailbox_config.h.in
64                   ${CMAKE_BINARY_DIR}/generated/interface/include/tfm_mailbox_config.h
65                   NEWLINE_STYLE UNIX
66    )
67endif()
68