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 |
Anton Komlev | c0ad604 | 2023-08-29 18:23:26 +0100 | [diff] [blame] | 39 | ) |
| 40 | |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 41 | target_include_directories(os_wrapper |
| 42 | PUBLIC |
| 43 | ${CMAKE_CURRENT_LIST_DIR}/../lib/os_wrapper |
| 44 | # Some NS files include "os_wrapper/xxx.h" instead |
| 45 | ${CMAKE_CURRENT_LIST_DIR}/../lib |
| 46 | # Some OS wrapper header files are exported from TF-M secure build |
| 47 | ${SPE_INSTALL_INTERFACE_INC} |
| 48 | ) |
| 49 | |
| 50 | target_link_libraries(os_wrapper |
| 51 | PRIVATE |
| 52 | RTX_OS |
| 53 | tfm_nsid_manager |
| 54 | ) |
| 55 | |
| 56 | # NSID manager |
| 57 | add_library(tfm_nsid_manager INTERFACE) |
| 58 | |
| 59 | target_include_directories(tfm_nsid_manager |
| 60 | INTERFACE |
| 61 | ${APP_LIB_DIR}/nsid_manager |
| 62 | ) |
| 63 | |
| 64 | target_sources(tfm_nsid_manager |
| 65 | INTERFACE |
| 66 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${APP_LIB_DIR}/nsid_manager/tfm_nsid_manager.c> |
| 67 | ) |
| 68 | |
| 69 | target_compile_definitions(tfm_nsid_manager |
| 70 | INTERFACE |
| 71 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID> |
| 72 | $<$<BOOL:${TEST_NS_MANAGE_NSID}>:TEST_NS_MANAGE_NSID> |
| 73 | ) |
| 74 | |
| 75 | # Provide TZ context management stub to RTOS if protected by Trustzone |
| 76 | target_sources(RTX_OS |
| 77 | INTERFACE |
| 78 | $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${APP_LIB_DIR}/nsid_manager/tz_shim_layer.c> |
| 79 | ) |
| 80 | |
| 81 | target_link_libraries(RTX_OS |
| 82 | INTERFACE |
| 83 | tfm_nsid_manager |
| 84 | ) |
| 85 | |
| 86 | # Multi-core library |
| 87 | if(TFM_PARTITION_NS_AGENT_MAILBOX) |
| 88 | add_library(ns_multi_core STATIC) |
| 89 | |
| 90 | target_sources(ns_multi_core |
| 91 | PRIVATE |
| 92 | $<$<NOT:$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>>:${SPE_INSTALL_INTERFACE_SRC}/multi_core/tfm_ns_mailbox.c> |
| 93 | $<$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>:${SPE_INSTALL_INTERFACE_SRC}/multi_core/tfm_ns_mailbox_thread.c> |
| 94 | # NS RTOS specific implementation of NS mailbox |
| 95 | ${APP_LIB_DIR}/multi_core/tfm_ns_mailbox_rtos_api.c |
| 96 | $<$<BOOL:${TEST_NS_MULTI_CORE}>:${APP_LIB_DIR}/multi_core/tfm_ns_mailbox_test.c> |
| 97 | ) |
| 98 | |
| 99 | target_compile_definitions(ns_multi_core |
| 100 | PUBLIC |
| 101 | $<$<BOOL:${TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD}>:TFM_MULTI_CORE_NS_OS_MAILBOX_THREAD> |
| 102 | TFM_MULTI_CORE_NS_OS |
| 103 | ) |
| 104 | |
| 105 | target_link_libraries(ns_multi_core |
| 106 | PRIVATE |
| 107 | platform_ns |
| 108 | tfm_api_ns |
| 109 | os_wrapper |
| 110 | ) |
| 111 | endif() |
| 112 | |
David Hu | 479ef00 | 2023-10-20 14:44:32 +0800 | [diff] [blame^] | 113 | # TF-M ns logging |
| 114 | add_library(tfm_ns_log STATIC EXCLUDE_FROM_ALL) |
| 115 | |
| 116 | target_sources(tfm_ns_log |
| 117 | PRIVATE |
| 118 | ${APP_LIB_DIR}/log/tfm_log_raw.c |
| 119 | ) |
| 120 | |
| 121 | target_include_directories(tfm_ns_log |
| 122 | PUBLIC |
| 123 | ${APP_LIB_DIR}/log/ |
| 124 | ) |
| 125 | |
| 126 | target_link_libraries(tfm_ns_log |
| 127 | PRIVATE |
| 128 | platform_ns |
| 129 | ) |
| 130 | |
David Hu | 87b46a8 | 2023-10-21 23:23:42 +0800 | [diff] [blame] | 131 | ################## Update plaform_ns with NS settings ################# |
| 132 | |
| 133 | target_include_directories(platform_ns |
| 134 | PUBLIC |
| 135 | $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:${SPE_INSTALL_INTERFACE_INC}/multi_core> |
| 136 | ${SPE_INSTALL_INTERFACE_INC} |
| 137 | ) |
| 138 | |
| 139 | target_compile_definitions(platform_ns |
| 140 | PUBLIC |
| 141 | $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:TFM_MULTI_CORE_NS_OS> |
| 142 | ) |
| 143 | |
| 144 | ################# Update NS interface with NS settings ################ |
| 145 | |
| 146 | target_sources(tfm_api_ns |
| 147 | PRIVATE |
| 148 | # NS specific implementation of NS interface dispatcher |
| 149 | $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${SPE_INSTALL_INTERFACE_SRC}/os_wrapper/tfm_ns_interface_rtos.c> |
| 150 | ) |
| 151 | |
| 152 | target_compile_definitions(tfm_api_ns |
| 153 | PUBLIC |
| 154 | $<$<BOOL:${TEST_NS_MULTI_CORE}>:TFM_MULTI_CORE_TEST> |
| 155 | ) |
| 156 | |
| 157 | target_link_libraries(tfm_api_ns |
| 158 | PRIVATE |
| 159 | $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:os_wrapper> |
| 160 | ) |
| 161 | |
| 162 | ######################## NS application broker ######################## |
| 163 | |
| 164 | add_library(tfm_test_broker STATIC) |
| 165 | |
| 166 | target_sources(tfm_test_broker |
| 167 | PRIVATE |
| 168 | main_ns.c |
| 169 | $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${CMAKE_CURRENT_LIST_DIR}/tfm_nsid_map_table.c> |
| 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 | ) |