Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
Balint Dobszay | 047aea8 | 2022-05-16 14:20:53 +0200 | [diff] [blame] | 7 | cmake_minimum_required(VERSION 3.18 FATAL_ERROR) |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 8 | |
| 9 | # Set default platform. |
| 10 | set(TS_PLATFORM "arm/fvp/fvp_base_revc-2xaemv8a" CACHE STRING "Target platform location.") |
Gyorgy Szing | 34aaf21 | 2022-10-20 07:26:23 +0200 | [diff] [blame] | 11 | |
| 12 | # Te crypto SP is big. Set default build type to MinSizWithDebInfo to avoid running ouf of |
| 13 | # secure memory on low resource IoT platforms. |
| 14 | if (NOT DEFINED CMAKE_BUILD_TYPE) |
| 15 | set(CMAKE_BUILD_TYPE "MinSizWithDebInfo" CACHE STRING "Build type.") |
| 16 | endif() |
| 17 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 18 | include(../../../deployment.cmake REQUIRED) |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 19 | |
| 20 | #------------------------------------------------------------------------------- |
| 21 | # The CMakeLists.txt for building the crypto deployment for generic sp |
| 22 | # environment. |
| 23 | # |
| 24 | # Builds the Crypto service provider for running in an SEL0 secure partition |
| 25 | # hosted by any SPM. |
| 26 | #------------------------------------------------------------------------------- |
| 27 | include(${TS_ROOT}/environments/sp/env.cmake) |
| 28 | set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type") |
| 29 | project(trusted-services LANGUAGES C ASM) |
| 30 | add_executable(crypto) |
| 31 | target_include_directories(crypto PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 32 | set(SP_NAME "crypto") |
Jelle Sels | 4960c41 | 2023-02-01 09:43:24 +0100 | [diff] [blame] | 33 | set(SP_BIN_UUID_CANON "d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0") |
| 34 | set(SP_FFA_UUID_CANON "${TS_RPC_UUID_CANON}") |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 35 | set(TRACE_PREFIX "CRYPTO" CACHE STRING "Trace prefix") |
| 36 | set(SP_STACK_SIZE "64 * 1024" CACHE STRING "Stack size") |
| 37 | set(SP_HEAP_SIZE "490 * 1024" CACHE STRING "Heap size") |
Gabor Toth | 1b0c11a | 2024-04-05 11:43:55 +0200 | [diff] [blame] | 38 | set(SP_BOOT_ORDER "4" CACHE STRING "Boot order of the SP") |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 39 | |
| 40 | #------------------------------------------------------------------------------- |
| 41 | # Components that are specific to deployment in the opteesp environment. |
| 42 | # |
| 43 | #------------------------------------------------------------------------------- |
| 44 | add_components(TARGET "crypto" |
| 45 | BASE_DIR ${TS_ROOT} |
| 46 | COMPONENTS |
| 47 | environments/sp |
| 48 | ) |
| 49 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 50 | include(../../env/commonsp/crypto_sp.cmake REQUIRED) |
| 51 | include(../../crypto.cmake REQUIRED) |
| 52 | include(../../infra/baremetal-psa.cmake REQUIRED) |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 53 | |
| 54 | #------------------------------------------------------------------------------- |
| 55 | # Set target platform to provide drivers needed by the deployment |
| 56 | # |
| 57 | #------------------------------------------------------------------------------- |
| 58 | add_platform(TARGET "crypto") |
| 59 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 60 | #------------------------------------------------------------------------------- |
| 61 | # Deployment specific build options |
| 62 | #------------------------------------------------------------------------------- |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 63 | target_compile_definitions(crypto PRIVATE |
| 64 | ARM64=1 |
| 65 | ) |
| 66 | |
| 67 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
| 68 | target_compile_options(crypto PRIVATE |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 69 | -std=c99 |
| 70 | ) |
| 71 | |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 72 | endif() |
| 73 | |
Jelle Sels | 4960c41 | 2023-02-01 09:43:24 +0100 | [diff] [blame] | 74 | compiler_generate_binary_output(TARGET crypto NAME "${SP_BIN_UUID_CANON}.bin" SP_BINARY) |
| 75 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SP_BIN_UUID_CANON}.bin DESTINATION ${TS_ENV}/bin) |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 76 | |
| 77 | include(${TS_ROOT}/tools/cmake/common/ExportMemoryRegionsToManifest.cmake REQUIRED) |
Jelle Sels | 4960c41 | 2023-02-01 09:43:24 +0100 | [diff] [blame] | 78 | export_memory_regions_to_manifest(TARGET crypto NAME "${SP_BIN_UUID_CANON}_memory_regions.dtsi" RES EXPORT_MEMORY_REGIONS_DTSI) |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 79 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 80 | #------------------------------------------------------------------------------- |
| 81 | # Deployment specific install options |
| 82 | #------------------------------------------------------------------------------- |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 83 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 84 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 85 | endif() |
| 86 | install(TARGETS crypto |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 87 | RUNTIME DESTINATION ${TS_ENV}/bin |
| 88 | ) |
| 89 | |
| 90 | include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake REQUIRED) |
| 91 | export_sp( |
Jelle Sels | 4960c41 | 2023-02-01 09:43:24 +0100 | [diff] [blame] | 92 | SP_FFA_UUID_CANON ${SP_FFA_UUID_CANON} |
| 93 | SP_BIN_UUID_CANON ${SP_BIN_UUID_CANON} |
Gabor Toth | 7e4babe | 2024-03-14 11:09:19 +0100 | [diff] [blame] | 94 | SP_BOOT_ORDER ${SP_BOOT_ORDER} |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 95 | SP_NAME ${SP_NAME} |
| 96 | DTS_IN ${CMAKE_CURRENT_LIST_DIR}/default_${SP_NAME}.dts.in |
Jelle Sels | 4960c41 | 2023-02-01 09:43:24 +0100 | [diff] [blame] | 97 | DTS_MEM_REGIONS ${SP_BIN_UUID_CANON}_memory_regions.dtsi |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 98 | JSON_IN ${TS_ROOT}/environments/sp/sp_pkg.json.in |
| 99 | ) |