Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Sherry Zhang | f58f2bd | 2022-01-10 17:21:11 +0800 | [diff] [blame] | 2 | # Copyright (c) 2020-2022, Arm Limited. All rights reserved. |
Chris Brand | 0d37310 | 2021-10-29 12:39:01 -0700 | [diff] [blame] | 3 | # Copyright (c) 2021, Cypress Semiconductor Corporation. All rights reserved. |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | #------------------------------------------------------------------------------- |
| 8 | |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 9 | cmake_minimum_required(VERSION 3.15) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 10 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 11 | add_executable(tfm_s) |
| 12 | add_library(secure_fw INTERFACE) |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 13 | add_library(tfm_secure_api INTERFACE) |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 14 | add_library(tfm_partitions INTERFACE) |
| 15 | # Lots of seperate things need to know which partitions are enabled, so this |
| 16 | # meta-target is provided so the related compile definitions can be collected in |
| 17 | # such a way that they don't cause issues with linking to the full spm (which is |
| 18 | # the other place these could be collected) Actual definitions are placed in the |
| 19 | # directories of the partitions |
| 20 | add_library(tfm_partition_defs INTERFACE) |
David Hu | 857bfa5 | 2019-05-21 13:54:50 +0800 | [diff] [blame] | 21 | |
Kevin Peng | 33d0394 | 2021-06-08 11:28:41 +0800 | [diff] [blame] | 22 | add_subdirectory(spm) |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 23 | add_subdirectory(partitions/lib/sprt) |
| 24 | add_subdirectory(partitions/audit_logging) |
| 25 | add_subdirectory(partitions/crypto) |
| 26 | add_subdirectory(partitions/initial_attestation) |
| 27 | add_subdirectory(partitions/protected_storage) |
| 28 | add_subdirectory(partitions/internal_trusted_storage) |
| 29 | add_subdirectory(partitions/platform) |
Mark Horvath | 652b900 | 2020-09-08 20:42:05 +0200 | [diff] [blame] | 30 | add_subdirectory(partitions/psa_proxy) |
Sherry Zhang | 07b4241 | 2021-01-07 14:19:41 +0800 | [diff] [blame] | 31 | add_subdirectory(partitions/firmware_update) |
Chris Brand | 0d37310 | 2021-10-29 12:39:01 -0700 | [diff] [blame] | 32 | add_subdirectory(partitions/ns_agent_tz) |
| 33 | add_subdirectory(partitions/ns_agent_mailbox) |
Mingyang Sun | d3f5597 | 2022-02-11 18:16:35 +0800 | [diff] [blame] | 34 | if (CONFIG_TFM_SPM_BACKEND_IPC) |
| 35 | add_subdirectory(partitions/idle_partition) |
| 36 | endif() |
| 37 | |
David Hu | b269420 | 2021-07-15 14:58:39 +0800 | [diff] [blame] | 38 | if (TFM_EXTRA_PARTITION_PATHS) |
| 39 | set(POSTFIX 1) |
| 40 | |
| 41 | foreach(EXTRA_PARTITION IN LISTS TFM_EXTRA_PARTITION_PATHS) |
| 42 | get_filename_component(EXTRA_PARTITION_NAME ${EXTRA_PARTITION} NAME_WLE) |
| 43 | set(TEMP_BINARY_EXTRA_PARTITION |
| 44 | ${CMAKE_CURRENT_BINARY_DIR}/partitions/${EXTRA_PARTITION_NAME}_${POSTFIX}) |
| 45 | add_subdirectory(${EXTRA_PARTITION} ${TEMP_BINARY_EXTRA_PARTITION}) |
| 46 | |
| 47 | math(EXPR POSTFIX "${POSTFIX} + 1") |
| 48 | endforeach() |
| 49 | endif() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 50 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 51 | target_include_directories(secure_fw |
| 52 | INTERFACE |
| 53 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 54 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/partitions> |
| 55 | ) |
Ken Liu | e40f9a2 | 2019-06-03 16:42:47 +0800 | [diff] [blame] | 56 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 57 | target_link_libraries(secure_fw |
| 58 | INTERFACE |
| 59 | tfm_spm |
| 60 | tfm_partitions |
| 61 | ) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 62 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 63 | target_link_libraries(tfm_s |
| 64 | PRIVATE |
| 65 | secure_fw |
| 66 | platform_s |
| 67 | psa_interface |
| 68 | tfm_sprt |
| 69 | ) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 70 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 71 | set_target_properties(tfm_s |
| 72 | PROPERTIES |
| 73 | SUFFIX ".axf" |
| 74 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
| 75 | ) |
Gyorgy Szing | d9c57fb | 2019-09-02 17:08:18 +0200 | [diff] [blame] | 76 | |
Feder Liang | d4dbaa9 | 2021-09-07 15:34:46 +0800 | [diff] [blame] | 77 | target_compile_options(tfm_s |
| 78 | PUBLIC |
| 79 | ${COMPILER_CP_FLAG} |
| 80 | ) |
| 81 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 82 | target_link_options(tfm_s |
| 83 | PRIVATE |
| 84 | --entry=Reset_Handler |
| 85 | $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_s.map> |
| 86 | $<$<C_COMPILER_ID:ARMClang>:--map> |
TTornblom | af19ae9 | 2020-09-29 13:26:29 +0200 | [diff] [blame] | 87 | $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_s.map> |
Feder Liang | d4dbaa9 | 2021-09-07 15:34:46 +0800 | [diff] [blame] | 88 | PUBLIC |
| 89 | ${LINKER_CP_OPTION} |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 90 | ) |
| 91 | |
| 92 | add_convert_to_bin_target(tfm_s) |
| 93 | |
| 94 | ############################ Secure API ######################################## |
| 95 | |
| 96 | target_include_directories(tfm_secure_api |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 97 | INTERFACE |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 98 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 99 | ) |
| 100 | |
| 101 | target_link_libraries(tfm_secure_api |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 102 | INTERFACE |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 103 | tfm_arch |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 104 | ) |
| 105 | |
| 106 | set_source_files_properties( |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 107 | ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_svc.c |
Xinyu Zhang | a7ba50b | 2021-12-27 17:32:53 +0800 | [diff] [blame] | 108 | ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_cross.c |
Ken Liu | f39d8eb | 2021-10-07 12:55:33 +0800 | [diff] [blame] | 109 | ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_sfn.c |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 110 | PROPERTIES |
Raef Coles | 5e8ea84 | 2020-09-25 10:36:16 +0100 | [diff] [blame] | 111 | COMPILE_FLAGS $<$<C_COMPILER_ID:GNU>:-Wno-unused-parameter> |
| 112 | COMPILE_FLAGS $<$<C_COMPILER_ID:ARMClang>:-Wno-unused-parameter> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 113 | ) |
| 114 | |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 115 | # Secure component relies on 'tfm_secure_api', append headers/sources |
| 116 | # into this target, also the SPE build indicator. |
| 117 | target_sources(tfm_secure_api |
| 118 | INTERFACE |
Sherry Zhang | f58f2bd | 2022-01-10 17:21:11 +0800 | [diff] [blame] | 119 | $<$<BOOL:${CONFIG_TFM_PSA_API_SUPERVISOR_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_svc.c> |
| 120 | $<$<BOOL:${CONFIG_TFM_PSA_API_CROSS_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_cross.c> |
| 121 | $<$<BOOL:${CONFIG_TFM_PSA_API_SFN_CALL}>:${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_sfn.c> |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 122 | ) |
| 123 | |
| 124 | target_compile_definitions(tfm_secure_api |
| 125 | INTERFACE |
| 126 | CONFIG_TFM_BUILDING_SPE=1 |
Kevin Peng | 613b417 | 2022-02-15 14:41:44 +0800 | [diff] [blame] | 127 | $<$<BOOL:${CONFIG_TFM_DOORBELL_API}>:CONFIG_TFM_DOORBELL_API=1> |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 128 | ) |
| 129 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 130 | ############################# Secure veneers ################################### |
| 131 | |
| 132 | if(NOT (TFM_PSA_API AND TFM_MULTI_CORE_TOPOLOGY)) |
| 133 | add_library(tfm_s_veneers STATIC) |
| 134 | |
| 135 | target_sources(tfm_s_veneers |
| 136 | PRIVATE |
| 137 | ${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o |
| 138 | ) |
| 139 | |
| 140 | # Since s_veneers.o doesn't exist when this is evaluated by cmake we need to |
| 141 | # explicity specify what language it will use. |
| 142 | set_target_properties(tfm_s_veneers |
| 143 | PROPERTIES |
| 144 | LINKER_LANGUAGE C |
| 145 | ) |
| 146 | |
| 147 | # Pretend we have a command to generate the veneers, when in reality all |
| 148 | # that's needed is the dependency on tfm_s. This is required for the ninja |
| 149 | # build system |
| 150 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o |
| 151 | COMMAND |
| 152 | DEPENDS tfm_s |
| 153 | ) |
| 154 | |
| 155 | target_link_options(tfm_s |
| 156 | PRIVATE |
| 157 | ${LINKER_VENEER_OUTPUT_FLAG}${CMAKE_CURRENT_BINARY_DIR}/s_veneers.o |
| 158 | ) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 159 | endif() |
Tamas Ban | f8b0b2d | 2020-10-26 13:03:13 +0000 | [diff] [blame] | 160 | |
| 161 | ############################### CODE SHARING ################################### |
| 162 | if (TFM_CODE_SHARING) |
| 163 | set(LIB_LIST mbedcrypto |
| 164 | crypto_service_cc312 |
| 165 | platform_s |
Raef Coles | dfe519b | 2021-01-07 12:52:47 +0000 | [diff] [blame] | 166 | tfm_psa_rot_partition_crypto |
| 167 | tfm_psa_rot_partition_audit |
| 168 | tfm_psa_rot_partition_attestation |
| 169 | tfm_app_rot_partition_ps |
| 170 | tfm_psa_rot_partition_its |
| 171 | tfm_psa_rot_partition_platform |
Tamas Ban | f8b0b2d | 2020-10-26 13:03:13 +0000 | [diff] [blame] | 172 | platform_s |
| 173 | tfm_sprt |
| 174 | tfm_spm |
| 175 | ) |
| 176 | if (TFM_CODE_SHARING_PATH) |
| 177 | compiler_link_shared_code(tfm_s |
| 178 | ${TFM_CODE_SHARING_PATH} # Path to shared code |
| 179 | EXTERNAL_TARGET # Not produced by tf-m build |
| 180 | "${LIB_LIST}" |
| 181 | ) |
| 182 | else() |
| 183 | compiler_link_shared_code(tfm_s |
| 184 | ${CMAKE_CURRENT_BINARY_DIR}/../bl2 |
| 185 | bl2 |
| 186 | "${LIB_LIST}" |
| 187 | ) |
| 188 | endif() |
| 189 | endif() |