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