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") |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 33 | set(SP_UUID_CANON "d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0") |
| 34 | set(SP_UUID_LE "0xd552dfd9 0xb24ba216 0x6dd2a49a 0xc0e8843b") |
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") |
| 38 | |
| 39 | #------------------------------------------------------------------------------- |
| 40 | # Components that are specific to deployment in the opteesp environment. |
| 41 | # |
| 42 | #------------------------------------------------------------------------------- |
| 43 | add_components(TARGET "crypto" |
| 44 | BASE_DIR ${TS_ROOT} |
| 45 | COMPONENTS |
| 46 | environments/sp |
| 47 | ) |
| 48 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 49 | include(../../env/commonsp/crypto_sp.cmake REQUIRED) |
| 50 | include(../../crypto.cmake REQUIRED) |
| 51 | include(../../infra/baremetal-psa.cmake REQUIRED) |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 52 | |
| 53 | #------------------------------------------------------------------------------- |
| 54 | # Set target platform to provide drivers needed by the deployment |
| 55 | # |
| 56 | #------------------------------------------------------------------------------- |
| 57 | add_platform(TARGET "crypto") |
| 58 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 59 | #------------------------------------------------------------------------------- |
| 60 | # Deployment specific build options |
| 61 | #------------------------------------------------------------------------------- |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 62 | target_compile_definitions(crypto PRIVATE |
| 63 | ARM64=1 |
| 64 | ) |
| 65 | |
| 66 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
| 67 | target_compile_options(crypto PRIVATE |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 68 | -std=c99 |
| 69 | ) |
| 70 | |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 71 | endif() |
| 72 | |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 73 | compiler_generate_binary_output(TARGET crypto NAME "${SP_UUID_CANON}.bin" SP_BINARY) |
| 74 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SP_UUID_CANON}.bin DESTINATION ${TS_ENV}/bin) |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 75 | |
| 76 | include(${TS_ROOT}/tools/cmake/common/ExportMemoryRegionsToManifest.cmake REQUIRED) |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 77 | export_memory_regions_to_manifest(TARGET crypto NAME "${SP_UUID_CANON}_memory_regions.dtsi" RES EXPORT_MEMORY_REGIONS_DTSI) |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 78 | |
Julian Hall | 64f1d87 | 2022-09-05 16:52:40 +0100 | [diff] [blame] | 79 | #------------------------------------------------------------------------------- |
| 80 | # Deployment specific install options |
| 81 | #------------------------------------------------------------------------------- |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 82 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 83 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 84 | endif() |
| 85 | install(TARGETS crypto |
| 86 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 87 | RUNTIME DESTINATION ${TS_ENV}/bin |
| 88 | ) |
| 89 | |
| 90 | include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake REQUIRED) |
| 91 | export_sp( |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 92 | SP_UUID_CANON ${SP_UUID_CANON} |
| 93 | SP_UUID_LE ${SP_UUID_LE} |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 94 | SP_NAME ${SP_NAME} |
| 95 | DTS_IN ${CMAKE_CURRENT_LIST_DIR}/default_${SP_NAME}.dts.in |
Balint Dobszay | c9daea9 | 2022-06-15 15:17:11 +0200 | [diff] [blame] | 96 | DTS_MEM_REGIONS ${SP_UUID_CANON}_memory_regions.dtsi |
Imre Kis | 840ded2 | 2022-01-13 15:32:01 +0100 | [diff] [blame] | 97 | JSON_IN ${TS_ROOT}/environments/sp/sp_pkg.json.in |
| 98 | ) |