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.") |
| 11 | include(../../deployment.cmake REQUIRED) |
| 12 | |
| 13 | #------------------------------------------------------------------------------- |
| 14 | # The CMakeLists.txt for building the crypto deployment for generic sp |
| 15 | # environment. |
| 16 | # |
| 17 | # Builds the Crypto service provider for running in an SEL0 secure partition |
| 18 | # hosted by any SPM. |
| 19 | #------------------------------------------------------------------------------- |
| 20 | include(${TS_ROOT}/environments/sp/env.cmake) |
| 21 | set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type") |
| 22 | project(trusted-services LANGUAGES C ASM) |
| 23 | add_executable(crypto) |
| 24 | target_include_directories(crypto PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 25 | set(SP_NAME "crypto") |
| 26 | set(SP_UUID "d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0") |
| 27 | set(TRACE_PREFIX "CRYPTO" CACHE STRING "Trace prefix") |
| 28 | set(SP_STACK_SIZE "64 * 1024" CACHE STRING "Stack size") |
| 29 | set(SP_HEAP_SIZE "490 * 1024" CACHE STRING "Heap size") |
| 30 | |
| 31 | #------------------------------------------------------------------------------- |
| 32 | # Components that are specific to deployment in the opteesp environment. |
| 33 | # |
| 34 | #------------------------------------------------------------------------------- |
| 35 | add_components(TARGET "crypto" |
| 36 | BASE_DIR ${TS_ROOT} |
| 37 | COMPONENTS |
| 38 | environments/sp |
| 39 | ) |
| 40 | |
| 41 | include(../crypto.cmake REQUIRED) |
| 42 | |
| 43 | #------------------------------------------------------------------------------- |
| 44 | # Set target platform to provide drivers needed by the deployment |
| 45 | # |
| 46 | #------------------------------------------------------------------------------- |
| 47 | add_platform(TARGET "crypto") |
| 48 | |
| 49 | ################################################################# |
| 50 | |
| 51 | target_compile_definitions(crypto PRIVATE |
| 52 | ARM64=1 |
| 53 | ) |
| 54 | |
| 55 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
| 56 | target_compile_options(crypto PRIVATE |
| 57 | -fdiagnostics-show-option |
| 58 | -gdwarf-2 |
| 59 | -mstrict-align |
| 60 | -std=c99 |
| 61 | ) |
| 62 | |
| 63 | # Options for GCC that control linking |
| 64 | target_link_options(crypto PRIVATE |
| 65 | -zmax-page-size=4096 |
| 66 | ) |
| 67 | # Options directly for LD, these are not understood by GCC |
| 68 | target_link_options(crypto PRIVATE |
| 69 | -Wl,--as-needed |
| 70 | -Wl,--sort-section=alignment |
| 71 | ) |
| 72 | endif() |
| 73 | |
| 74 | compiler_generate_binary_output(TARGET crypto NAME "${SP_UUID}.bin" SP_BINARY) |
| 75 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SP_UUID}.bin DESTINATION ${TS_ENV}/bin) |
| 76 | |
| 77 | include(${TS_ROOT}/tools/cmake/common/ExportMemoryRegionsToManifest.cmake REQUIRED) |
| 78 | export_memory_regions_to_manifest(TARGET crypto NAME "${SP_UUID}_memory_regions.dtsi" RES EXPORT_MEMORY_REGIONS_DTSI) |
| 79 | |
| 80 | ######################################## install |
| 81 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 82 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 83 | endif() |
| 84 | install(TARGETS crypto |
| 85 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 86 | RUNTIME DESTINATION ${TS_ENV}/bin |
| 87 | ) |
| 88 | |
| 89 | include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake REQUIRED) |
| 90 | export_sp( |
| 91 | SP_UUID ${SP_UUID} |
| 92 | SP_NAME ${SP_NAME} |
| 93 | DTS_IN ${CMAKE_CURRENT_LIST_DIR}/default_${SP_NAME}.dts.in |
| 94 | DTS_MEM_REGIONS ${SP_UUID}_memory_regions.dtsi |
| 95 | JSON_IN ${TS_ROOT}/environments/sp/sp_pkg.json.in |
| 96 | ) |