blob: 9770d20b4e354004d9e0549a0d20a4c94a78e674 [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)
Kevin Peng62a87112020-07-07 15:07:46 +080017endif()
18
Raef Coles5ee45ed2020-09-24 11:25:44 +010019############################# PSA test integration #############################
20
Raef Colesc922f252020-10-05 10:49:30 +010021if(TEST_PSA_API AND NOT PSA_ARCH_TESTS_BINARY_PATH)
22 if(NOT SUITE)
23 set(SUITE ${TEST_PSA_API})
24 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +010025
26 string(REGEX REPLACE ".*/" "" PSA_API_TEST_TARGET ${TFM_PLATFORM})
27
Raef Colesc922f252020-10-05 10:49:30 +010028 if(NOT TARGET)
29 if (NOT "${TEST_PSA_API}" STREQUAL "IPC")
30 set(TARGET tgt_dev_apis_tfm_${PSA_API_TEST_TARGET})
31 else()
32 set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET})
33 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +010034 endif()
35
Raef Coles5ee45ed2020-09-24 11:25:44 +010036
Raef Colesc922f252020-10-05 10:49:30 +010037 if(NOT PSA_INCLUDE_PATHS)
38 set(PSA_INCLUDE_PATHS ${CMAKE_SOURCE_DIR}/interface/include/
Raef Coles23d6a192020-10-22 15:43:38 +010039 ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/
Raef Colesc922f252020-10-05 10:49:30 +010040 ${CMAKE_BINARY_DIR}/generated/interface/include
41 )
Raef Coles5ee45ed2020-09-24 11:25:44 +010042 endif()
43
Raef Colesc922f252020-10-05 10:49:30 +010044 if(NOT SP_HEAP_MEM_SUPP)
Raef Coles06e6f652020-10-20 16:10:38 +010045 set(SP_HEAP_MEM_SUPP 0)
Raef Colesc922f252020-10-05 10:49:30 +010046 endif()
47 if(NOT PLATFORM_PSA_ISOLATION_LEVEL)
48 set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL})
49 endif()
50
51 if (NOT TOOLCHAIN)
52 if (${CMAKE_C_COMPILER_ID} STREQUAL GNU)
53 set(TOOLCHAIN GNUARM)
54 elseif (${CMAKE_C_COMPILER_ID} STREQUAL ARMClang)
55 set(TOOLCHAIN ARMCLANG)
56 endif()
57 endif()
58
59 if (NOT CPU_ARCH)
60 if (${CMAKE_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.main)
61 set(CPU_ARCH armv8m_ml)
62 elseif (${CMAKE_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.base)
63 set(CPU_ARCH armv8m_bl)
64 elseif (${CMAKE_SYSTEM_ARCHITECTURE} STREQUAL armv7-m)
65 set(CPU_ARCH armv7m)
66 endif()
Raef Coles5ee45ed2020-09-24 11:25:44 +010067 endif()
68
69 add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_CURRENT_BINARY_DIR}/psa_api_tests)
Kevin Peng62a87112020-07-07 15:07:46 +080070endif()
71
Raef Coles5ee45ed2020-09-24 11:25:44 +010072############################# Test integration #################################
Kevin Peng62a87112020-07-07 15:07:46 +080073
Raef Coles5ee45ed2020-09-24 11:25:44 +010074add_library(tfm_ns_integration_test STATIC EXCLUDE_FROM_ALL)
Kevin Peng62a87112020-07-07 15:07:46 +080075
Raef Coles5ee45ed2020-09-24 11:25:44 +010076target_sources(tfm_ns_integration_test
77 PRIVATE
78 tfm_integ_test.c
79)
Kevin Peng62a87112020-07-07 15:07:46 +080080
Raef Coles5ee45ed2020-09-24 11:25:44 +010081target_include_directories(tfm_ns_integration_test
82 PUBLIC
83 .
84)
Kevin Peng62a87112020-07-07 15:07:46 +080085
Raef Coles5ee45ed2020-09-24 11:25:44 +010086target_link_libraries(tfm_ns_integration_test
87 PUBLIC
88 $<$<BOOL:${TEST_NS}>:tfm_ns_tests>
89 tfm_test_framework
90 PRIVATE
91 psa_interface
Raef Coles5ee45ed2020-09-24 11:25:44 +010092 psa_api_ns
93 CMSIS_5_tfm_ns
94)
Kevin Peng62a87112020-07-07 15:07:46 +080095
Raef Coles5ee45ed2020-09-24 11:25:44 +010096target_compile_definitions(tfm_ns_integration_test
97 PUBLIC
98 $<$<BOOL:${TEST_NS}>:TEST_FRAMEWORK_NS>
99 $<$<BOOL:${TEST_S}>:TEST_FRAMEWORK_S>
100)
Kevin Peng62a87112020-07-07 15:07:46 +0800101
Raef Coles5ee45ed2020-09-24 11:25:44 +0100102############################# TFM NS app #######################################
Kevin Peng62a87112020-07-07 15:07:46 +0800103
Raef Coles5ee45ed2020-09-24 11:25:44 +0100104add_executable(tfm_ns)
Kevin Peng62a87112020-07-07 15:07:46 +0800105
Raef Coles5ee45ed2020-09-24 11:25:44 +0100106target_sources(tfm_ns
107 PRIVATE
108 main_ns.c
109 $<$<BOOL:${TEST_PSA_API}>:psa_api_test.c>
110)
Kevin Peng62a87112020-07-07 15:07:46 +0800111
Raef Coles5ee45ed2020-09-24 11:25:44 +0100112target_link_libraries(tfm_ns
113 PRIVATE
114 platform_ns
115 CMSIS_5_tfm_ns
116 $<$<OR:$<BOOL:${TEST_NS}>,$<BOOL:${TEST_S}>>:tfm_ns_integration_test>
117 $<$<BOOL:${TEST_PSA_API}>:val_nspe>
118 $<$<BOOL:${TEST_PSA_API}>:pal_nspe>
119 $<$<BOOL:${TEST_PSA_API}>:test_combine>
120 $<$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>:tfm_s_veneers>
121 psa_api_ns
122)
Kevin Peng62a87112020-07-07 15:07:46 +0800123
Raef Coles5ee45ed2020-09-24 11:25:44 +0100124target_compile_definitions(tfm_ns
125 PUBLIC
126 $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_NS>
127)
Kevin Peng62a87112020-07-07 15:07:46 +0800128
Raef Coles5ee45ed2020-09-24 11:25:44 +0100129set_target_properties(tfm_ns PROPERTIES
130 SUFFIX ".axf"
131 RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
132)
Kevin Peng62a87112020-07-07 15:07:46 +0800133
Raef Coles5ee45ed2020-09-24 11:25:44 +0100134target_link_options(tfm_ns
135 PRIVATE
136 $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
137 $<$<C_COMPILER_ID:ARMClang>:--map>
138)
Kevin Peng62a87112020-07-07 15:07:46 +0800139
Raef Coles5ee45ed2020-09-24 11:25:44 +0100140add_convert_to_bin_target(tfm_ns)
Kevin Peng62a87112020-07-07 15:07:46 +0800141
Raef Coles5ee45ed2020-09-24 11:25:44 +0100142############################# CMSIS ############################################
Kevin Peng62a87112020-07-07 15:07:46 +0800143
Raef Coles5ee45ed2020-09-24 11:25:44 +0100144include(FetchContent)
Kevin Peng62a87112020-07-07 15:07:46 +0800145
Raef Coles5ee45ed2020-09-24 11:25:44 +0100146set(FETCHCONTENT_QUIET FALSE)
147cmake_policy(SET CMP0079 NEW)
Kevin Peng62a87112020-07-07 15:07:46 +0800148
Raef Coles5ee45ed2020-09-24 11:25:44 +0100149add_library(CMSIS_5_tfm_ns INTERFACE)
Kevin Peng62a87112020-07-07 15:07:46 +0800150
Raef Coles5ee45ed2020-09-24 11:25:44 +0100151target_sources(CMSIS_5_tfm_ns
152 INTERFACE
153 ${CMSIS_5_PATH}/RTOS2/RTX/Config/RTX_Config.c
154 ${CMSIS_5_PATH}/RTOS2/RTX/Source/rtx_lib.c
155 ${CMAKE_CURRENT_SOURCE_DIR}/os_wrapper_cmsis_rtos_v2.c
156)
Kevin Peng62a87112020-07-07 15:07:46 +0800157
Raef Coles5ee45ed2020-09-24 11:25:44 +0100158target_include_directories(CMSIS_5_tfm_ns
159 INTERFACE
160 ${CMSIS_5_PATH}/Core/Include
161 ${CMSIS_5_PATH}/RTOS2/Include
162 ${CMSIS_5_PATH}/RTOS2/RTX/Include
163 ${CMSIS_5_PATH}/RTOS2/RTX/Config
164)
Kevin Peng62a87112020-07-07 15:07:46 +0800165
Raef Coles5ee45ed2020-09-24 11:25:44 +0100166target_link_libraries(CMSIS_5_tfm_ns
167 INTERFACE
168 platform_ns
169)