Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | cmake_minimum_required(VERSION 3.16) |
Gyorgy Szing | a365a04 | 2021-12-02 01:48:27 +0100 | [diff] [blame^] | 8 | |
| 9 | # Set default platform. |
| 10 | set(TS_PLATFORM "arm/fvp/fvp_base_revc-2xaemv8a" CACHE STRING "Target platform location.") |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 11 | include(../../deployment.cmake REQUIRED) |
| 12 | |
| 13 | #------------------------------------------------------------------------------- |
| 14 | # The CMakeLists.txt for building the se-proxy deployment for opteesp |
| 15 | # |
| 16 | # Builds proxy service providers that communicate with a separate secure element |
| 17 | # that hosts a set of service endpoints. This deployment is for running in an |
| 18 | # SEL0 secure partition hosted by OPTEE in the role of SPM. |
| 19 | #------------------------------------------------------------------------------- |
| 20 | include(${TS_ROOT}/environments/opteesp/env.cmake) |
| 21 | project(trusted-services LANGUAGES C ASM) |
| 22 | add_executable(se-proxy) |
| 23 | target_include_directories(se-proxy PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 24 | set(SP_UUID "46bb39d1-b4d9-45b5-88ff-040027dab249") |
| 25 | |
| 26 | #------------------------------------------------------------------------------- |
| 27 | # Include SP DEV KIT interface |
| 28 | # |
| 29 | #------------------------------------------------------------------------------- |
| 30 | set(SP_DEV_KIT_INC_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 31 | list(APPEND CMAKE_MODULE_PATH "${TS_ROOT}/external/Spdevkit") |
| 32 | find_package(Spdevkit REQUIRED) |
| 33 | sp_dev_kit_configure_linking(TARGET se-proxy DEFINES ARM64=1) |
| 34 | target_link_libraries(se-proxy PRIVATE ${SP_DEV_KIT_LIBRARIES}) |
| 35 | |
| 36 | #------------------------------------------------------------------------------- |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 37 | # Components that are specific to deployment in the opteesp environment. |
| 38 | # |
| 39 | #------------------------------------------------------------------------------- |
| 40 | add_components(TARGET "se-proxy" |
| 41 | BASE_DIR ${TS_ROOT} |
| 42 | COMPONENTS |
| 43 | "protocols/rpc/common/packed-c" |
| 44 | "protocols/service/secure_storage/packed-c" |
| 45 | "protocols/service/crypto/protobuf" |
| 46 | "environments/opteesp" |
| 47 | "components/common/tlv" |
| 48 | "components/config/ramstore" |
| 49 | "components/config/loader/sp" |
| 50 | "components/messaging/ffa/libsp" |
| 51 | "components/rpc/ffarpc/endpoint" |
| 52 | "components/rpc/common/interface" |
| 53 | "components/rpc/common/demux" |
| 54 | "components/service/common/include" |
| 55 | "components/service/common/serializer/protobuf" |
Julian Hall | 628be29 | 2021-08-04 16:57:40 +0100 | [diff] [blame] | 56 | "components/service/common/client" |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 57 | "components/service/common/provider" |
Julian Hall | 3e61454 | 2021-07-29 11:47:47 +0100 | [diff] [blame] | 58 | "components/service/discovery/provider" |
| 59 | "components/service/discovery/provider/serializer/packed-c" |
Julian Hall | 628be29 | 2021-08-04 16:57:40 +0100 | [diff] [blame] | 60 | "components/service/crypto/include" |
Julian Hall | 9061e6c | 2021-06-29 14:24:20 +0100 | [diff] [blame] | 61 | "components/service/crypto/provider" |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 62 | "components/service/crypto/provider/serializer/protobuf" |
| 63 | "components/service/crypto/provider/serializer/packed-c" |
Julian Hall | 7bfb18e | 2021-07-13 15:48:13 +0100 | [diff] [blame] | 64 | "components/service/crypto/provider/extension/hash" |
| 65 | "components/service/crypto/provider/extension/hash/serializer/packed-c" |
Julian Hall | e7bccbe | 2021-07-16 09:50:34 +0100 | [diff] [blame] | 66 | "components/service/crypto/provider/extension/cipher" |
| 67 | "components/service/crypto/provider/extension/cipher/serializer/packed-c" |
Julian Hall | fe487b7 | 2021-07-19 10:29:59 +0100 | [diff] [blame] | 68 | "components/service/crypto/provider/extension/key_derivation" |
| 69 | "components/service/crypto/provider/extension/key_derivation/serializer/packed-c" |
Julian Hall | a6d3cbc | 2021-07-20 10:13:21 +0100 | [diff] [blame] | 70 | "components/service/crypto/provider/extension/mac" |
| 71 | "components/service/crypto/provider/extension/mac/serializer/packed-c" |
Julian Hall | 7bfb18e | 2021-07-13 15:48:13 +0100 | [diff] [blame] | 72 | "components/service/crypto/factory/full" |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 73 | "components/service/secure_storage/include" |
| 74 | "components/service/secure_storage/frontend/secure_storage_provider" |
| 75 | "components/service/attestation/include" |
| 76 | "components/service/attestation/provider" |
| 77 | "components/service/attestation/provider/serializer/packed-c" |
| 78 | |
Julian Hall | 628be29 | 2021-08-04 16:57:40 +0100 | [diff] [blame] | 79 | # Stub service provider backends |
| 80 | "components/rpc/dummy" |
| 81 | "components/rpc/common/caller" |
| 82 | "components/service/attestation/reporter/stub" |
| 83 | "components/service/attestation/key_mngr/stub" |
| 84 | "components/service/crypto/backend/stub" |
| 85 | "components/service/crypto/client/psa" |
| 86 | "components/service/secure_storage/backend/mock_store" |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 87 | ) |
| 88 | |
| 89 | target_sources(se-proxy PRIVATE |
| 90 | se_proxy_sp.c |
| 91 | service_proxy_factory.c |
| 92 | ) |
| 93 | |
| 94 | #------------------------------------------------------------------------------- |
Gyorgy Szing | a365a04 | 2021-12-02 01:48:27 +0100 | [diff] [blame^] | 95 | # Set target platform to provide drivers needed by the deployment |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 96 | # |
| 97 | #------------------------------------------------------------------------------- |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 98 | add_platform(TARGET "se-proxy") |
| 99 | |
| 100 | #------------------------------------------------------------------------------- |
| 101 | # Components used from external projects |
| 102 | # |
| 103 | #------------------------------------------------------------------------------- |
| 104 | |
| 105 | # Nanopb |
| 106 | list(APPEND NANOPB_EXTERNAL_INCLUDE_PATHS ${SP_DEV_KIT_INCLUDE_DIR}) |
| 107 | include(../../../external/nanopb/nanopb.cmake) |
| 108 | target_link_libraries(se-proxy PRIVATE nanopb::protobuf-nanopb-static) |
| 109 | protobuf_generate_all(TGT "se-proxy" NAMESPACE "protobuf" BASE_DIR "${TS_ROOT}/protocols") |
| 110 | |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 111 | ################################################################# |
| 112 | |
| 113 | target_compile_definitions(se-proxy PRIVATE |
| 114 | ARM64=1 |
| 115 | ) |
| 116 | |
| 117 | target_include_directories(se-proxy PRIVATE |
| 118 | ${TS_ROOT} |
| 119 | ${TS_ROOT}/components |
| 120 | ${TS_ROOT}/deployments/se-proxy/opteesp |
| 121 | ) |
| 122 | |
| 123 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
| 124 | target_compile_options(se-proxy PRIVATE |
| 125 | -fdiagnostics-show-option |
| 126 | -gdwarf-2 |
| 127 | -mstrict-align |
| 128 | -O0 |
| 129 | -std=c99 |
| 130 | ) |
| 131 | |
| 132 | # Options for GCC that control linking |
| 133 | target_link_options(se-proxy PRIVATE |
| 134 | -zmax-page-size=4096 |
| 135 | ) |
| 136 | # Options directly for LD, these are not understood by GCC |
| 137 | target_link_options(se-proxy PRIVATE |
| 138 | -Wl,--as-needed |
| 139 | -Wl,--sort-section=alignment |
| 140 | # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list |
| 141 | ) |
| 142 | endif() |
| 143 | |
| 144 | compiler_generate_stripped_elf(TARGET se-proxy NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF) |
| 145 | |
| 146 | ######################################## install |
| 147 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 148 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 149 | endif() |
| 150 | #TODO: api headers |
| 151 | |
| 152 | install(TARGETS se-proxy |
| 153 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 154 | RUNTIME DESTINATION ${TS_ENV}/bin |
| 155 | ) |
| 156 | install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin) |
| 157 | |
| 158 | get_property(_PROTO_FILES TARGET se-proxy PROPERTY PROTOBUF_FILES) |
| 159 | install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf) |
| 160 | |
| 161 | |
| 162 | set(EXPORT_SP_NAME "se-proxy") |
| 163 | set(EXPORT_SP_UUID ${SP_UUID}) |
| 164 | include(${TS_ROOT}/environments/opteesp/ExportSp.cmake) |