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 |
Julian Hall | a7e76c8 | 2021-04-14 11:12:11 +0100 | [diff] [blame] | 39 | components/service/common/include |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 40 | components/service/common/provider |
Julian Hall | a7e76c8 | 2021-04-14 11:12:11 +0100 | [diff] [blame] | 41 | components/service/secure_storage/include |
julhal01 | 1260f10 | 2021-02-15 17:34:08 +0000 | [diff] [blame] | 42 | components/service/secure_storage/frontend/secure_storage_provider |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 43 | 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 Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 46 | protocols/rpc/common/packed-c |
| 47 | protocols/service/secure_storage/packed-c |
| 48 | environments/opteesp |
| 49 | ) |
| 50 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 51 | target_sources(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 52 | sp.c |
| 53 | ) |
| 54 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 55 | target_compile_definitions(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 56 | ARM64=1 |
| 57 | ) |
| 58 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 59 | target_include_directories(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 60 | ${TS_ROOT} |
| 61 | ${TS_ROOT}/components |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 62 | ${TS_ROOT}/deployments/protected-storage/opteesp |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 63 | ) |
| 64 | |
| 65 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 66 | target_compile_options(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 67 | -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 |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 76 | target_link_options(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 77 | -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 |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 84 | target_link_options(protected-storage PRIVATE |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 85 | -Wl,--as-needed |
| 86 | -Wl,--sort-section=alignment |
| 87 | # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list |
| 88 | ) |
| 89 | endif() |
| 90 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 91 | 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] | 92 | |
| 93 | ######################################## install |
| 94 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 95 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 96 | endif() |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 97 | install(TARGETS protected-storage |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 98 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 99 | RUNTIME DESTINATION ${TS_ENV}/bin |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 100 | ) |
Gyorgy Szing | c31afbf | 2021-02-12 01:51:55 +0100 | [diff] [blame] | 101 | install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin) |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 102 | |
julhal01 | 3a4207d | 2021-03-08 13:32:08 +0000 | [diff] [blame] | 103 | set(EXPORT_SP_NAME "protected-storage") |
Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 104 | set(EXPORT_SP_UUID ${SP_UUID}) |
| 105 | include(${TS_ROOT}/environments/opteesp/ExportSp.cmake) |