Anton Komlev | c0ad604 | 2023-08-29 18:23:26 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2023, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | # |
| 8 | # This CMake script used in a split build only. In the legacy 'sinlge' build |
| 9 | # this file is ignoed. Please don't be confused. |
| 10 | # |
| 11 | cmake_minimum_required(VERSION 3.15) |
| 12 | |
| 13 | # This is important to add this SPE subdirectory at first as it |
| 14 | # brings configuration from TF-M build |
| 15 | add_subdirectory(${CONFIG_SPE_PATH} ${CMAKE_BINARY_DIR}/spe) |
| 16 | |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 17 | ####################### NS application libraries ####################### |
Anton Komlev | c0ad604 | 2023-08-29 18:23:26 +0100 | [diff] [blame] | 18 | |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 19 | # Build all the NS application libraries here under app_broker |
| 20 | # Those NS libraries depend on each other. It is more convenient to sort out the dependencies here. |
| 21 | # |
| 22 | # Those NS libraries also link to libraries exported from TF-M secure build. Specify all the |
| 23 | # dependencies on TF-M exported libraries here, rather than under each NS library folder. |
| 24 | # Therefore, NS library can be shared and re-used in other downstream projects, without specially |
| 25 | # handling the differences of dependencies and paths in NS builds. |
| 26 | |
| 27 | # Interface files exported from TF-M secure build |
| 28 | set(SPE_INSTALL_INTERFACE_SRC ${CONFIG_SPE_PATH}/interface/src) |
| 29 | set(SPE_INSTALL_INTERFACE_INC ${CONFIG_SPE_PATH}/interface/include) |
| 30 | # lib parth |
| 31 | set(APP_LIB_DIR ${CMAKE_CURRENT_LIST_DIR}/../lib) |
| 32 | |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 33 | # OS wrapper library consists of the wrapper layer of RTOSes, such as RTX |
| 34 | add_library(os_wrapper STATIC) |
| 35 | |
| 36 | target_sources(os_wrapper |
| 37 | PRIVATE |
| 38 | ${CMAKE_CURRENT_LIST_DIR}/os_wrapper_cmsis_rtos_v2.c |
Xinyu Zhang | 09174dc | 2023-11-01 14:32:00 +0800 | [diff] [blame] | 39 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_LIST_DIR}/tfm_nsid_map_table.c> |
Anton Komlev | c0ad604 | 2023-08-29 18:23:26 +0100 | [diff] [blame] | 40 | ) |
| 41 | |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 42 | target_include_directories(os_wrapper |
| 43 | PUBLIC |
| 44 | ${CMAKE_CURRENT_LIST_DIR}/../lib/os_wrapper |
| 45 | # Some NS files include "os_wrapper/xxx.h" instead |
| 46 | ${CMAKE_CURRENT_LIST_DIR}/../lib |
| 47 | # Some OS wrapper header files are exported from TF-M secure build |
| 48 | ${SPE_INSTALL_INTERFACE_INC} |
| 49 | ) |
| 50 | |
| 51 | target_link_libraries(os_wrapper |
| 52 | PRIVATE |
| 53 | RTX_OS |
| 54 | tfm_nsid_manager |
| 55 | ) |
| 56 | |
| 57 | # NSID manager |
| 58 | add_library(tfm_nsid_manager INTERFACE) |
| 59 | |
| 60 | target_include_directories(tfm_nsid_manager |
| 61 | INTERFACE |
| 62 | ${APP_LIB_DIR}/nsid_manager |
| 63 | ) |
| 64 | |
| 65 | target_sources(tfm_nsid_manager |
| 66 | INTERFACE |
| 67 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${APP_LIB_DIR}/nsid_manager/tfm_nsid_manager.c> |
| 68 | ) |
| 69 | |
| 70 | target_compile_definitions(tfm_nsid_manager |
| 71 | INTERFACE |
| 72 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID> |
| 73 | $<$<BOOL:${TEST_NS_MANAGE_NSID}>:TEST_NS_MANAGE_NSID> |
| 74 | ) |
| 75 | |
| 76 | # Provide TZ context management stub to RTOS if protected by Trustzone |
| 77 | target_sources(RTX_OS |
| 78 | INTERFACE |
| 79 | $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${APP_LIB_DIR}/nsid_manager/tz_shim_layer.c> |
| 80 | ) |
| 81 | |
| 82 | target_link_libraries(RTX_OS |
| 83 | INTERFACE |
| 84 | tfm_nsid_manager |
| 85 | ) |
| 86 | |
| 87 | # Multi-core library |
| 88 | if(TFM_PARTITION_NS_AGENT_MAILBOX) |
| 89 | add_library(ns_multi_core STATIC) |
| 90 | |
| 91 | target_sources(ns_multi_core |
| 92 | PRIVATE |
| 93 | $<$<NOT:$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>>:${SPE_INSTALL_INTERFACE_SRC}/multi_core/tfm_ns_mailbox.c> |
| 94 | $<$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>:${SPE_INSTALL_INTERFACE_SRC}/multi_core/tfm_ns_mailbox_thread.c> |
| 95 | # NS RTOS specific implementation of NS mailbox |
| 96 | ${APP_LIB_DIR}/multi_core/tfm_ns_mailbox_rtos_api.c |
| 97 | $<$<BOOL:${TEST_NS_MULTI_CORE}>:${APP_LIB_DIR}/multi_core/tfm_ns_mailbox_test.c> |
| 98 | ) |
| 99 | |
| 100 | target_compile_definitions(ns_multi_core |
| 101 | PUBLIC |
| 102 | $<$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>:TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD> |
| 103 | TFM_MULTI_CORE_NS_OS |
| 104 | ) |
| 105 | |
| 106 | target_link_libraries(ns_multi_core |
| 107 | PRIVATE |
| 108 | platform_ns |
| 109 | tfm_api_ns |
| 110 | os_wrapper |
| 111 | ) |
| 112 | endif() |
| 113 | |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 114 | # TF-M ns logging |
| 115 | add_library(tfm_ns_log STATIC EXCLUDE_FROM_ALL) |
| 116 | |
| 117 | target_sources(tfm_ns_log |
| 118 | PRIVATE |
| 119 | ${APP_LIB_DIR}/log/tfm_log_raw.c |
| 120 | ) |
| 121 | |
| 122 | target_include_directories(tfm_ns_log |
| 123 | PUBLIC |
| 124 | ${APP_LIB_DIR}/log/ |
| 125 | ) |
| 126 | |
| 127 | target_link_libraries(tfm_ns_log |
| 128 | PRIVATE |
| 129 | platform_ns |
| 130 | ) |
| 131 | |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 132 | ################## Update plaform_ns with NS settings ################# |
| 133 | |
| 134 | target_include_directories(platform_ns |
| 135 | PUBLIC |
| 136 | $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:${SPE_INSTALL_INTERFACE_INC}/multi_core> |
| 137 | ${SPE_INSTALL_INTERFACE_INC} |
| 138 | ) |
| 139 | |
| 140 | target_compile_definitions(platform_ns |
| 141 | PUBLIC |
| 142 | $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:TFM_MULTI_CORE_NS_OS> |
| 143 | ) |
| 144 | |
| 145 | ################# Update NS interface with NS settings ################ |
| 146 | |
| 147 | target_sources(tfm_api_ns |
| 148 | PRIVATE |
| 149 | # NS specific implementation of NS interface dispatcher |
| 150 | $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${SPE_INSTALL_INTERFACE_SRC}/os_wrapper/tfm_ns_interface_rtos.c> |
| 151 | ) |
| 152 | |
| 153 | target_compile_definitions(tfm_api_ns |
| 154 | PUBLIC |
| 155 | $<$<BOOL:${TEST_NS_MULTI_CORE}>:TFM_MULTI_CORE_TEST> |
| 156 | ) |
| 157 | |
| 158 | target_link_libraries(tfm_api_ns |
| 159 | PRIVATE |
| 160 | $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:os_wrapper> |
| 161 | ) |
| 162 | |
| 163 | ######################## NS application broker ######################## |
| 164 | |
| 165 | add_library(tfm_test_broker STATIC) |
| 166 | |
| 167 | target_sources(tfm_test_broker |
| 168 | PRIVATE |
| 169 | main_ns.c |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 170 | ) |
| 171 | |
| 172 | target_include_directories(tfm_test_broker |
| 173 | PUBLIC |
| 174 | . |
| 175 | ) |
Anton Komlev | c0ad604 | 2023-08-29 18:23:26 +0100 | [diff] [blame] | 176 | |
| 177 | target_link_libraries(tfm_test_broker |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 178 | PRIVATE |
| 179 | os_wrapper |
| 180 | tfm_nsid_manager |
Anton Komlev | c0ad604 | 2023-08-29 18:23:26 +0100 | [diff] [blame] | 181 | PUBLIC |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 182 | RTX_OS |
Anton Komlev | c0ad604 | 2023-08-29 18:23:26 +0100 | [diff] [blame] | 183 | tfm_api_ns |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 184 | tfm_ns_log |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 185 | $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:ns_multi_core> |
Anton Komlev | c0ad604 | 2023-08-29 18:23:26 +0100 | [diff] [blame] | 186 | ) |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame] | 187 | |
| 188 | target_compile_definitions(tfm_test_broker |
| 189 | PUBLIC |
| 190 | $<$<BOOL:${TFM_NS_REG_TEST}>:TFM_NS_REG_TEST> |
| 191 | ) |