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) |
| 8 | include(../../deployment.cmake REQUIRED) |
| 9 | |
| 10 | #------------------------------------------------------------------------------- |
| 11 | # The CMakeLists.txt for building the se-proxy deployment for opteesp |
| 12 | # |
| 13 | # Builds proxy service providers that communicate with a separate secure element |
| 14 | # that hosts a set of service endpoints. This deployment is for running in an |
| 15 | # SEL0 secure partition hosted by OPTEE in the role of SPM. |
| 16 | #------------------------------------------------------------------------------- |
| 17 | include(${TS_ROOT}/environments/opteesp/env.cmake) |
| 18 | project(trusted-services LANGUAGES C ASM) |
| 19 | add_executable(se-proxy) |
| 20 | target_include_directories(se-proxy PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 21 | set(SP_UUID "46bb39d1-b4d9-45b5-88ff-040027dab249") |
| 22 | |
| 23 | #------------------------------------------------------------------------------- |
| 24 | # Include SP DEV KIT interface |
| 25 | # |
| 26 | #------------------------------------------------------------------------------- |
| 27 | set(SP_DEV_KIT_INC_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 28 | list(APPEND CMAKE_MODULE_PATH "${TS_ROOT}/external/Spdevkit") |
| 29 | find_package(Spdevkit REQUIRED) |
| 30 | sp_dev_kit_configure_linking(TARGET se-proxy DEFINES ARM64=1) |
| 31 | target_link_libraries(se-proxy PRIVATE ${SP_DEV_KIT_LIBRARIES}) |
| 32 | |
| 33 | #------------------------------------------------------------------------------- |
| 34 | # Default deployment specific configuration |
| 35 | # |
| 36 | #------------------------------------------------------------------------------- |
| 37 | set(TS_NO_FLOAT_HW ON) |
| 38 | |
| 39 | #------------------------------------------------------------------------------- |
| 40 | # Components that are specific to deployment in the opteesp environment. |
| 41 | # |
| 42 | #------------------------------------------------------------------------------- |
| 43 | add_components(TARGET "se-proxy" |
| 44 | BASE_DIR ${TS_ROOT} |
| 45 | COMPONENTS |
| 46 | "protocols/rpc/common/packed-c" |
| 47 | "protocols/service/secure_storage/packed-c" |
| 48 | "protocols/service/crypto/protobuf" |
| 49 | "environments/opteesp" |
| 50 | "components/common/tlv" |
| 51 | "components/config/ramstore" |
| 52 | "components/config/loader/sp" |
| 53 | "components/messaging/ffa/libsp" |
| 54 | "components/rpc/ffarpc/endpoint" |
| 55 | "components/rpc/common/interface" |
| 56 | "components/rpc/common/demux" |
| 57 | "components/service/common/include" |
| 58 | "components/service/common/serializer/protobuf" |
| 59 | "components/service/common/provider" |
Julian Hall | 9061e6c | 2021-06-29 14:24:20 +0100 | [diff] [blame] | 60 | "components/service/crypto/provider" |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 61 | "components/service/crypto/provider/serializer/protobuf" |
| 62 | "components/service/crypto/provider/serializer/packed-c" |
Julian Hall | 7bfb18e | 2021-07-13 15:48:13 +0100 | [diff] [blame] | 63 | "components/service/crypto/provider/extension/hash" |
| 64 | "components/service/crypto/provider/extension/hash/serializer/packed-c" |
Julian Hall | e7bccbe | 2021-07-16 09:50:34 +0100 | [diff] [blame^] | 65 | "components/service/crypto/provider/extension/cipher" |
| 66 | "components/service/crypto/provider/extension/cipher/serializer/packed-c" |
Julian Hall | 7bfb18e | 2021-07-13 15:48:13 +0100 | [diff] [blame] | 67 | "components/service/crypto/factory/full" |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 68 | "components/service/secure_storage/include" |
| 69 | "components/service/secure_storage/frontend/secure_storage_provider" |
| 70 | "components/service/attestation/include" |
| 71 | "components/service/attestation/provider" |
| 72 | "components/service/attestation/provider/serializer/packed-c" |
| 73 | |
| 74 | # Components that won't be in a proxy |
| 75 | "components/common/endian" |
| 76 | "components/service/attestation/claims" |
| 77 | "components/service/attestation/claims/sources/boot_seed_generator" |
| 78 | "components/service/attestation/claims/sources/null_lifecycle" |
| 79 | "components/service/attestation/claims/sources/instance_id" |
| 80 | "components/service/attestation/claims/sources/event_log" |
| 81 | "components/service/attestation/claims/sources/event_log/mock" |
Julian Hall | 644b57a | 2021-06-30 08:45:19 +0100 | [diff] [blame] | 82 | "components/service/attestation/reporter/local" |
| 83 | "components/service/attestation/reporter/eat" |
| 84 | "components/service/attestation/key_mngr/local" |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 85 | "components/service/secure_storage/frontend/psa/its" |
| 86 | "components/service/secure_storage/backend/secure_flash_store" |
| 87 | "components/service/secure_storage/backend/secure_flash_store/flash_fs" |
| 88 | "components/service/secure_storage/backend/secure_flash_store/flash" |
Julian Hall | 9061e6c | 2021-06-29 14:24:20 +0100 | [diff] [blame] | 89 | "components/service/crypto/backend/mbedcrypto" |
| 90 | "components/service/crypto/backend/mbedcrypto/trng_adapter/platform" |
Julian Hall | 527ddd5 | 2021-06-28 11:57:17 +0100 | [diff] [blame] | 91 | ) |
| 92 | |
| 93 | target_sources(se-proxy PRIVATE |
| 94 | se_proxy_sp.c |
| 95 | service_proxy_factory.c |
| 96 | ) |
| 97 | |
| 98 | #------------------------------------------------------------------------------- |
| 99 | # Use the selected platform to provide drivers needed by the deployment |
| 100 | # |
| 101 | #------------------------------------------------------------------------------- |
| 102 | # temporarily force platform - with this change, the build interface to |
| 103 | # an external builder such as a Yocto recipe is unchanged. Should remove |
| 104 | # once the build interface is published. |
| 105 | set(TS_PLATFORM "arm/fvp/fvp_base_revc-2xaemv8a" CACHE STRING "Overridden" FORCE) |
| 106 | |
| 107 | add_platform(TARGET "se-proxy") |
| 108 | |
| 109 | #------------------------------------------------------------------------------- |
| 110 | # Components used from external projects |
| 111 | # |
| 112 | #------------------------------------------------------------------------------- |
| 113 | |
| 114 | # Nanopb |
| 115 | list(APPEND NANOPB_EXTERNAL_INCLUDE_PATHS ${SP_DEV_KIT_INCLUDE_DIR}) |
| 116 | include(../../../external/nanopb/nanopb.cmake) |
| 117 | target_link_libraries(se-proxy PRIVATE nanopb::protobuf-nanopb-static) |
| 118 | protobuf_generate_all(TGT "se-proxy" NAMESPACE "protobuf" BASE_DIR "${TS_ROOT}/protocols") |
| 119 | |
| 120 | # Mbed TLS provides libmbedcrypto |
| 121 | include(../../../external/MbedTLS/MbedTLS.cmake) |
| 122 | target_link_libraries(se-proxy PRIVATE mbedcrypto) |
| 123 | |
| 124 | # Qcbor |
| 125 | include(${TS_ROOT}/external/qcbor/qcbor.cmake) |
| 126 | target_link_libraries(se-proxy PRIVATE qcbor) |
| 127 | |
| 128 | # t_cose |
| 129 | include(${TS_ROOT}/external/t_cose/t_cose.cmake) |
| 130 | target_link_libraries(se-proxy PRIVATE t_cose) |
| 131 | |
| 132 | ################################################################# |
| 133 | |
| 134 | target_compile_definitions(se-proxy PRIVATE |
| 135 | ARM64=1 |
| 136 | ) |
| 137 | |
| 138 | target_include_directories(se-proxy PRIVATE |
| 139 | ${TS_ROOT} |
| 140 | ${TS_ROOT}/components |
| 141 | ${TS_ROOT}/deployments/se-proxy/opteesp |
| 142 | ) |
| 143 | |
| 144 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
| 145 | target_compile_options(se-proxy PRIVATE |
| 146 | -fdiagnostics-show-option |
| 147 | -gdwarf-2 |
| 148 | -mstrict-align |
| 149 | -O0 |
| 150 | -std=c99 |
| 151 | ) |
| 152 | |
| 153 | # Options for GCC that control linking |
| 154 | target_link_options(se-proxy PRIVATE |
| 155 | -zmax-page-size=4096 |
| 156 | ) |
| 157 | # Options directly for LD, these are not understood by GCC |
| 158 | target_link_options(se-proxy PRIVATE |
| 159 | -Wl,--as-needed |
| 160 | -Wl,--sort-section=alignment |
| 161 | # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list |
| 162 | ) |
| 163 | endif() |
| 164 | |
| 165 | compiler_generate_stripped_elf(TARGET se-proxy NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF) |
| 166 | |
| 167 | ######################################## install |
| 168 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 169 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 170 | endif() |
| 171 | #TODO: api headers |
| 172 | |
| 173 | install(TARGETS se-proxy |
| 174 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 175 | RUNTIME DESTINATION ${TS_ENV}/bin |
| 176 | ) |
| 177 | install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin) |
| 178 | |
| 179 | get_property(_PROTO_FILES TARGET se-proxy PROPERTY PROTOBUF_FILES) |
| 180 | install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf) |
| 181 | |
| 182 | |
| 183 | set(EXPORT_SP_NAME "se-proxy") |
| 184 | set(EXPORT_SP_UUID ${SP_UUID}) |
| 185 | include(${TS_ROOT}/environments/opteesp/ExportSp.cmake) |