blob: c4f0fd5a67a1ed4c898ffbbd60edb3c12e3f0d5a [file] [log] [blame]
Balint Dobszay72c3f042020-11-23 18:23:57 +01001#-------------------------------------------------------------------------------
Gyorgy Szingc31afbf2021-02-12 01:51:55 +01002# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
Balint Dobszay72c3f042020-11-23 18:23:57 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7cmake_minimum_required(VERSION 3.16)
8include(../../deployment.cmake REQUIRED)
9
10#-------------------------------------------------------------------------------
julhal013a4207d2021-03-08 13:32:08 +000011# The CMakeLists.txt for building the protected-storage deployment for opteesp
Balint Dobszay72c3f042020-11-23 18:23:57 +010012#
13# Builds the secure storage service provider for running in an SEL0 secure
14# partition hosted by OPTEE in the role of SPM.
15#-------------------------------------------------------------------------------
16include(${TS_ROOT}/environments/opteesp/env.cmake)
17project(trusted-services LANGUAGES C ASM)
julhal013a4207d2021-03-08 13:32:08 +000018add_executable(protected-storage)
19target_include_directories(protected-storage PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
20set(SP_UUID "751bf801-3dde-4768-a514-0f10aeed1790")
Balint Dobszay72c3f042020-11-23 18:23:57 +010021
22
23# Include SP DEV KIT interface
24set(SP_DEV_KIT_INC_DIR ${CMAKE_CURRENT_LIST_DIR})
25list(APPEND CMAKE_MODULE_PATH "${TS_ROOT}/external/Spdevkit")
26find_package(Spdevkit COMPONENTS SP_HEADER interface)
27
julhal013a4207d2021-03-08 13:32:08 +000028sp_dev_kit_configure_linking(TARGET protected-storage DEFINES ARM64=1)
29target_link_libraries(protected-storage ${SP_DEV_KIT_LIBRARIES})
Balint Dobszay72c3f042020-11-23 18:23:57 +010030
julhal013a4207d2021-03-08 13:32:08 +000031add_components(TARGET "protected-storage"
Balint Dobszay72c3f042020-11-23 18:23:57 +010032 BASE_DIR ${TS_ROOT}
33 COMPONENTS
34 components/messaging/ffa/libsp
35 components/rpc/ffarpc/endpoint
36 components/rpc/common/interface
julhal013a4207d2021-03-08 13:32:08 +000037 components/rpc/ffarpc/caller/sp
38 components/rpc/common/caller
julhal011260f102021-02-15 17:34:08 +000039 components/service/common
Balint Dobszay72c3f042020-11-23 18:23:57 +010040 components/service/common/provider
julhal011260f102021-02-15 17:34:08 +000041 components/service/secure_storage/frontend/secure_storage_provider
julhal013a4207d2021-03-08 13:32:08 +000042 components/service/secure_storage/backend/secure_storage_client
43 components/service/secure_storage/backend/null_store
44 components/service/secure_storage/factory/sp/optee_trusted_store
Balint Dobszay72c3f042020-11-23 18:23:57 +010045 protocols/rpc/common/packed-c
46 protocols/service/secure_storage/packed-c
47 environments/opteesp
48)
49
julhal013a4207d2021-03-08 13:32:08 +000050target_sources(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010051 sp.c
52)
53
julhal013a4207d2021-03-08 13:32:08 +000054target_compile_definitions(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010055 ARM64=1
56)
57
julhal013a4207d2021-03-08 13:32:08 +000058target_include_directories(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010059 ${TS_ROOT}
60 ${TS_ROOT}/components
julhal013a4207d2021-03-08 13:32:08 +000061 ${TS_ROOT}/deployments/protected-storage/opteesp
Balint Dobszay72c3f042020-11-23 18:23:57 +010062)
63
64if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
julhal013a4207d2021-03-08 13:32:08 +000065 target_compile_options(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010066 -fdiagnostics-show-option
67 -fpic
68 -gdwarf-2
69 -mstrict-align
70 -O0
71 -std=gnu99
72 )
73
74 # Options for GCC that control linking
julhal013a4207d2021-03-08 13:32:08 +000075 target_link_options(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010076 -e __sp_entry
77 -fno-lto
78 -nostdlib
79 -pie
80 -zmax-page-size=4096
81 )
82 # Options directly for LD, these are not understood by GCC
julhal013a4207d2021-03-08 13:32:08 +000083 target_link_options(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010084 -Wl,--as-needed
85 -Wl,--sort-section=alignment
86 # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list
87 )
88endif()
89
julhal013a4207d2021-03-08 13:32:08 +000090compiler_generate_stripped_elf(TARGET protected-storage NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF)
Balint Dobszay72c3f042020-11-23 18:23:57 +010091
92######################################## install
93if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
94 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
95endif()
julhal013a4207d2021-03-08 13:32:08 +000096install(TARGETS protected-storage
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010097 PUBLIC_HEADER DESTINATION ${TS_ENV}/include
98 RUNTIME DESTINATION ${TS_ENV}/bin
Balint Dobszay72c3f042020-11-23 18:23:57 +010099 )
Gyorgy Szingc31afbf2021-02-12 01:51:55 +0100100install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin)
Balint Dobszay72c3f042020-11-23 18:23:57 +0100101
julhal013a4207d2021-03-08 13:32:08 +0000102set(EXPORT_SP_NAME "protected-storage")
Balint Dobszay72c3f042020-11-23 18:23:57 +0100103set(EXPORT_SP_UUID ${SP_UUID})
104include(${TS_ROOT}/environments/opteesp/ExportSp.cmake)