Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 2 | # Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved. |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | cmake_minimum_required(VERSION 3.16) |
| 8 | include(../../deployment.cmake REQUIRED) |
| 9 | |
| 10 | #------------------------------------------------------------------------------- |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 11 | # The CMakeLists.txt for building the protected-storage deployment for opteesp |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 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 | #------------------------------------------------------------------------------- |
| 16 | include(${TS_ROOT}/environments/opteesp/env.cmake) |
| 17 | project(trusted-services LANGUAGES C ASM) |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 18 | add_executable(protected-storage) |
| 19 | target_include_directories(protected-storage PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 20 | set(SP_UUID "751bf801-3dde-4768-a514-0f10aeed1790") |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 21 | |
| 22 | |
| 23 | # Include SP DEV KIT interface |
| 24 | set(SP_DEV_KIT_INC_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 25 | list(APPEND CMAKE_MODULE_PATH "${TS_ROOT}/external/Spdevkit") |
| 26 | find_package(Spdevkit COMPONENTS SP_HEADER interface) |
| 27 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 28 | sp_dev_kit_configure_linking(TARGET protected-storage DEFINES ARM64=1) |
| 29 | target_link_libraries(protected-storage ${SP_DEV_KIT_LIBRARIES}) |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 30 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 31 | add_components(TARGET "protected-storage" |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 32 | BASE_DIR ${TS_ROOT} |
| 33 | COMPONENTS |
| 34 | components/messaging/ffa/libsp |
| 35 | components/rpc/ffarpc/endpoint |
| 36 | components/rpc/common/interface |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 37 | components/rpc/ffarpc/caller/sp |
| 38 | components/rpc/common/caller |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame] | 39 | components/service/common |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 40 | components/service/common/provider |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame] | 41 | components/service/secure_storage/frontend/secure_storage_provider |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 42 | 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 Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 45 | protocols/rpc/common/packed-c |
| 46 | protocols/service/secure_storage/packed-c |
| 47 | environments/opteesp |
| 48 | ) |
| 49 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 50 | target_sources(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 51 | sp.c |
| 52 | ) |
| 53 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 54 | target_compile_definitions(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 55 | ARM64=1 |
| 56 | ) |
| 57 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 58 | target_include_directories(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 59 | ${TS_ROOT} |
| 60 | ${TS_ROOT}/components |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 61 | ${TS_ROOT}/deployments/protected-storage/opteesp |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 62 | ) |
| 63 | |
| 64 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 65 | target_compile_options(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 66 | -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 |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 75 | target_link_options(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 76 | -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 |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 83 | target_link_options(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 84 | -Wl,--as-needed |
| 85 | -Wl,--sort-section=alignment |
| 86 | # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list |
| 87 | ) |
| 88 | endif() |
| 89 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 90 | compiler_generate_stripped_elf(TARGET protected-storage NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF) |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 91 | |
| 92 | ######################################## install |
| 93 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 94 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 95 | endif() |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 96 | install(TARGETS protected-storage |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 97 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 98 | RUNTIME DESTINATION ${TS_ENV}/bin |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 99 | ) |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 100 | install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin) |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 101 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 102 | set(EXPORT_SP_NAME "protected-storage") |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 103 | set(EXPORT_SP_UUID ${SP_UUID}) |
| 104 | include(${TS_ROOT}/environments/opteesp/ExportSp.cmake) |