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