blob: 034b64a15a8599efbdac6f65cbd57a6029a936f0 [file] [log] [blame]
Kevin Peng62a87112020-07-07 15:07:46 +08001#-------------------------------------------------------------------------------
Raef Coles5ee45ed2020-09-24 11:25:44 +01002# Copyright (c) 2020, Arm Limited. All rights reserved.
Kevin Peng62a87112020-07-07 15:07:46 +08003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Raef Coles5ee45ed2020-09-24 11:25:44 +01008cmake_minimum_required(VERSION 3.13)
Kevin Peng62a87112020-07-07 15:07:46 +08009project(tfm_ns LANGUAGES ASM C)
Kevin Peng62a87112020-07-07 15:07:46 +080010
Raef Coles5ee45ed2020-09-24 11:25:44 +010011# For multi-core projects, the NS app can be run on a different CPU to the
12# Secure code. To facilitate this, we once again reload the compiler to load the
13# setting for the NS CPU. Cmake settings are directory scoped so this affects
14# anything loaded from or declared in this dir.
15if (TFM_MULTI_CORE_TOPOLOGY)
16 include(${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake)
Raef Coles34cffa72020-10-28 10:27:19 +000017 tfm_toolchain_reload_compiler()
Kevin Peng62a87112020-07-07 15:07:46 +080018endif()
19
Raef Coles5ee45ed2020-09-24 11:25:44 +010020############################# PSA test integration #############################
21
Raef Colesc922f252020-10-05 10:49:30 +010022if(TEST_PSA_API AND NOT PSA_ARCH_TESTS_BINARY_PATH)
23 if(NOT SUITE)
24 set(SUITE ${TEST_PSA_API})
25 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +010026
27 string(REGEX REPLACE ".*/" "" PSA_API_TEST_TARGET ${TFM_PLATFORM})
28
Raef Colesc922f252020-10-05 10:49:30 +010029 if(NOT TARGET)
30 if (NOT "${TEST_PSA_API}" STREQUAL "IPC")
31 set(TARGET tgt_dev_apis_tfm_${PSA_API_TEST_TARGET})
32 else()
33 set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET})
34 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +010035 endif()
36
Raef Coles5ee45ed2020-09-24 11:25:44 +010037
Raef Colesc922f252020-10-05 10:49:30 +010038 if(NOT PSA_INCLUDE_PATHS)
39 set(PSA_INCLUDE_PATHS ${CMAKE_SOURCE_DIR}/interface/include/
Raef Coles23d6a192020-10-22 15:43:38 +010040 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/
Raef Colesc922f252020-10-05 10:49:30 +010041 ${CMAKE_BINARY_DIR}/generated/interface/include
42 )
Raef Coles5ee45ed2020-09-24 11:25:44 +010043 endif()
44
Raef Colesc922f252020-10-05 10:49:30 +010045 if(NOT SP_HEAP_MEM_SUPP)
Raef Coles06e6f652020-10-20 16:10:38 +010046 set(SP_HEAP_MEM_SUPP 0)
Raef Colesc922f252020-10-05 10:49:30 +010047 endif()
48 if(NOT PLATFORM_PSA_ISOLATION_LEVEL)
49 set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL})
50 endif()
51
52 if (NOT TOOLCHAIN)
53 if (${CMAKE_C_COMPILER_ID} STREQUAL GNU)
54 set(TOOLCHAIN GNUARM)
55 elseif (${CMAKE_C_COMPILER_ID} STREQUAL ARMClang)
56 set(TOOLCHAIN ARMCLANG)
57 endif()
58 endif()
59
60 if (NOT CPU_ARCH)
61 if (${CMAKE_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.main)
62 set(CPU_ARCH armv8m_ml)
63 elseif (${CMAKE_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.base)
64 set(CPU_ARCH armv8m_bl)
65 elseif (${CMAKE_SYSTEM_ARCHITECTURE} STREQUAL armv7-m)
66 set(CPU_ARCH armv7m)
67 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +010068 endif()
69
70 add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_CURRENT_BINARY_DIR}/psa_api_tests)
Kevin Peng62a87112020-07-07 15:07:46 +080071endif()
72
Raef Coles5ee45ed2020-09-24 11:25:44 +010073############################# Test integration #################################
Kevin Peng62a87112020-07-07 15:07:46 +080074
Raef Coles5ee45ed2020-09-24 11:25:44 +010075add_library(tfm_ns_integration_test STATIC EXCLUDE_FROM_ALL)
Kevin Peng62a87112020-07-07 15:07:46 +080076
Raef Coles5ee45ed2020-09-24 11:25:44 +010077target_sources(tfm_ns_integration_test
78 PRIVATE
79 tfm_integ_test.c
80)
Kevin Peng62a87112020-07-07 15:07:46 +080081
Raef Coles5ee45ed2020-09-24 11:25:44 +010082target_include_directories(tfm_ns_integration_test
83 PUBLIC
84 .
85)
Kevin Peng62a87112020-07-07 15:07:46 +080086
Raef Coles5ee45ed2020-09-24 11:25:44 +010087target_link_libraries(tfm_ns_integration_test
88 PUBLIC
89 $<$<BOOL:${TEST_NS}>:tfm_ns_tests>
90 tfm_test_framework
91 PRIVATE
92 psa_interface
Raef Coles5ee45ed2020-09-24 11:25:44 +010093 psa_api_ns
94 CMSIS_5_tfm_ns
95)
Kevin Peng62a87112020-07-07 15:07:46 +080096
Raef Coles5ee45ed2020-09-24 11:25:44 +010097target_compile_definitions(tfm_ns_integration_test
98 PUBLIC
99 $<$<BOOL:${TEST_NS}>:TEST_FRAMEWORK_NS>
100 $<$<BOOL:${TEST_S}>:TEST_FRAMEWORK_S>
101)
Kevin Peng62a87112020-07-07 15:07:46 +0800102
Raef Coles5ee45ed2020-09-24 11:25:44 +0100103############################# TFM NS app #######################################
Kevin Peng62a87112020-07-07 15:07:46 +0800104
Raef Coles5ee45ed2020-09-24 11:25:44 +0100105add_executable(tfm_ns)
Kevin Peng62a87112020-07-07 15:07:46 +0800106
Raef Coles5ee45ed2020-09-24 11:25:44 +0100107target_sources(tfm_ns
108 PRIVATE
109 main_ns.c
110 $<$<BOOL:${TEST_PSA_API}>:psa_api_test.c>
111)
Kevin Peng62a87112020-07-07 15:07:46 +0800112
Raef Coles5ee45ed2020-09-24 11:25:44 +0100113target_link_libraries(tfm_ns
114 PRIVATE
115 platform_ns
116 CMSIS_5_tfm_ns
117 $<$<OR:$<BOOL:${TEST_NS}>,$<BOOL:${TEST_S}>>:tfm_ns_integration_test>
118 $<$<BOOL:${TEST_PSA_API}>:val_nspe>
119 $<$<BOOL:${TEST_PSA_API}>:pal_nspe>
120 $<$<BOOL:${TEST_PSA_API}>:test_combine>
121 $<$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>:tfm_s_veneers>
122 psa_api_ns
Kevin Pengaf602292020-10-20 17:49:52 +0800123 tfm_ns_log
Raef Coles5ee45ed2020-09-24 11:25:44 +0100124)
Kevin Peng62a87112020-07-07 15:07:46 +0800125
Raef Coles5ee45ed2020-09-24 11:25:44 +0100126target_compile_definitions(tfm_ns
127 PUBLIC
128 $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_NS>
129)
Kevin Peng62a87112020-07-07 15:07:46 +0800130
Raef Coles5ee45ed2020-09-24 11:25:44 +0100131set_target_properties(tfm_ns PROPERTIES
132 SUFFIX ".axf"
133 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
134)
Kevin Peng62a87112020-07-07 15:07:46 +0800135
Raef Coles5ee45ed2020-09-24 11:25:44 +0100136target_link_options(tfm_ns
137 PRIVATE
138 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
139 $<$<C_COMPILER_ID:ARMClang>:--map>
TTornblomd35ffa02020-09-29 13:31:31 +0200140 $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
Raef Coles5ee45ed2020-09-24 11:25:44 +0100141)
Kevin Peng62a87112020-07-07 15:07:46 +0800142
Raef Coles5ee45ed2020-09-24 11:25:44 +0100143add_convert_to_bin_target(tfm_ns)
Kevin Peng62a87112020-07-07 15:07:46 +0800144
Raef Coles5ee45ed2020-09-24 11:25:44 +0100145############################# CMSIS ############################################
Kevin Peng62a87112020-07-07 15:07:46 +0800146
Raef Coles5ee45ed2020-09-24 11:25:44 +0100147include(FetchContent)
Kevin Peng62a87112020-07-07 15:07:46 +0800148
Raef Coles5ee45ed2020-09-24 11:25:44 +0100149set(FETCHCONTENT_QUIET FALSE)
150cmake_policy(SET CMP0079 NEW)
Kevin Peng62a87112020-07-07 15:07:46 +0800151
Raef Coles5ee45ed2020-09-24 11:25:44 +0100152add_library(CMSIS_5_tfm_ns INTERFACE)
Kevin Peng62a87112020-07-07 15:07:46 +0800153
Raef Coles5ee45ed2020-09-24 11:25:44 +0100154target_sources(CMSIS_5_tfm_ns
155 INTERFACE
156 ${CMSIS_5_PATH}/RTOS2/RTX/Config/RTX_Config.c
157 ${CMSIS_5_PATH}/RTOS2/RTX/Source/rtx_lib.c
158 ${CMAKE_CURRENT_SOURCE_DIR}/os_wrapper_cmsis_rtos_v2.c
159)
Kevin Peng62a87112020-07-07 15:07:46 +0800160
Raef Coles5ee45ed2020-09-24 11:25:44 +0100161target_include_directories(CMSIS_5_tfm_ns
162 INTERFACE
163 ${CMSIS_5_PATH}/Core/Include
164 ${CMSIS_5_PATH}/RTOS2/Include
165 ${CMSIS_5_PATH}/RTOS2/RTX/Include
166 ${CMSIS_5_PATH}/RTOS2/RTX/Config
167)
Kevin Peng62a87112020-07-07 15:07:46 +0800168
Raef Coles5ee45ed2020-09-24 11:25:44 +0100169target_link_libraries(CMSIS_5_tfm_ns
170 INTERFACE
171 platform_ns
172)