blob: 964fd60d23314086307edfe4ab9ef787889ae168 [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.")
Gyorgy Szing34aaf212022-10-20 07:26:23 +020011
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.
14if (NOT DEFINED CMAKE_BUILD_TYPE)
15 set(CMAKE_BUILD_TYPE "MinSizWithDebInfo" CACHE STRING "Build type.")
16endif()
17
Julian Hall64f1d872022-09-05 16:52:40 +010018include(../../../deployment.cmake REQUIRED)
Imre Kis840ded22022-01-13 15:32:01 +010019
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#-------------------------------------------------------------------------------
27include(${TS_ROOT}/environments/sp/env.cmake)
28set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type")
29project(trusted-services LANGUAGES C ASM)
30add_executable(crypto)
31target_include_directories(crypto PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
32set(SP_NAME "crypto")
Balint Dobszayc9daea92022-06-15 15:17:11 +020033set(SP_UUID_CANON "d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0")
34set(SP_UUID_LE "0xd552dfd9 0xb24ba216 0x6dd2a49a 0xc0e8843b")
Imre Kis840ded22022-01-13 15:32:01 +010035set(TRACE_PREFIX "CRYPTO" CACHE STRING "Trace prefix")
36set(SP_STACK_SIZE "64 * 1024" CACHE STRING "Stack size")
37set(SP_HEAP_SIZE "490 * 1024" CACHE STRING "Heap size")
38
39#-------------------------------------------------------------------------------
40# Components that are specific to deployment in the opteesp environment.
41#
42#-------------------------------------------------------------------------------
43add_components(TARGET "crypto"
44 BASE_DIR ${TS_ROOT}
45 COMPONENTS
46 environments/sp
47)
48
Julian Hall64f1d872022-09-05 16:52:40 +010049include(../../env/commonsp/crypto_sp.cmake REQUIRED)
50include(../../crypto.cmake REQUIRED)
51include(../../infra/baremetal-psa.cmake REQUIRED)
Imre Kis840ded22022-01-13 15:32:01 +010052
53#-------------------------------------------------------------------------------
54# Set target platform to provide drivers needed by the deployment
55#
56#-------------------------------------------------------------------------------
57add_platform(TARGET "crypto")
58
Julian Hall64f1d872022-09-05 16:52:40 +010059#-------------------------------------------------------------------------------
60# Deployment specific build options
61#-------------------------------------------------------------------------------
Imre Kis840ded22022-01-13 15:32:01 +010062target_compile_definitions(crypto PRIVATE
63 ARM64=1
64)
65
66if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
67 target_compile_options(crypto PRIVATE
Imre Kis840ded22022-01-13 15:32:01 +010068 -std=c99
69 )
70
Imre Kis840ded22022-01-13 15:32:01 +010071endif()
72
Balint Dobszayc9daea92022-06-15 15:17:11 +020073compiler_generate_binary_output(TARGET crypto NAME "${SP_UUID_CANON}.bin" SP_BINARY)
74install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SP_UUID_CANON}.bin DESTINATION ${TS_ENV}/bin)
Imre Kis840ded22022-01-13 15:32:01 +010075
76include(${TS_ROOT}/tools/cmake/common/ExportMemoryRegionsToManifest.cmake REQUIRED)
Balint Dobszayc9daea92022-06-15 15:17:11 +020077export_memory_regions_to_manifest(TARGET crypto NAME "${SP_UUID_CANON}_memory_regions.dtsi" RES EXPORT_MEMORY_REGIONS_DTSI)
Imre Kis840ded22022-01-13 15:32:01 +010078
Julian Hall64f1d872022-09-05 16:52:40 +010079#-------------------------------------------------------------------------------
80# Deployment specific install options
81#-------------------------------------------------------------------------------
Imre Kis840ded22022-01-13 15:32:01 +010082if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
83 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
84endif()
85install(TARGETS crypto
86 PUBLIC_HEADER DESTINATION ${TS_ENV}/include
87 RUNTIME DESTINATION ${TS_ENV}/bin
88 )
89
90include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake REQUIRED)
91export_sp(
Balint Dobszayc9daea92022-06-15 15:17:11 +020092 SP_UUID_CANON ${SP_UUID_CANON}
93 SP_UUID_LE ${SP_UUID_LE}
Imre Kis840ded22022-01-13 15:32:01 +010094 SP_NAME ${SP_NAME}
95 DTS_IN ${CMAKE_CURRENT_LIST_DIR}/default_${SP_NAME}.dts.in
Balint Dobszayc9daea92022-06-15 15:17:11 +020096 DTS_MEM_REGIONS ${SP_UUID_CANON}_memory_regions.dtsi
Imre Kis840ded22022-01-13 15:32:01 +010097 JSON_IN ${TS_ROOT}/environments/sp/sp_pkg.json.in
98)