Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 2 | # Copyright (c) 2020, Arm Limited. All rights reserved. |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 8 | cmake_minimum_required(VERSION 3.13) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 9 | project(tfm_ns LANGUAGES ASM C) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 10 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 11 | # 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. |
| 15 | if (TFM_MULTI_CORE_TOPOLOGY) |
| 16 | include(${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 17 | endif() |
| 18 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 19 | ############################# PSA test integration ############################# |
| 20 | |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 21 | if(TEST_PSA_API AND NOT PSA_ARCH_TESTS_BINARY_PATH) |
| 22 | if(NOT SUITE) |
| 23 | set(SUITE ${TEST_PSA_API}) |
| 24 | endif() |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 25 | |
| 26 | string(REGEX REPLACE ".*/" "" PSA_API_TEST_TARGET ${TFM_PLATFORM}) |
| 27 | |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 28 | 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 Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 34 | endif() |
| 35 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 36 | |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 37 | if(NOT PSA_INCLUDE_PATHS) |
| 38 | set(PSA_INCLUDE_PATHS ${CMAKE_SOURCE_DIR}/interface/include/ |
Raef Coles | 23d6a19 | 2020-10-22 15:43:38 +0100 | [diff] [blame^] | 39 | ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/ |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 40 | ${CMAKE_BINARY_DIR}/generated/interface/include |
| 41 | ) |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 42 | endif() |
| 43 | |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 44 | if(NOT SP_HEAP_MEM_SUPP) |
Raef Coles | 06e6f65 | 2020-10-20 16:10:38 +0100 | [diff] [blame] | 45 | set(SP_HEAP_MEM_SUPP 0) |
Raef Coles | c922f25 | 2020-10-05 10:49:30 +0100 | [diff] [blame] | 46 | 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 Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 67 | endif() |
| 68 | |
| 69 | add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_CURRENT_BINARY_DIR}/psa_api_tests) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 70 | endif() |
| 71 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 72 | ############################# Test integration ################################# |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 73 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 74 | add_library(tfm_ns_integration_test STATIC EXCLUDE_FROM_ALL) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 75 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 76 | target_sources(tfm_ns_integration_test |
| 77 | PRIVATE |
| 78 | tfm_integ_test.c |
| 79 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 80 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 81 | target_include_directories(tfm_ns_integration_test |
| 82 | PUBLIC |
| 83 | . |
| 84 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 85 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 86 | target_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 Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 92 | psa_api_ns |
| 93 | CMSIS_5_tfm_ns |
| 94 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 95 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 96 | target_compile_definitions(tfm_ns_integration_test |
| 97 | PUBLIC |
| 98 | $<$<BOOL:${TEST_NS}>:TEST_FRAMEWORK_NS> |
| 99 | $<$<BOOL:${TEST_S}>:TEST_FRAMEWORK_S> |
| 100 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 101 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 102 | ############################# TFM NS app ####################################### |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 103 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 104 | add_executable(tfm_ns) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 105 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 106 | target_sources(tfm_ns |
| 107 | PRIVATE |
| 108 | main_ns.c |
| 109 | $<$<BOOL:${TEST_PSA_API}>:psa_api_test.c> |
| 110 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 111 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 112 | target_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 Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 123 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 124 | target_compile_definitions(tfm_ns |
| 125 | PUBLIC |
| 126 | $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_NS> |
| 127 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 128 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 129 | set_target_properties(tfm_ns PROPERTIES |
| 130 | SUFFIX ".axf" |
| 131 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
| 132 | ) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 133 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 134 | target_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 Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 139 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 140 | add_convert_to_bin_target(tfm_ns) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 141 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 142 | ############################# CMSIS ############################################ |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 143 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 144 | include(FetchContent) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 145 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 146 | set(FETCHCONTENT_QUIET FALSE) |
| 147 | cmake_policy(SET CMP0079 NEW) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 148 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 149 | add_library(CMSIS_5_tfm_ns INTERFACE) |
Kevin Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 150 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 151 | target_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 Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 157 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 158 | target_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 Peng | 62a8711 | 2020-07-07 15:07:46 +0800 | [diff] [blame] | 165 | |
Raef Coles | 5ee45ed | 2020-09-24 11:25:44 +0100 | [diff] [blame] | 166 | target_link_libraries(CMSIS_5_tfm_ns |
| 167 | INTERFACE |
| 168 | platform_ns |
| 169 | ) |