blob: 08ffb890a781c64cae39e429b240f9402b7e2fc5 [file] [log] [blame]
Anton Komlevc0ad6042023-08-29 18:23:26 +01001#-------------------------------------------------------------------------------
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#
11cmake_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
15add_subdirectory(${CONFIG_SPE_PATH} ${CMAKE_BINARY_DIR}/spe)
16
David Hu87b46a82023-10-21 23:23:42 +080017####################### NS application libraries #######################
Anton Komlevc0ad6042023-08-29 18:23:26 +010018
David Hu87b46a82023-10-21 23:23:42 +080019# 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
28set(SPE_INSTALL_INTERFACE_SRC ${CONFIG_SPE_PATH}/interface/src)
29set(SPE_INSTALL_INTERFACE_INC ${CONFIG_SPE_PATH}/interface/include)
30# lib parth
31set(APP_LIB_DIR ${CMAKE_CURRENT_LIST_DIR}/../lib)
32
David Hu87b46a82023-10-21 23:23:42 +080033# OS wrapper library consists of the wrapper layer of RTOSes, such as RTX
34add_library(os_wrapper STATIC)
35
36target_sources(os_wrapper
37 PRIVATE
38 ${CMAKE_CURRENT_LIST_DIR}/os_wrapper_cmsis_rtos_v2.c
Anton Komlevc0ad6042023-08-29 18:23:26 +010039)
40
David Hu87b46a82023-10-21 23:23:42 +080041target_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
50target_link_libraries(os_wrapper
51 PRIVATE
52 RTX_OS
53 tfm_nsid_manager
54)
55
56# NSID manager
57add_library(tfm_nsid_manager INTERFACE)
58
59target_include_directories(tfm_nsid_manager
60 INTERFACE
61 ${APP_LIB_DIR}/nsid_manager
62)
63
64target_sources(tfm_nsid_manager
65 INTERFACE
66 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${APP_LIB_DIR}/nsid_manager/tfm_nsid_manager.c>
67)
68
69target_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
76target_sources(RTX_OS
77 INTERFACE
78 $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${APP_LIB_DIR}/nsid_manager/tz_shim_layer.c>
79)
80
81target_link_libraries(RTX_OS
82 INTERFACE
83 tfm_nsid_manager
84)
85
86# Multi-core library
87if(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 )
111endif()
112
David Hu479ef002023-10-20 14:44:32 +0800113# TF-M ns logging
114add_library(tfm_ns_log STATIC EXCLUDE_FROM_ALL)
115
116target_sources(tfm_ns_log
117 PRIVATE
118 ${APP_LIB_DIR}/log/tfm_log_raw.c
119)
120
121target_include_directories(tfm_ns_log
122 PUBLIC
123 ${APP_LIB_DIR}/log/
124)
125
126target_link_libraries(tfm_ns_log
127 PRIVATE
128 platform_ns
129)
130
David Hu87b46a82023-10-21 23:23:42 +0800131################## Update plaform_ns with NS settings #################
132
133target_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
139target_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
146target_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
152target_compile_definitions(tfm_api_ns
153 PUBLIC
154 $<$<BOOL:${TEST_NS_MULTI_CORE}>:TFM_MULTI_CORE_TEST>
155)
156
157target_link_libraries(tfm_api_ns
158 PRIVATE
159 $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:os_wrapper>
160)
161
162######################## NS application broker ########################
163
164add_library(tfm_test_broker STATIC)
165
166target_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
172target_include_directories(tfm_test_broker
173 PUBLIC
174 .
175)
Anton Komlevc0ad6042023-08-29 18:23:26 +0100176
177target_link_libraries(tfm_test_broker
David Hu87b46a82023-10-21 23:23:42 +0800178 PRIVATE
179 os_wrapper
180 tfm_nsid_manager
Anton Komlevc0ad6042023-08-29 18:23:26 +0100181 PUBLIC
David Hu87b46a82023-10-21 23:23:42 +0800182 RTX_OS
Anton Komlevc0ad6042023-08-29 18:23:26 +0100183 tfm_api_ns
David Hu479ef002023-10-20 14:44:32 +0800184 tfm_ns_log
David Hu87b46a82023-10-21 23:23:42 +0800185 $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:ns_multi_core>
Anton Komlevc0ad6042023-08-29 18:23:26 +0100186)
David Hu479ef002023-10-20 14:44:32 +0800187
188target_compile_definitions(tfm_test_broker
189 PUBLIC
190 $<$<BOOL:${TFM_NS_REG_TEST}>:TFM_NS_REG_TEST>
191)