blob: 6c1d654f0339ffe9e877d1675b16a8a0e6c5c7fe [file] [log] [blame]
Gyorgy Szing30fa9872017-12-05 01:08:47 +00001#-------------------------------------------------------------------------------
Sherry Zhangf58f2bd2022-01-10 17:21:11 +08002# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
Chris Brand0d373102021-10-29 12:39:01 -07003# Copyright (c) 2021, Cypress Semiconductor Corporation. All rights reserved.
Gyorgy Szing30fa9872017-12-05 01:08:47 +00004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7#-------------------------------------------------------------------------------
8
Raef Coles69817322020-10-19 14:14:14 +01009cmake_minimum_required(VERSION 3.15)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000010
Raef Colesabfe81a2020-07-10 09:52:34 +010011add_executable(tfm_s)
12add_library(secure_fw INTERFACE)
Summer Qin5a212ec2020-11-19 15:48:57 +080013add_library(tfm_secure_api INTERFACE)
David Hu857bfa52019-05-21 13:54:50 +080014
Kevin Peng33d03942021-06-08 11:28:41 +080015add_subdirectory(spm)
David Hu057ba652021-12-07 13:50:15 +080016add_subdirectory(partitions)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000017
Raef Colesabfe81a2020-07-10 09:52:34 +010018target_include_directories(secure_fw
19 INTERFACE
20 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
21 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/partitions>
22)
Ken Liue40f9a22019-06-03 16:42:47 +080023
Raef Colesabfe81a2020-07-10 09:52:34 +010024target_link_libraries(secure_fw
25 INTERFACE
26 tfm_spm
27 tfm_partitions
28)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000029
Raef Colesabfe81a2020-07-10 09:52:34 +010030target_link_libraries(tfm_s
31 PRIVATE
32 secure_fw
33 platform_s
34 psa_interface
35 tfm_sprt
36)
Gyorgy Szing30fa9872017-12-05 01:08:47 +000037
Raef Colesabfe81a2020-07-10 09:52:34 +010038set_target_properties(tfm_s
39 PROPERTIES
40 SUFFIX ".axf"
41 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
42)
Gyorgy Szingd9c57fb2019-09-02 17:08:18 +020043
Feder Liangd4dbaa92021-09-07 15:34:46 +080044target_compile_options(tfm_s
45 PUBLIC
46 ${COMPILER_CP_FLAG}
47)
48
Raef Colesabfe81a2020-07-10 09:52:34 +010049target_link_options(tfm_s
50 PRIVATE
51 --entry=Reset_Handler
52 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_s.map>
53 $<$<C_COMPILER_ID:ARMClang>:--map>
TTornblomaf19ae92020-09-29 13:26:29 +020054 $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_s.map>
Feder Liangd4dbaa92021-09-07 15:34:46 +080055 PUBLIC
56 ${LINKER_CP_OPTION}
Raef Colesabfe81a2020-07-10 09:52:34 +010057)
58
59add_convert_to_bin_target(tfm_s)
60
61############################ Secure API ########################################
62
63target_include_directories(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +080064 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +010065 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
66)
67
68target_link_libraries(tfm_secure_api
Summer Qin5a212ec2020-11-19 15:48:57 +080069 INTERFACE
Raef Colesabfe81a2020-07-10 09:52:34 +010070 tfm_arch
Raef Colesabfe81a2020-07-10 09:52:34 +010071)
72
73set_source_files_properties(
Ken Liu82e3eac2021-10-14 16:19:13 +080074 ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_svc.c
Xinyu Zhanga7ba50b2021-12-27 17:32:53 +080075 ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_cross.c
Ken Liuf39d8eb2021-10-07 12:55:33 +080076 ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_sfn.c
Raef Colesabfe81a2020-07-10 09:52:34 +010077 PROPERTIES
Raef Coles5e8ea842020-09-25 10:36:16 +010078 COMPILE_FLAGS $<$<C_COMPILER_ID:GNU>:-Wno-unused-parameter>
79 COMPILE_FLAGS $<$<C_COMPILER_ID:ARMClang>:-Wno-unused-parameter>
Raef Colesabfe81a2020-07-10 09:52:34 +010080)
81
Ken Liu82e3eac2021-10-14 16:19:13 +080082# Secure component relies on 'tfm_secure_api', append headers/sources
83# into this target, also the SPE build indicator.
84target_sources(tfm_secure_api
85 INTERFACE
Sherry Zhangf58f2bd2022-01-10 17:21:11 +080086 $<$<BOOL:${CONFIG_TFM_PSA_API_SUPERVISOR_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_svc.c>
87 $<$<BOOL:${CONFIG_TFM_PSA_API_CROSS_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_cross.c>
88 $<$<BOOL:${CONFIG_TFM_PSA_API_SFN_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_sfn.c>
Ken Liu82e3eac2021-10-14 16:19:13 +080089)
90
91target_compile_definitions(tfm_secure_api
92 INTERFACE
93 CONFIG_TFM_BUILDING_SPE=1
Kevin Peng613b4172022-02-15 14:41:44 +080094 $<$<BOOL:${CONFIG_TFM_DOORBELL_API}>:CONFIG_TFM_DOORBELL_API=1>
Ken Liu82e3eac2021-10-14 16:19:13 +080095)
96
Raef Colesabfe81a2020-07-10 09:52:34 +010097############################# Secure veneers ###################################
98
99if(NOT (TFM_PSA_API AND TFM_MULTI_CORE_TOPOLOGY))
100 add_library(tfm_s_veneers STATIC)
101
102 target_sources(tfm_s_veneers
103 PRIVATE
104 ${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o
105 )
106
107 # Since s_veneers.o doesn't exist when this is evaluated by cmake we need to
108 # explicity specify what language it will use.
109 set_target_properties(tfm_s_veneers
110 PROPERTIES
111 LINKER_LANGUAGE C
112 )
113
114 # Pretend we have a command to generate the veneers, when in reality all
115 # that's needed is the dependency on tfm_s. This is required for the ninja
116 # build system
117 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o
118 COMMAND
119 DEPENDS tfm_s
120 )
121
122 target_link_options(tfm_s
123 PRIVATE
124 ${LINKER_VENEER_OUTPUT_FLAG}${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o
125 )
Gyorgy Szing30fa9872017-12-05 01:08:47 +0000126endif()
Tamas Banf8b0b2d2020-10-26 13:03:13 +0000127
128############################### CODE SHARING ###################################
129if (TFM_CODE_SHARING)
130 set(LIB_LIST mbedcrypto
131 crypto_service_cc312
132 platform_s
Raef Colesdfe519b2021-01-07 12:52:47 +0000133 tfm_psa_rot_partition_crypto
134 tfm_psa_rot_partition_audit
135 tfm_psa_rot_partition_attestation
136 tfm_app_rot_partition_ps
137 tfm_psa_rot_partition_its
138 tfm_psa_rot_partition_platform
Tamas Banf8b0b2d2020-10-26 13:03:13 +0000139 platform_s
140 tfm_sprt
141 tfm_spm
142 )
143 if (TFM_CODE_SHARING_PATH)
144 compiler_link_shared_code(tfm_s
145 ${TFM_CODE_SHARING_PATH} # Path to shared code
146 EXTERNAL_TARGET # Not produced by tf-m build
147 "${LIB_LIST}"
148 )
149 else()
150 compiler_link_shared_code(tfm_s
151 ${CMAKE_CURRENT_BINARY_DIR}/../bl2
152 bl2
153 "${LIB_LIST}"
154 )
155 endif()
156endif()