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