blob: 16aacc2349e9225d8072d54504b2437c7c83fd58 [file] [log] [blame]
Raef Coles7d3545b2020-07-10 10:00:35 +01001#-------------------------------------------------------------------------------
Sherry Zhangf58f2bd2022-01-10 17:21:11 +08002# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
Chris Brandd0790332022-05-20 13:36:30 -07003# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
4# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
Raef Coles7d3545b2020-07-10 10:00:35 +01005#
6# SPDX-License-Identifier: BSD-3-Clause
7#
8#-------------------------------------------------------------------------------
9
Raef Coles69817322020-10-19 14:14:14 +010010cmake_minimum_required(VERSION 3.15)
Raef Coles7d3545b2020-07-10 10:00:35 +010011cmake_policy(SET CMP0076 NEW)
12cmake_policy(SET CMP0079 NEW)
13
Kevin Peng386374c2021-11-04 14:36:17 +080014# Generate framework feature
Kevin Peng710acf52021-11-16 11:42:41 +080015set(PSA_FRAMEWORK_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL})
Kevin Peng386374c2021-11-04 14:36:17 +080016configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/psa/framework_feature.h.in
Kevin Peng710acf52021-11-16 11:42:41 +080017 ${CMAKE_BINARY_DIR}/generated/interface/include/psa/framework_feature.h
18 @ONLY)
Raef Coles7d3545b2020-07-10 10:00:35 +010019
Chris Brandd0790332022-05-20 13:36:30 -070020if (EXISTS ${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake)
Raef Coles7d3545b2020-07-10 10:00:35 +010021 include(${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake)
Raef Colese3bf94d2020-11-03 11:49:56 +000022 tfm_toolchain_reload_compiler()
Chris Brandd0790332022-05-20 13:36:30 -070023endif()
24
Raef Coles7d3545b2020-07-10 10:00:35 +010025###################### 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
Mark Horvathfbc2c502022-09-09 16:16:07 +020033 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:${CMAKE_CURRENT_SOURCE_DIR}/include/multi_core>
Raef Coles7d3545b2020-07-10 10:00:35 +010034)
35
36# PSA interface files are generated from a template
37add_dependencies(psa_interface
38 tfm_generated_files
39)
40
41target_link_libraries(psa_interface
42 INTERFACE
43 tfm_partition_defs
44)
45
46target_compile_definitions(psa_interface
47 INTERFACE
Raef Coles7d3545b2020-07-10 10:00:35 +010048 $<$<BOOL:${CONFIG_TFM_ENABLE_CTX_MGMT}>:CONFIG_TFM_ENABLE_CTX_MGMT>
49 $<$<BOOL:${TFM_ISOLATION_LEVEL}>:TFM_LVL=${TFM_ISOLATION_LEVEL}>
Chris Brandca819022022-07-19 09:25:15 -070050 $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:CONFIG_TFM_USE_TRUSTZONE>
Raef Coles7d3545b2020-07-10 10:00:35 +010051 $<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:TFM_MULTI_CORE_TOPOLOGY>
Summer Qin2a299592022-02-07 17:37:10 +080052 $<$<BOOL:${CONFIG_TFM_PARTITION_META}>:CONFIG_TFM_PARTITION_META>
Kevin Pengd4ccd082022-02-28 14:16:37 +080053 $<$<BOOL:${CONFIG_TFM_DOORBELL_API}>:CONFIG_TFM_DOORBELL_API=1>
Raef Coles7d3545b2020-07-10 10:00:35 +010054)
55
56###################### PSA api (S lib) #########################################
57
Kevin Peng8b8f7a42022-08-05 17:56:30 +080058target_sources(tfm_sprt
59 PRIVATE
Summer Qind23bbb32022-10-18 15:30:06 +080060 $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_attest_api.c>
61 $<$<BOOL:${TFM_PARTITION_CRYPTO}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_crypto_api.c>
62 $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_fwu_api.c>
63 $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_its_api.c>
64 $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_platform_api.c>
65 $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_ps_api.c>
Summer Qin566e03b2022-10-08 17:27:42 +080066 ${CMAKE_CURRENT_SOURCE_DIR}/src/tfm_psa_call_pack.c
Kevin Peng8b8f7a42022-08-05 17:56:30 +080067)
68
69target_compile_definitions(tfm_sprt
70 PUBLIC
71 CONFIG_TFM_BUILDING_SPE=1
Raef Coles7d3545b2020-07-10 10:00:35 +010072)
David Hu8b526d42020-11-27 20:59:52 +080073
74###################### Export configurations to NS #############################
75
Mark Horvathfbc2c502022-09-09 16:16:07 +020076if (TFM_MULTI_CORE_TOPOLOGY)
David Hu8b526d42020-11-27 20:59:52 +080077 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/multi_core/tfm_mailbox_config.h.in
David Hu186a1292021-09-13 09:05:52 +080078 ${CMAKE_BINARY_DIR}/generated/interface/include/tfm_mailbox_config.h
David Hu8b526d42020-11-27 20:59:52 +080079 NEWLINE_STYLE UNIX
80 )
81endif()