Balint Dobszay | 72c3f04 | 2020-11-23 18:23:57 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | cmake_minimum_required(VERSION 3.16) |
| 8 | include(../../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 | #------------------------------------------------------------------------------- |
| 16 | include(${TS_ROOT}/environments/opteesp/env.cmake) |
| 17 | project(trusted-services LANGUAGES C ASM) |
| 18 | add_executable(secure-storage) |
| 19 | target_include_directories(secure-storage PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 20 | set(SP_UUID "dc1eef48-b17a-4ccf-ac8b-dfcff7711b14") |
| 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 | |
| 28 | sp_dev_kit_configure_linking(TARGET secure-storage DEFINES ARM64=1) |
| 29 | target_link_libraries(secure-storage ${SP_DEV_KIT_LIBRARIES}) |
| 30 | |
| 31 | add_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 | |
| 46 | target_sources(secure-storage PRIVATE |
| 47 | sp.c |
| 48 | ) |
| 49 | |
| 50 | target_compile_definitions(secure-storage PRIVATE |
| 51 | ARM64=1 |
| 52 | ) |
| 53 | |
| 54 | target_include_directories(secure-storage PRIVATE |
| 55 | ${TS_ROOT} |
| 56 | ${TS_ROOT}/components |
| 57 | ${TS_ROOT}/deployments/secure-storage/opteesp |
| 58 | ) |
| 59 | |
| 60 | if(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 | ) |
| 84 | endif() |
| 85 | |
| 86 | compiler_generate_stripped_elf(TARGET secure-storage NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF) |
| 87 | |
| 88 | ######################################## install |
| 89 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 90 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 91 | endif() |
| 92 | install(TARGETS secure-storage |
| 93 | PUBLIC_HEADER DESTINATION include |
| 94 | RUNTIME DESTINATION bin |
| 95 | ) |
| 96 | install(FILES ${STRIPPED_ELF} DESTINATION bin) |
| 97 | |
| 98 | set(EXPORT_SP_NAME "secure-storage") |
| 99 | set(EXPORT_SP_UUID ${SP_UUID}) |
| 100 | include(${TS_ROOT}/environments/opteesp/ExportSp.cmake) |