blob: 7106a017eb638bbf476a42c3d57b3e38c4bf1e54 [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
Julian Halla7e76c82021-04-14 11:12:11 +010039 components/service/common/include
Balint Dobszay72c3f042020-11-23 18:23:57 +010040 components/service/common/provider
Julian Halla7e76c82021-04-14 11:12:11 +010041 components/service/secure_storage/include
julhal011260f102021-02-15 17:34:08 +000042 components/service/secure_storage/frontend/secure_storage_provider
julhal013a4207d2021-03-08 13:32:08 +000043 components/service/secure_storage/backend/secure_storage_client
44 components/service/secure_storage/backend/null_store
45 components/service/secure_storage/factory/sp/optee_trusted_store
Balint Dobszay72c3f042020-11-23 18:23:57 +010046 protocols/rpc/common/packed-c
47 protocols/service/secure_storage/packed-c
48 environments/opteesp
49)
50
julhal013a4207d2021-03-08 13:32:08 +000051target_sources(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010052 sp.c
53)
54
julhal013a4207d2021-03-08 13:32:08 +000055target_compile_definitions(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010056 ARM64=1
57)
58
julhal013a4207d2021-03-08 13:32:08 +000059target_include_directories(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010060 ${TS_ROOT}
61 ${TS_ROOT}/components
julhal013a4207d2021-03-08 13:32:08 +000062 ${TS_ROOT}/deployments/protected-storage/opteesp
Balint Dobszay72c3f042020-11-23 18:23:57 +010063)
64
65if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
julhal013a4207d2021-03-08 13:32:08 +000066 target_compile_options(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010067 -fdiagnostics-show-option
68 -fpic
69 -gdwarf-2
70 -mstrict-align
71 -O0
72 -std=gnu99
73 )
74
75 # Options for GCC that control linking
julhal013a4207d2021-03-08 13:32:08 +000076 target_link_options(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010077 -e __sp_entry
78 -fno-lto
79 -nostdlib
80 -pie
81 -zmax-page-size=4096
82 )
83 # Options directly for LD, these are not understood by GCC
julhal013a4207d2021-03-08 13:32:08 +000084 target_link_options(protected-storage PRIVATE
Balint Dobszay72c3f042020-11-23 18:23:57 +010085 -Wl,--as-needed
86 -Wl,--sort-section=alignment
87 # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list
88 )
89endif()
90
julhal013a4207d2021-03-08 13:32:08 +000091compiler_generate_stripped_elf(TARGET protected-storage NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF)
Balint Dobszay72c3f042020-11-23 18:23:57 +010092
93######################################## install
94if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
95 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
96endif()
julhal013a4207d2021-03-08 13:32:08 +000097install(TARGETS protected-storage
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010098 PUBLIC_HEADER DESTINATION ${TS_ENV}/include
99 RUNTIME DESTINATION ${TS_ENV}/bin
Balint Dobszay72c3f042020-11-23 18:23:57 +0100100 )
Gyorgy Szingc31afbf2021-02-12 01:51:55 +0100101install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin)
Balint Dobszay72c3f042020-11-23 18:23:57 +0100102
julhal013a4207d2021-03-08 13:32:08 +0000103set(EXPORT_SP_NAME "protected-storage")
Balint Dobszay72c3f042020-11-23 18:23:57 +0100104set(EXPORT_SP_UUID ${SP_UUID})
105include(${TS_ROOT}/environments/opteesp/ExportSp.cmake)