Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 1 | #/** @file |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 2 | # * Copyright (c) 2019-2020, Arm Limited or its affiliates. All rights reserved. |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 3 | # * SPDX-License-Identifier : Apache-2.0 |
| 4 | # * |
| 5 | # * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # * you may not use this file except in compliance with the License. |
| 7 | # * You may obtain a copy of the License at |
| 8 | # * |
| 9 | # * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # * |
| 11 | # * Unless required by applicable law or agreed to in writing, software |
| 12 | # * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # * See the License for the specific language governing permissions and |
| 15 | # * limitations under the License. |
| 16 | #**/ |
| 17 | |
| 18 | # Set the minimum required version of CMake for the project |
| 19 | cmake_minimum_required(VERSION 3.10) |
| 20 | |
| 21 | # cmake_policy |
| 22 | cmake_policy(SET CMP0057 NEW) |
| 23 | |
| 24 | # Find python interpreter version 3 or greater |
| 25 | find_package(PythonInterp 3 REQUIRED) |
| 26 | # Find Git package |
| 27 | find_package(Git REQUIRED) |
| 28 | |
| 29 | get_filename_component(PSA_ROOT_DIR . ABSOLUTE) |
| 30 | |
| 31 | list(APPEND CMAKE_MODULE_PATH ${PSA_ROOT_DIR}/tools/cmake) |
| 32 | include("common/Utils") |
| 33 | include(${PSA_ROOT_DIR}/tools/cmake/common/CMakeSettings.cmake) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 34 | include(${PSA_ROOT_DIR}/tools/cmake/common/CMakeExternal.cmake) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 35 | |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame^] | 36 | if(NOT DEFINED TFM_PROFILE) |
| 37 | message(STATUS "[PSA] : Building Default profile") |
| 38 | list(APPEND PSA_SUITES |
| 39 | "IPC" |
| 40 | "CRYPTO" |
| 41 | "INTERNAL_TRUSTED_STORAGE" |
| 42 | "PROTECTED_STORAGE" |
| 43 | "STORAGE" |
| 44 | "INITIAL_ATTESTATION" |
| 45 | ) |
| 46 | else() |
| 47 | |
| 48 | if("${TFM_PROFILE}" STREQUAL "profile_small") |
| 49 | # list of supported suites |
| 50 | list(APPEND PSA_SUITES |
| 51 | "CRYPTO" |
| 52 | "INTERNAL_TRUSTED_STORAGE" |
| 53 | "INITIAL_ATTESTATION" |
| 54 | ) |
| 55 | else() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 56 | # list of supported suites |
| 57 | list(APPEND PSA_SUITES |
| 58 | "IPC" |
| 59 | "CRYPTO" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 60 | "INTERNAL_TRUSTED_STORAGE" |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame^] | 61 | "PROTECTED_STORAGE" |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 62 | "STORAGE" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 63 | "INITIAL_ATTESTATION" |
| 64 | ) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame^] | 65 | endif() |
| 66 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 67 | # list of ipc files required |
| 68 | list(APPEND PSA_IPC_FILES |
| 69 | "psa/client.h" |
| 70 | "psa/service.h" |
Jaykumar Pitambarbhai Patel | 1c2b028 | 2019-11-06 11:29:13 +0530 | [diff] [blame] | 71 | "psa/lifecycle.h" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 72 | "psa_manifest/sid.h" |
| 73 | "psa_manifest/pid.h" |
Jaykumar Pitambarbhai Patel | 1c2b028 | 2019-11-06 11:29:13 +0530 | [diff] [blame] | 74 | "psa_manifest/driver_partition_psa.h" |
| 75 | "psa_manifest/client_partition_psa.h" |
| 76 | "psa_manifest/server_partition_psa.h" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 77 | ) |
| 78 | |
| 79 | # list of crypto files required |
| 80 | list(APPEND PSA_CRYPTO_FILES |
| 81 | "psa/crypto.h" |
| 82 | ) |
| 83 | |
| 84 | # list of protected_storage files required |
| 85 | list(APPEND PSA_PROTECTED_STORAGE_FILES |
| 86 | "psa/protected_storage.h" |
| 87 | ) |
| 88 | |
| 89 | # list of internal_trusted_storage files required |
| 90 | list(APPEND PSA_INTERNAL_TRUSTED_STORAGE_FILES |
| 91 | "psa/internal_trusted_storage.h" |
| 92 | ) |
| 93 | |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 94 | # list of storage files required |
| 95 | list(APPEND PSA_STORAGE_FILES |
| 96 | ${PSA_INTERNAL_TRUSTED_STORAGE_FILES} |
| 97 | ${PSA_PROTECTED_STORAGE_FILES} |
| 98 | ) |
| 99 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 100 | # list of initial_attestation files required |
| 101 | list(APPEND PSA_INITIAL_ATTESTATION_FILES |
| 102 | "psa/initial_attestation.h" |
| 103 | "psa/crypto.h" |
| 104 | ) |
| 105 | |
| 106 | # list of supported toolchains |
| 107 | list(APPEND PSA_TOOLCHAIN_SUPPORT |
| 108 | GNUARM |
| 109 | ARMCLANG |
| 110 | HOST_GCC |
| 111 | ) |
| 112 | |
| 113 | # list of suported CPU arch |
| 114 | list(APPEND PSA_CPU_ARCH_SUPPORT |
| 115 | armv8m_ml |
| 116 | armv8m_bl |
| 117 | armv7m |
| 118 | ) |
| 119 | |
| 120 | # list of VERBOSE options |
| 121 | list(APPEND PSA_VERBOSE_OPTIONS 1 2 3 4 5) |
| 122 | |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 123 | # list of PLATFORM_PSA_ISOLATION_LEVEL options |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame^] | 124 | if("${TFM_PROFILE}" STREQUAL "profile_medium") |
| 125 | list(APPEND PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS 1 2) |
| 126 | else() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 127 | list(APPEND PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS 1 2 3) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame^] | 128 | endif() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 129 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 130 | message(STATUS "[PSA] : ----------Process input arguments- start-------------") |
| 131 | |
| 132 | # Check for TARGET command line argument |
| 133 | _check_arguments("TARGET") |
| 134 | # Check for SUTIE command line argument |
| 135 | _check_arguments("SUITE") |
| 136 | # Check for PSA_INCLUDE_PATHS command line argument |
| 137 | _check_arguments("PSA_INCLUDE_PATHS") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 138 | |
| 139 | string(TOLOWER ${SUITE} SUITE_LOWER) |
| 140 | |
| 141 | # Check for valid targets |
| 142 | _get_sub_dir_list(PSA_TARGET_LIST ${PSA_ROOT_DIR}/platform/targets) |
| 143 | if(NOT ${TARGET} IN_LIST PSA_TARGET_LIST) |
| 144 | message(FATAL_ERROR "[PSA] : Error: Unspported value for -DTARGET=, supported targets are : ${PSA_TARGET_LIST}") |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 145 | else() |
| 146 | message(STATUS "[PSA] : TARGET is set to ${TARGET}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 147 | endif() |
| 148 | |
| 149 | # Check for the presence of required test suite directories |
| 150 | if((NOT IS_DIRECTORY ${PSA_ROOT_DIR}/dev_apis) OR (NOT IS_DIRECTORY ${PSA_ROOT_DIR}/ff)) |
| 151 | message(STATUS "[PSA] : Error: Could not find architecture test suite directories in psa root path ${PSA_ROOT_DIR}") |
| 152 | endif() |
| 153 | |
| 154 | if(FALSE) |
| 155 | # Check for build directory specified |
| 156 | if(NOT DEFINED BUILD) |
| 157 | set(BUILD ${CMAKE_CURRENT_BINARY_DIR}/BUILD CACHE INTERNAL "Defaulting build directory to ${BUILD}" FORCE) |
| 158 | else() |
| 159 | set(BUILD ${CMAKE_CURRENT_BINARY_DIR}/${BUILD}/BUILD CACHE INTERNAL "Defaulting build directory to ${BUILD}" FORCE) |
| 160 | endif() |
| 161 | endif() |
| 162 | |
| 163 | # Check for valid suite cmake argument passed |
| 164 | if(NOT ${SUITE} IN_LIST PSA_SUITES) |
| 165 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DSUITE=, select one from supported suites which are : ${PSA_SUITES}") |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 166 | else() |
| 167 | message(STATUS "[PSA] : SUITE is set to ${SUITE}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 168 | endif() |
| 169 | |
| 170 | # Project variables |
| 171 | set(PSA_TARGET_PRE_BUILD psa_pre_build) |
| 172 | set(PSA_TARGET_GENERATE_DATABASE_PRE psa_generate_database_prerequisite) |
| 173 | set(PSA_TARGET_GENERATE_DATABASE psa_generate_database) |
| 174 | set(PSA_TARGET_GENERATE_DATABASE_POST psa_generate_database_cleanup) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 175 | if(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
| 176 | set(PSA_TARGET_QCBOR psa_qcbor) |
| 177 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 178 | set(PSA_TARGET_PAL_NSPE_LIB pal_nspe) |
| 179 | set(PSA_TARGET_VAL_NSPE_LIB val_nspe) |
| 180 | set(PSA_TARGET_TEST_COMBINE_LIB test_combine) |
| 181 | set(PSA_TARGET_DRIVER_PARTITION_LIB driver_partition) |
| 182 | set(PSA_TARGET_CLIENT_PARTITION_LIB client_partition) |
| 183 | set(PSA_TARGET_SERVER_PARTITION_LIB server_partition) |
| 184 | if(${SUITE} STREQUAL "IPC") |
| 185 | set(PSA_SUITE_DIR ${PSA_ROOT_DIR}/ff/${SUITE_LOWER}) |
| 186 | set(PSA_SUITE_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/ff/${SUITE_LOWER}) |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 187 | elseif((${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE") OR (${SUITE} STREQUAL "PROTECTED_STORAGE")) |
| 188 | set(PSA_SUITE_DIR ${PSA_ROOT_DIR}/dev_apis/storage) |
| 189 | set(PSA_SUITE_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/dev_apis/storage) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 190 | else() |
| 191 | set(PSA_SUITE_DIR ${PSA_ROOT_DIR}/dev_apis/${SUITE_LOWER}) |
| 192 | set(PSA_SUITE_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/dev_apis/${SUITE_LOWER}) |
| 193 | endif() |
| 194 | set(PSA_TARGET_CONFIG_HEADER_GENERATOR ${PSA_ROOT_DIR}/tools/scripts/target_cfg/targetConfigGen.py) |
| 195 | set(PSA_TESTLIST_GENERATOR ${PSA_ROOT_DIR}/tools/scripts/gen_tests_list.py) |
| 196 | set(TARGET_CONFIGURATION_FILE ${PSA_ROOT_DIR}/platform/targets/${TARGET}/target.cfg) |
| 197 | set(TGT_CONFIG_SOURCE_C ${CMAKE_CURRENT_BINARY_DIR}/targetConfigGen.c) |
| 198 | set(OUTPUT_HEADER target_database.h) |
| 199 | set(DATABASE_TABLE_NAME target_database) |
| 200 | set(DATABASE_TABLE_SECTION_NAME "NOSECTION") |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 201 | set(TARGET_HEADER_GEN_INCLUDE_PATHS "${PSA_ROOT_DIR}/val/nspe|${PSA_ROOT_DIR}/val/common|${PSA_ROOT_DIR}/platform/targets/common/nspe|${PSA_ROOT_DIR}/platform/targets/common/nspe/crypto|${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe") |
| 202 | if(${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE") |
| 203 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/its_testsuite.db) |
| 204 | elseif((${SUITE} STREQUAL "PROTECTED_STORAGE") OR (${SUITE} STREQUAL "STORAGE")) |
| 205 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/ps_testsuite.db) |
| 206 | else() |
| 207 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 208 | endif() |
| 209 | set(PSA_TESTLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/${SUITE_LOWER}_testlist.txt) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 210 | set(PSA_TEST_ENTRY_LIST_INC ${CMAKE_CURRENT_BINARY_DIR}/test_entry_list.inc) |
| 211 | set(PSA_TEST_ENTRY_FUN_DECLARE_INC ${CMAKE_CURRENT_BINARY_DIR}/test_entry_fn_declare_list.inc) |
| 212 | set(PSA_CLIENT_TEST_LIST_DELCARE_INC ${CMAKE_CURRENT_BINARY_DIR}/client_tests_list_declare.inc) |
| 213 | set(PSA_CLIENT_TEST_LIST_INC ${CMAKE_CURRENT_BINARY_DIR}/client_tests_list.inc) |
| 214 | set(PSA_SERVER_TEST_LIST_DECLARE_INC ${CMAKE_CURRENT_BINARY_DIR}/server_tests_list_declare.inc) |
| 215 | set(PSA_SERVER_TEST_LIST ${CMAKE_CURRENT_BINARY_DIR}/server_tests_list.inc) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 216 | if(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
| 217 | set(PSA_QCBOR_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${PSA_TARGET_QCBOR}/inc) |
| 218 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 219 | |
| 220 | # Validity check for required files for a given suite |
| 221 | if(NOT DEFINED PSA_${SUITE}_FILES) |
| 222 | message(FATAL_ERROR "[PSA] : List of file/s to verify against ${suite} is not defined") |
| 223 | endif() |
| 224 | foreach(file_item ${PSA_${SUITE}_FILES}) |
| 225 | set(PSA_FILE_FOUND FALSE) |
| 226 | foreach(include_path ${PSA_INCLUDE_PATHS}) |
| 227 | if((EXISTS ${include_path}/${file_item}) AND |
| 228 | (NOT PSA_FILE_FOUND)) |
| 229 | set(PSA_FILE_FOUND TRUE) |
| 230 | break() |
| 231 | endif() |
| 232 | endforeach() |
| 233 | if(NOT PSA_FILE_FOUND) |
| 234 | message(FATAL_ERROR "[PSA] : Couldn't find ${file_item} in ${PSA_INCLUDE_PATHS}") |
| 235 | endif() |
| 236 | endforeach() |
| 237 | |
| 238 | # Check for TOOLCHAIN command line argument |
| 239 | if(NOT DEFINED TOOLCHAIN) |
| 240 | set(TOOLCHAIN "GNUARM" CACHE INTERNAL "Compiler used" FORCE) |
| 241 | message(STATUS "[PSA] : Defaulting compiler to ${TOOLCHAIN}") |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 242 | else() |
| 243 | message(STATUS "[PSA] : TOOLCHAIN is set to ${TOOLCHAIN}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 244 | endif() |
| 245 | |
Gowtham Siddarth | 1d6d469 | 2019-09-16 11:47:29 +0530 | [diff] [blame] | 246 | if(${TOOLCHAIN} STREQUAL "ARMCLANG" OR ${TOOLCHAIN} STREQUAL "GNUARM") |
| 247 | if(NOT DEFINED CPU_ARCH) |
| 248 | message(FATAL_ERROR "[PSA] : Error: -DCPU_ARCH option missing") |
| 249 | else() |
| 250 | # Check for CPU architecture |
| 251 | if(NOT ${CPU_ARCH} IN_LIST PSA_CPU_ARCH_SUPPORT) |
| 252 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DCPU_ARCH=, supported CPU arch are : ${PSA_CPU_ARCH_SUPPORT}") |
| 253 | endif() |
| 254 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 255 | message(STATUS "[PSA] : CPU_ARCH is set to ${CPU_ARCH}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 256 | endif() |
| 257 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 258 | # Check for VERBOSE |
| 259 | if(NOT DEFINED VERBOSE) |
| 260 | set(VERBOSE 3 CACHE INTERNAL "Default VERBOSE value" FORCE) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 261 | message(STATUS "[PSA] : Defaulting VERBOSE to ${VERBOSE}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 262 | else() |
| 263 | if(NOT ${VERBOSE} IN_LIST PSA_VERBOSE_OPTIONS) |
| 264 | message(FATAL_ERROR "[PSA] : Error: Unspported value for -DVERBOSE=, supported values are : ${PSA_VERBOSE_OPTIONS}") |
| 265 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 266 | message(STATUS "[PSA] : VERBOSE is set to ${VERBOSE}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 267 | endif() |
| 268 | |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 269 | # Check for PLATFORM_PSA_ISOLATION_LEVEL |
| 270 | if(NOT DEFINED PLATFORM_PSA_ISOLATION_LEVEL) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame^] | 271 | if("${TFM_PROFILE}" STREQUAL "profile_medium") |
| 272 | set(PLATFORM_PSA_ISOLATION_LEVEL 2 CACHE INTERNAL "Default PLATFORM_PSA_ISOLATION_LEVEL value" FORCE) |
| 273 | else() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 274 | set(PLATFORM_PSA_ISOLATION_LEVEL 3 CACHE INTERNAL "Default PLATFORM_PSA_ISOLATION_LEVEL value" FORCE) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame^] | 275 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 276 | if(${SUITE} STREQUAL "IPC") |
| 277 | message(STATUS "[PSA] : Defaulting PLATFORM_PSA_ISOLATION_LEVEL to ${PLATFORM_PSA_ISOLATION_LEVEL}") |
| 278 | endif() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 279 | else() |
| 280 | if(NOT ${PLATFORM_PSA_ISOLATION_LEVEL} IN_LIST PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS) |
| 281 | message(FATAL_ERROR "[PSA] : Error: Unspported value for -DPLATFORM_PSA_ISOLATION_LEVEL=, supported values are : ${PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS}") |
| 282 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 283 | if(${SUITE} STREQUAL "IPC") |
| 284 | message(STATUS "[PSA] : PLATFORM_PSA_ISOLATION_LEVEL is set to ${PLATFORM_PSA_ISOLATION_LEVEL}") |
| 285 | endif() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 286 | endif() |
| 287 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 288 | if(NOT DEFINED INCLUDE_PANIC_TESTS) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 289 | #By default panic tests are disabled |
| 290 | set(INCLUDE_PANIC_TESTS 0 CACHE INTERNAL "Default INCLUDE_PANIC_TESTS value" FORCE) |
| 291 | message(STATUS "[PSA] : Defaulting INCLUDE_PANIC_TESTS to ${INCLUDE_PANIC_TESTS}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 292 | else() |
| 293 | if(INCLUDE_PANIC_TESTS EQUAL 1) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 294 | message(STATUS "[PSA] : " |
| 295 | "INCLUDE_PANIC_TESTS set to 1, therefore including PSA APIs panic tests into the regression,\n" |
| 296 | "\tensure that watchdog.num is set to 1 in ${PSA_ROOT_DIR}/platform/targets/${TARGET}/target.cfg") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 297 | endif() |
| 298 | endif() |
| 299 | |
| 300 | if(NOT DEFINED WATCHDOG_AVAILABLE) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 301 | #Assuming watchdog is available to program by test suite |
| 302 | set(WATCHDOG_AVAILABLE 1 CACHE INTERNAL "Default WATCHDOG_AVAILABLE value" FORCE) |
| 303 | message(STATUS "[PSA] : Defaulting WATCHDOG_AVAILABLE to ${WATCHDOG_AVAILABLE}") |
| 304 | else() |
| 305 | message(STATUS "[PSA] : WATCHDOG_AVAILABLE is set to ${WATCHDOG_AVAILABLE}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 306 | endif() |
| 307 | |
| 308 | if((INCLUDE_PANIC_TESTS EQUAL 1) AND |
| 309 | (WATCHDOG_AVAILABLE EQUAL 0)) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 310 | message(WARNING "[PSA]: " |
| 311 | "Note that to test PSA APIs panic conditions, test harness may require to access" |
| 312 | "the watchdog timer in oder to recover from panic and to be able to continue with" |
| 313 | "next test. Ignore this warning if system under test has capability to reset the" |
| 314 | "system when it encounters panic condition.") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 315 | endif() |
| 316 | |
| 317 | if(NOT DEFINED SP_HEAP_MEM_SUPP) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 318 | #Are dynamic memory functions available to secure partition? |
| 319 | set(SP_HEAP_MEM_SUPP 1 CACHE INTERNAL "Default SP_HEAP_MEM_SUPP value" FORCE) |
| 320 | message(STATUS "[PSA] : Defaulting SP_HEAP_MEM_SUPP to ${SP_HEAP_MEM_SUPP}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 321 | endif() |
| 322 | |
Vinay Kumar Kotegowder | ac21899 | 2020-04-03 12:56:00 +0530 | [diff] [blame] | 323 | if(NOT DEFINED SUITE_TEST_RANGE) |
| 324 | set(SUITE_TEST_RANGE_MIN None) |
| 325 | set(SUITE_TEST_RANGE_MAX None) |
| 326 | else() |
| 327 | list(LENGTH SUITE_TEST_RANGE SUITE_TEST_RANGE_LENGTH) |
| 328 | if(${SUITE_TEST_RANGE_LENGTH} GREATER "2") |
| 329 | message(FATAL_ERROR "[PSA] : -DSUITE_TEST_RANGE=<...> value error! accepts two " |
| 330 | " numbers in quotes separated with ';'") |
| 331 | endif() |
| 332 | if(${SUITE_TEST_RANGE_LENGTH} EQUAL "2") |
| 333 | list(GET SUITE_TEST_RANGE 0 SUITE_TEST_RANGE_MIN) |
| 334 | list(GET SUITE_TEST_RANGE 1 SUITE_TEST_RANGE_MAX) |
| 335 | message(STATUS "[PSA] : Testing (${SUITE_TEST_RANGE_MIN}, ${SUITE_TEST_RANGE_MAX}) of ${SUITE} suite") |
| 336 | endif() |
| 337 | if(${SUITE_TEST_RANGE_LENGTH} EQUAL "1") |
| 338 | set(SUITE_TEST_RANGE_MIN ${SUITE_TEST_RANGE}) |
| 339 | set(SUITE_TEST_RANGE_MAX ${SUITE_TEST_RANGE}) |
| 340 | message(STATUS "[PSA] : Testing ${SUITE_TEST_RANGE_MIN} of ${SUITE} suite") |
| 341 | endif() |
| 342 | endif() |
| 343 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 344 | message(STATUS "[PSA] : ----------Process input arguments- complete-------------") |
| 345 | |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 346 | |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame^] | 347 | if((${SUITE} STREQUAL "INITIAL_ATTESTATION") AND (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${PSA_TARGET_QCBOR})) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 348 | # Clone QCBOR and move to specified tag |
| 349 | execute_process(COMMAND ${GIT_EXECUTABLE} clone ${PSA_QCBOR_GIT_REPO_LINK} ${PSA_TARGET_QCBOR} |
| 350 | RESULT_VARIABLE ${PSA_TARGET_QCBOR}_clone_result |
| 351 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
| 352 | if(${PSA_TARGET_QCBOR}_clone_result) |
| 353 | message(FATAL_ERROR "git clone failed for ${PSA_QCBOR_GIT_REPO_LINK}") |
| 354 | endif() |
| 355 | |
| 356 | if(NOT ${PSA_TARGET_QCBOR}_clone_result) |
| 357 | execute_process(COMMAND ${GIT_EXECUTABLE} checkout -q "${PSA_QCBOR_GIT_REPO_TAG}" |
| 358 | RESULT_VARIABLE ${PSA_TARGET_QCBOR}_checkout_result |
| 359 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PSA_TARGET_QCBOR}) |
| 360 | if(${PSA_TARGET_QCBOR}_checkout_result) |
| 361 | message(FATAL_ERROR "git checkout failed for Repo : ${PSA_QCBOR_GIT_REPO_LINK}, Tag : ${PSA_QCBOR_GIT_REPO_TAG}") |
| 362 | endif() |
| 363 | endif() |
| 364 | endif() |
gowtham siddarth | 1283304 | 2020-02-10 22:11:11 +0530 | [diff] [blame] | 365 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 366 | # Create PSA clean list |
| 367 | list(APPEND PSA_CLEAN_LIST |
| 368 | ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_HEADER} |
| 369 | ${PSA_TESTLIST_FILE} |
| 370 | ${PSA_TEST_ENTRY_LIST_INC} |
| 371 | ${PSA_TEST_ENTRY_FUN_DECLARE_INC} |
| 372 | ${PSA_CLIENT_TEST_LIST_DELCARE_INC} |
| 373 | ${PSA_CLIENT_TEST_LIST_INC} |
| 374 | ${PSA_SERVER_TEST_LIST_DECLARE_INC} |
| 375 | ${PSA_SERVER_TEST_LIST} |
| 376 | ) |
| 377 | |
| 378 | # Process testsuite.db |
| 379 | message(STATUS "[PSA] : Creating testlist.txt 'available at ${PSA_TESTLIST_FILE}'") |
| 380 | execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PSA_TESTLIST_GENERATOR} |
| 381 | ${SUITE_LOWER} |
| 382 | ${TESTSUITE_DB} |
| 383 | ${INCLUDE_PANIC_TESTS} |
| 384 | ${PSA_TESTLIST_FILE} |
| 385 | ${PSA_TEST_ENTRY_LIST_INC} |
| 386 | ${PSA_TEST_ENTRY_FUN_DECLARE_INC} |
| 387 | ${PSA_CLIENT_TEST_LIST_DELCARE_INC} |
| 388 | ${PSA_CLIENT_TEST_LIST_INC} |
| 389 | ${PSA_SERVER_TEST_LIST_DECLARE_INC} |
Vinay Kumar Kotegowder | ac21899 | 2020-04-03 12:56:00 +0530 | [diff] [blame] | 390 | ${PSA_SERVER_TEST_LIST} |
| 391 | ${SUITE_TEST_RANGE_MIN} |
| 392 | ${SUITE_TEST_RANGE_MAX}) |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 393 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 394 | # Creating CMake list variable from file |
| 395 | file(READ ${PSA_TESTLIST_FILE} PSA_TEST_LIST) |
Vinay Kumar Kotegowder | ac21899 | 2020-04-03 12:56:00 +0530 | [diff] [blame] | 396 | if(NOT PSA_TEST_LIST) |
| 397 | message(FATAL_ERROR "[PSA] : Invalid test number!") |
| 398 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 399 | string(REGEX REPLACE "\n" ";" PSA_TEST_LIST "${PSA_TEST_LIST}") |
| 400 | |
| 401 | add_custom_target( |
| 402 | ${PSA_TARGET_GENERATE_DATABASE_PRE} |
| 403 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/platform |
| 404 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/val |
| 405 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/partition |
| 406 | COMMAND ${CMAKE_COMMAND} -E make_directory ${PSA_SUITE_OUT_DIR} |
| 407 | ) |
| 408 | |
| 409 | # Generate target files from User provided data base |
| 410 | include(ExternalProject) |
| 411 | ExternalProject_Add( |
| 412 | ${PSA_TARGET_GENERATE_DATABASE} |
| 413 | PREFIX ${CMAKE_CURRENT_BINARY_DIR} |
| 414 | DOWNLOAD_COMMAND "" |
| 415 | UPDATE_COMMAND "" |
| 416 | PATCH_COMMAND "" |
| 417 | BUILD_COMMAND "" |
| 418 | SOURCE_DIR "${PSA_ROOT_DIR}/tools/scripts/target_cfg" |
| 419 | CMAKE_ARGS -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} |
| 420 | -DOUT_DIR=${CMAKE_CURRENT_BINARY_DIR} |
| 421 | -DTARGET=${TARGET} |
| 422 | -DGENERATOR_FILE=${PSA_TARGET_CONFIG_HEADER_GENERATOR} |
| 423 | -DINCLUDE_DIR=${PSA_ROOT_DIR}/val/common |
| 424 | -DTARGET_CONFIGURATION_FILE=${TARGET_CONFIGURATION_FILE} |
| 425 | -DTGT_CONFIG_SOURCE_C=${TGT_CONFIG_SOURCE_C} |
| 426 | -DOUTPUT_HEADER=${OUTPUT_HEADER} |
| 427 | -DDATABASE_TABLE_NAME=${DATABASE_TABLE_NAME} |
| 428 | -DDATABASE_TABLE_SECTION_NAME=${DATABASE_TABLE_SECTION_NAME} |
| 429 | -DTARGET_HEADER_GEN_INCLUDE_PATHS=${TARGET_HEADER_GEN_INCLUDE_PATHS} |
| 430 | LIST_SEPARATOR | |
| 431 | TEST_COMMAND "" |
| 432 | ) |
| 433 | |
| 434 | # Add custom target to clean generated files of the external project |
| 435 | add_custom_target( |
| 436 | ${PSA_TARGET_GENERATE_DATABASE_POST} |
| 437 | COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/src/${PSA_TARGET_GENERATE_DATABASE}-build/ -- clean |
| 438 | ) |
| 439 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 440 | # Check for supported toolchain/s |
| 441 | if(${TOOLCHAIN} IN_LIST PSA_TOOLCHAIN_SUPPORT) |
| 442 | include(${PSA_ROOT_DIR}/tools/cmake/compiler/${TOOLCHAIN}.cmake) |
| 443 | else() |
| 444 | message(FATAL_ERROR "[PSA] : Error: Unspported value for -DTOOLCHAIN=, supported toolchain are : ${PSA_TOOLCHAIN_SUPPORT}") |
| 445 | endif() |
| 446 | |
| 447 | # Global macro to identify the PSA test suite cmake build |
| 448 | add_definitions(-DPSA_CMAKE_BUILD) |
| 449 | add_definitions(-D${SUITE}) |
| 450 | add_definitions(-DVERBOSE=${VERBOSE}) |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 451 | add_definitions(-DPLATFORM_PSA_ISOLATION_LEVEL=${PLATFORM_PSA_ISOLATION_LEVEL}) |
Vinay Kumar Kotegowder | 52bbfc9 | 2020-07-03 17:23:59 +0530 | [diff] [blame] | 452 | add_definitions(-D${TARGET}) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame^] | 453 | if("${TFM_PROFILE}" STREQUAL "profile_small") |
| 454 | message(STATUS "[PSA] : Building SMALL profile") |
| 455 | add_definitions(-DTF_M_PROFILE_SMALL) |
| 456 | elseif("${TFM_PROFILE}" STREQUAL "profile_medium") |
| 457 | message(STATUS "[PSA] : Building MEDIUM profile") |
| 458 | add_definitions(-DTF_M_PROFILE_MEDIUM) |
| 459 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 460 | if(${SP_HEAP_MEM_SUPP} EQUAL 1) |
| 461 | add_definitions(-DSP_HEAP_MEM_SUPP) |
| 462 | endif() |
| 463 | |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 464 | # Build PAL NSPE LIB |
| 465 | include(${PSA_ROOT_DIR}/platform/targets/${TARGET}/target.cmake) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 466 | # Build VAL NSPE LIB |
| 467 | #add_definitions(-DVAL_NSPE_BUILD) |
| 468 | include(${PSA_ROOT_DIR}/val/val_nspe.cmake) |
| 469 | # Build test |
| 470 | include(${PSA_SUITE_DIR}/suite.cmake) |
| 471 | if(${SUITE} STREQUAL "IPC") |
| 472 | # Build SPE LIB |
| 473 | include(${PSA_ROOT_DIR}/val/val_spe.cmake) |
| 474 | endif() |
| 475 | |
| 476 | add_dependencies(${PSA_TARGET_GENERATE_DATABASE} ${PSA_TARGET_GENERATE_DATABASE_PRE}) |
| 477 | add_dependencies(${PSA_TARGET_GENERATE_DATABASE_POST} ${PSA_TARGET_GENERATE_DATABASE}) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 478 | add_dependencies(${PSA_TARGET_PAL_NSPE_LIB} ${PSA_TARGET_GENERATE_DATABASE_POST}) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 479 | add_dependencies(${PSA_TARGET_VAL_NSPE_LIB} ${PSA_TARGET_PAL_NSPE_LIB}) |
| 480 | add_dependencies(${PSA_TARGET_TEST_COMBINE_LIB} ${PSA_TARGET_VAL_NSPE_LIB}) |
| 481 | if(${SUITE} STREQUAL "IPC") |
| 482 | add_dependencies(${PSA_TARGET_DRIVER_PARTITION_LIB} ${PSA_TARGET_TEST_COMBINE_LIB}) |
| 483 | add_dependencies(${PSA_TARGET_CLIENT_PARTITION_LIB} ${PSA_TARGET_DRIVER_PARTITION_LIB}) |
| 484 | add_dependencies(${PSA_TARGET_SERVER_PARTITION_LIB} ${PSA_TARGET_CLIENT_PARTITION_LIB}) |
| 485 | endif() |
| 486 | |
| 487 | # Include the files for make clean |
| 488 | foreach(clean_item ${PSA_CLEAN_LIST}) |
| 489 | set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clean_item}) |
| 490 | endforeach() |
| 491 | |
| 492 | set_property(TARGET ${PSA_TARGET_VAL_NSPE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/val) |
| 493 | set_property(TARGET ${PSA_TARGET_PAL_NSPE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/platform) |
| 494 | set_property(TARGET ${PSA_TARGET_TEST_COMBINE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${PSA_SUITE_OUT_DIR}) |
| 495 | if(${SUITE} STREQUAL "IPC") |
| 496 | set_property(TARGET ${PSA_TARGET_DRIVER_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 497 | set_property(TARGET ${PSA_TARGET_CLIENT_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 498 | set_property(TARGET ${PSA_TARGET_SERVER_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 499 | endif() |