blob: 735366d8491deef04957062cb874321402964c28 [file] [log] [blame]
Imre Kis840ded22022-01-13 15:32:01 +01001#-------------------------------------------------------------------------------
2# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
Balint Dobszay047aea82022-05-16 14:20:53 +02007cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
Imre Kis840ded22022-01-13 15:32:01 +01008
9# Set default platform.
10set(TS_PLATFORM "arm/fvp/fvp_base_revc-2xaemv8a" CACHE STRING "Target platform location.")
11include(../../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#-------------------------------------------------------------------------------
20include(${TS_ROOT}/environments/sp/env.cmake)
21set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type")
22project(trusted-services LANGUAGES C ASM)
23add_executable(crypto)
24target_include_directories(crypto PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
25set(SP_NAME "crypto")
26set(SP_UUID "d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0")
27set(TRACE_PREFIX "CRYPTO" CACHE STRING "Trace prefix")
28set(SP_STACK_SIZE "64 * 1024" CACHE STRING "Stack size")
29set(SP_HEAP_SIZE "490 * 1024" CACHE STRING "Heap size")
30
31#-------------------------------------------------------------------------------
32# Components that are specific to deployment in the opteesp environment.
33#
34#-------------------------------------------------------------------------------
35add_components(TARGET "crypto"
36 BASE_DIR ${TS_ROOT}
37 COMPONENTS
38 environments/sp
39)
40
41include(../crypto.cmake REQUIRED)
42
43#-------------------------------------------------------------------------------
44# Set target platform to provide drivers needed by the deployment
45#
46#-------------------------------------------------------------------------------
47add_platform(TARGET "crypto")
48
49#################################################################
50
51target_compile_definitions(crypto PRIVATE
52 ARM64=1
53)
54
55if(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 )
72endif()
73
74compiler_generate_binary_output(TARGET crypto NAME "${SP_UUID}.bin" SP_BINARY)
75install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SP_UUID}.bin DESTINATION ${TS_ENV}/bin)
76
77include(${TS_ROOT}/tools/cmake/common/ExportMemoryRegionsToManifest.cmake REQUIRED)
78export_memory_regions_to_manifest(TARGET crypto NAME "${SP_UUID}_memory_regions.dtsi" RES EXPORT_MEMORY_REGIONS_DTSI)
79
80######################################## install
81if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
82 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
83endif()
84install(TARGETS crypto
85 PUBLIC_HEADER DESTINATION ${TS_ENV}/include
86 RUNTIME DESTINATION ${TS_ENV}/bin
87 )
88
89include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake REQUIRED)
90export_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)