blob: 1e4069d6678ff01b32eb22d7c4557980f8bea218 [file] [log] [blame]
Julian Hall4061ed62020-11-23 18:24:06 +01001#-------------------------------------------------------------------------------
Gyorgy Szing8a1e7f42023-07-26 18:26:48 +02002# Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.
Julian Hall4061ed62020-11-23 18:24:06 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
Balint Dobszay047aea82022-05-16 14:20:53 +02007cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
Gyorgy Szinga365a042021-12-02 01:48:27 +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)
Julian Hall4061ed62020-11-23 18:24:06 +010019
20#-------------------------------------------------------------------------------
21# The CMakeLists.txt for building the crypto deployment for opteesp
22#
23# Builds the Crypto service provider for running in an SEL0 secure partition
24# hosted by OPTEE in the role of SPM.
25#-------------------------------------------------------------------------------
26include(${TS_ROOT}/environments/opteesp/env.cmake)
27project(trusted-services LANGUAGES C ASM)
Imre Kisd0ed5c22021-12-15 17:05:47 +010028add_executable(crypto)
29target_include_directories(crypto PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
Jelle Sels4960c412023-02-01 09:43:24 +010030set(SP_BIN_UUID_CANON "d9df52d5-16a2-4bb2-9aa4-d26d3b84e8c0")
31set(SP_FFA_UUID_CANON "${TS_RPC_UUID_CANON}")
Imre Kiseeee9642021-12-17 13:59:46 +010032set(SP_HEAP_SIZE "490 * 1024" CACHE STRING "SP heap size in bytes")
Imre Kis2ccd8e82021-10-08 11:21:14 +020033set(TRACE_PREFIX "CRYPTO" CACHE STRING "Trace prefix")
Julian Hall4061ed62020-11-23 18:24:06 +010034
Julian Hall64f1d872022-09-05 16:52:40 +010035target_include_directories(crypto PRIVATE
36 ${CMAKE_CURRENT_LIST_DIR}
37)
38
julhal01ffa98d82021-01-20 13:51:58 +000039#-------------------------------------------------------------------------------
Julian Hall64f1d872022-09-05 16:52:40 +010040# Deployment specific components
julhal01ffa98d82021-01-20 13:51:58 +000041#
42#-------------------------------------------------------------------------------
Jelle Sels4960c412023-02-01 09:43:24 +010043
Imre Kisd0ed5c22021-12-15 17:05:47 +010044add_components(TARGET "crypto"
Julian Hall4061ed62020-11-23 18:24:06 +010045 BASE_DIR ${TS_ROOT}
46 COMPONENTS
Julian Hall4061ed62020-11-23 18:24:06 +010047 "environments/opteesp"
48)
49
Julian Hall64f1d872022-09-05 16:52:40 +010050include(../../env/commonsp/crypto_sp.cmake REQUIRED)
51include(../../crypto.cmake REQUIRED)
52include(../../infra/baremetal-psa.cmake REQUIRED)
Julian Hall4061ed62020-11-23 18:24:06 +010053
julhal01ffa98d82021-01-20 13:51:58 +000054#-------------------------------------------------------------------------------
Gyorgy Szinga365a042021-12-02 01:48:27 +010055# Set target platform to provide drivers needed by the deployment
julhal01ffa98d82021-01-20 13:51:58 +000056#
57#-------------------------------------------------------------------------------
Imre Kisd0ed5c22021-12-15 17:05:47 +010058add_platform(TARGET "crypto")
Julian Hall4061ed62020-11-23 18:24:06 +010059
Julian Hall64f1d872022-09-05 16:52:40 +010060#-------------------------------------------------------------------------------
61# Deployment specific build options
62#-------------------------------------------------------------------------------
Imre Kisd0ed5c22021-12-15 17:05:47 +010063target_compile_definitions(crypto PRIVATE
Julian Hall4061ed62020-11-23 18:24:06 +010064 ARM64=1
65)
66
Julian Hall4061ed62020-11-23 18:24:06 +010067if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
Imre Kisd0ed5c22021-12-15 17:05:47 +010068 target_compile_options(crypto PRIVATE
Andrew Beggs97a00d42021-06-15 15:45:46 +000069 -std=c99
Julian Hall4061ed62020-11-23 18:24:06 +010070 )
71
Julian Hall4061ed62020-11-23 18:24:06 +010072endif()
73
Julian Hall64f1d872022-09-05 16:52:40 +010074#-------------------------------------------------------------------------------
75# Deployment specific install options
76#-------------------------------------------------------------------------------
Julian Hall4061ed62020-11-23 18:24:06 +010077if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
78 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
79endif()
80#TODO: api headers
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010081
Imre Kisd0ed5c22021-12-15 17:05:47 +010082install(TARGETS crypto
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010083 PUBLIC_HEADER DESTINATION ${TS_ENV}/include
84 RUNTIME DESTINATION ${TS_ENV}/bin
Julian Hall4061ed62020-11-23 18:24:06 +010085 )
Julian Hall4061ed62020-11-23 18:24:06 +010086
Imre Kisd0ed5c22021-12-15 17:05:47 +010087get_property(_PROTO_FILES TARGET crypto PROPERTY PROTOBUF_FILES)
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010088install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf)
Julian Hall4061ed62020-11-23 18:24:06 +010089
Imre Kisa74aaf92021-12-14 17:13:06 +010090include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake)
91export_sp(
Jelle Sels4960c412023-02-01 09:43:24 +010092 SP_FFA_UUID_CANON ${SP_FFA_UUID_CANON}
93 SP_BIN_UUID_CANON ${SP_BIN_UUID_CANON}
Imre Kisa74aaf92021-12-14 17:13:06 +010094 SP_NAME "crypto"
95 MK_IN ${TS_ROOT}/environments/opteesp/sp.mk.in
96 DTS_IN ${CMAKE_CURRENT_LIST_DIR}/default_crypto.dts.in
97 JSON_IN ${TS_ROOT}/environments/opteesp/sp_pkg.json.in
98)