blob: 6394bfef09e95191f1821883361a4ca0b6e6e732 [file] [log] [blame]
Balint Dobszay72c3f042020-11-23 18:23:57 +01001#-------------------------------------------------------------------------------
2# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7cmake_minimum_required(VERSION 3.16)
8include(../../deployment.cmake REQUIRED)
9
10#-------------------------------------------------------------------------------
11# The CMakeLists.txt for building the secure-storage deployment for opteesp
12#
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)
18add_executable(secure-storage)
19target_include_directories(secure-storage PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
20set(SP_UUID "dc1eef48-b17a-4ccf-ac8b-dfcff7711b14")
21
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
28sp_dev_kit_configure_linking(TARGET secure-storage DEFINES ARM64=1)
29target_link_libraries(secure-storage ${SP_DEV_KIT_LIBRARIES})
30
31add_components(TARGET "secure-storage"
32 BASE_DIR ${TS_ROOT}
33 COMPONENTS
34 components/messaging/ffa/libsp
35 components/rpc/ffarpc/endpoint
36 components/rpc/common/interface
37 components/service/common/provider
38 components/service/secure_storage/provider/secure_flash_store
39 components/service/secure_storage/provider/secure_flash_store/flash_fs
40 components/service/secure_storage/provider/secure_flash_store/flash
41 protocols/rpc/common/packed-c
42 protocols/service/secure_storage/packed-c
43 environments/opteesp
44)
45
46target_sources(secure-storage PRIVATE
47 sp.c
48)
49
50target_compile_definitions(secure-storage PRIVATE
51 ARM64=1
52)
53
54target_include_directories(secure-storage PRIVATE
55 ${TS_ROOT}
56 ${TS_ROOT}/components
57 ${TS_ROOT}/deployments/secure-storage/opteesp
58)
59
60if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
61 target_compile_options(secure-storage PRIVATE
62 -fdiagnostics-show-option
63 -fpic
64 -gdwarf-2
65 -mstrict-align
66 -O0
67 -std=gnu99
68 )
69
70 # Options for GCC that control linking
71 target_link_options(secure-storage PRIVATE
72 -e __sp_entry
73 -fno-lto
74 -nostdlib
75 -pie
76 -zmax-page-size=4096
77 )
78 # Options directly for LD, these are not understood by GCC
79 target_link_options(secure-storage PRIVATE
80 -Wl,--as-needed
81 -Wl,--sort-section=alignment
82 # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list
83 )
84endif()
85
86compiler_generate_stripped_elf(TARGET secure-storage NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF)
87
88######################################## install
89if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
90 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
91endif()
92install(TARGETS secure-storage
93 PUBLIC_HEADER DESTINATION include
94 RUNTIME DESTINATION bin
95 )
96install(FILES ${STRIPPED_ELF} DESTINATION bin)
97
98set(EXPORT_SP_NAME "secure-storage")
99set(EXPORT_SP_UUID ${SP_UUID})
100include(${TS_ROOT}/environments/opteesp/ExportSp.cmake)