blob: 29338330147d83549108a05e3048129f68a400ed [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
33# TF-M logging
34add_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
37add_library(os_wrapper STATIC)
38
39target_sources(os_wrapper
40 PRIVATE
41 ${CMAKE_CURRENT_LIST_DIR}/os_wrapper_cmsis_rtos_v2.c
Anton Komlevc0ad6042023-08-29 18:23:26 +010042)
43
David Hu87b46a82023-10-21 23:23:42 +080044target_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
53target_link_libraries(os_wrapper
54 PRIVATE
55 RTX_OS
56 tfm_nsid_manager
57)
58
59# NSID manager
60add_library(tfm_nsid_manager INTERFACE)
61
62target_include_directories(tfm_nsid_manager
63 INTERFACE
64 ${APP_LIB_DIR}/nsid_manager
65)
66
67target_sources(tfm_nsid_manager
68 INTERFACE
69 $<$<BOOL:${TFM_NS_MANAGE_NSID}>:${APP_LIB_DIR}/nsid_manager/tfm_nsid_manager.c>
70)
71
72target_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
79target_sources(RTX_OS
80 INTERFACE
81 $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${APP_LIB_DIR}/nsid_manager/tz_shim_layer.c>
82)
83
84target_link_libraries(RTX_OS
85 INTERFACE
86 tfm_nsid_manager
87)
88
89# Multi-core library
90if(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 )
114endif()
115
116################## Update plaform_ns with NS settings #################
117
118target_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
124target_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
131target_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
137target_compile_definitions(tfm_api_ns
138 PUBLIC
139 $<$<BOOL:${TEST_NS_MULTI_CORE}>:TFM_MULTI_CORE_TEST>
140)
141
142target_link_libraries(tfm_api_ns
143 PRIVATE
144 $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:os_wrapper>
145)
146
147######################## NS application broker ########################
148
149add_library(tfm_test_broker STATIC)
150
151target_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
157target_include_directories(tfm_test_broker
158 PUBLIC
159 .
160)
Anton Komlevc0ad6042023-08-29 18:23:26 +0100161
162target_link_libraries(tfm_test_broker
David Hu87b46a82023-10-21 23:23:42 +0800163 PRIVATE
164 os_wrapper
165 tfm_nsid_manager
Anton Komlevc0ad6042023-08-29 18:23:26 +0100166 PUBLIC
David Hu87b46a82023-10-21 23:23:42 +0800167 RTX_OS
Anton Komlevc0ad6042023-08-29 18:23:26 +0100168 tfm_api_ns
169 tfm_log
David Hu87b46a82023-10-21 23:23:42 +0800170 $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:ns_multi_core>
Anton Komlevc0ad6042023-08-29 18:23:26 +0100171)