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) |
David Hu | 857bfa5 | 2019-05-21 13:54:50 +0800 | [diff] [blame] | 14 | |
Kevin Peng | 33d0394 | 2021-06-08 11:28:41 +0800 | [diff] [blame] | 15 | add_subdirectory(spm) |
David Hu | 057ba65 | 2021-12-07 13:50:15 +0800 | [diff] [blame^] | 16 | add_subdirectory(partitions) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 17 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 18 | target_include_directories(secure_fw |
| 19 | INTERFACE |
| 20 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 21 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/partitions> |
| 22 | ) |
Ken Liu | e40f9a2 | 2019-06-03 16:42:47 +0800 | [diff] [blame] | 23 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 24 | target_link_libraries(secure_fw |
| 25 | INTERFACE |
| 26 | tfm_spm |
| 27 | tfm_partitions |
| 28 | ) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 29 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 30 | target_link_libraries(tfm_s |
| 31 | PRIVATE |
| 32 | secure_fw |
| 33 | platform_s |
| 34 | psa_interface |
| 35 | tfm_sprt |
| 36 | ) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 37 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 38 | set_target_properties(tfm_s |
| 39 | PROPERTIES |
| 40 | SUFFIX ".axf" |
| 41 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
| 42 | ) |
Gyorgy Szing | d9c57fb | 2019-09-02 17:08:18 +0200 | [diff] [blame] | 43 | |
Feder Liang | d4dbaa9 | 2021-09-07 15:34:46 +0800 | [diff] [blame] | 44 | target_compile_options(tfm_s |
| 45 | PUBLIC |
| 46 | ${COMPILER_CP_FLAG} |
| 47 | ) |
| 48 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 49 | target_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> |
TTornblom | af19ae9 | 2020-09-29 13:26:29 +0200 | [diff] [blame] | 54 | $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_s.map> |
Feder Liang | d4dbaa9 | 2021-09-07 15:34:46 +0800 | [diff] [blame] | 55 | PUBLIC |
| 56 | ${LINKER_CP_OPTION} |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 57 | ) |
| 58 | |
| 59 | add_convert_to_bin_target(tfm_s) |
| 60 | |
| 61 | ############################ Secure API ######################################## |
| 62 | |
| 63 | target_include_directories(tfm_secure_api |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 64 | INTERFACE |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 65 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 66 | ) |
| 67 | |
| 68 | target_link_libraries(tfm_secure_api |
Summer Qin | 5a212ec | 2020-11-19 15:48:57 +0800 | [diff] [blame] | 69 | INTERFACE |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 70 | tfm_arch |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 71 | ) |
| 72 | |
| 73 | set_source_files_properties( |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 74 | ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_svc.c |
Xinyu Zhang | a7ba50b | 2021-12-27 17:32:53 +0800 | [diff] [blame] | 75 | ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_cross.c |
Ken Liu | f39d8eb | 2021-10-07 12:55:33 +0800 | [diff] [blame] | 76 | ${CMAKE_SOURCE_DIR}/secure_fw/spm/cmsis_psa/psa_interface_sfn.c |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 77 | PROPERTIES |
Raef Coles | 5e8ea84 | 2020-09-25 10:36:16 +0100 | [diff] [blame] | 78 | COMPILE_FLAGS $<$<C_COMPILER_ID:GNU>:-Wno-unused-parameter> |
| 79 | COMPILE_FLAGS $<$<C_COMPILER_ID:ARMClang>:-Wno-unused-parameter> |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 80 | ) |
| 81 | |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 82 | # Secure component relies on 'tfm_secure_api', append headers/sources |
| 83 | # into this target, also the SPE build indicator. |
| 84 | target_sources(tfm_secure_api |
| 85 | INTERFACE |
Sherry Zhang | f58f2bd | 2022-01-10 17:21:11 +0800 | [diff] [blame] | 86 | $<$<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 Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 89 | ) |
| 90 | |
| 91 | target_compile_definitions(tfm_secure_api |
| 92 | INTERFACE |
| 93 | CONFIG_TFM_BUILDING_SPE=1 |
Kevin Peng | 613b417 | 2022-02-15 14:41:44 +0800 | [diff] [blame] | 94 | $<$<BOOL:${CONFIG_TFM_DOORBELL_API}>:CONFIG_TFM_DOORBELL_API=1> |
Ken Liu | 82e3eac | 2021-10-14 16:19:13 +0800 | [diff] [blame] | 95 | ) |
| 96 | |
Raef Coles | abfe81a | 2020-07-10 09:52:34 +0100 | [diff] [blame] | 97 | ############################# Secure veneers ################################### |
| 98 | |
| 99 | if(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 Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 126 | endif() |
Tamas Ban | f8b0b2d | 2020-10-26 13:03:13 +0000 | [diff] [blame] | 127 | |
| 128 | ############################### CODE SHARING ################################### |
| 129 | if (TFM_CODE_SHARING) |
| 130 | set(LIB_LIST mbedcrypto |
| 131 | crypto_service_cc312 |
| 132 | platform_s |
Raef Coles | dfe519b | 2021-01-07 12:52:47 +0000 | [diff] [blame] | 133 | 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 Ban | f8b0b2d | 2020-10-26 13:03:13 +0000 | [diff] [blame] | 139 | 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() |
| 156 | endif() |