blob: 40578e30eaef93742a804dd2220bac18119a2793 [file] [log] [blame]
Julian Hallcaa4af82021-05-19 12:02:36 +01001#-------------------------------------------------------------------------------
2# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7cmake_minimum_required(VERSION 3.16)
8include(../../deployment.cmake REQUIRED)
9
10#-------------------------------------------------------------------------------
11# The CMakeLists.txt for building the attestation deployment for opteesp
12#
13# Builds the attestation service provider for running in an SEL0 secure partition
14# hosted by OPTEE in the role of SPM.
15#-------------------------------------------------------------------------------
16include(${TS_ROOT}/environments/opteesp/env.cmake)
17project(trusted-services LANGUAGES C ASM)
18add_executable(attestation)
19target_include_directories(attestation PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
20set(SP_UUID "a1baf155-8876-4695-8f7c-54955e8db974")
21
22
23# Include SP DEV KIT interface
24set(SP_DEV_KIT_INC_DIR ${CMAKE_CURRENT_LIST_DIR})
25list(APPEND CMAKE_MODULE_PATH "${TS_ROOT}/external/Spdevkit")
26find_package(Spdevkit REQUIRED)
27sp_dev_kit_configure_linking(TARGET attestation DEFINES ARM64=1)
28target_link_libraries(attestation PRIVATE ${SP_DEV_KIT_LIBRARIES})
29
30#-------------------------------------------------------------------------------
31# Default deployment specific configuration
32#
33#-------------------------------------------------------------------------------
34set(TS_NO_FLOAT_HW ON)
35
36#-------------------------------------------------------------------------------
37# Components that are specific to deployment in the opteesp environment.
38#
39#-------------------------------------------------------------------------------
40add_components(TARGET "attestation"
41 BASE_DIR ${TS_ROOT}
42 COMPONENTS
43 "components/common/tlv"
44 "components/common/endian"
45 "components/config/ramstore"
46 "components/config/loader/sp"
47 "components/messaging/ffa/libsp"
48 "components/rpc/ffarpc/endpoint"
49 "components/rpc/ffarpc/caller/sp"
50 "components/rpc/common/caller"
51 "components/rpc/common/interface"
52 "components/service/common/include"
53 "components/service/common/provider"
54 "components/service/attestation/include"
55 "components/service/attestation/claims"
56 "components/service/attestation/claims/sources/boot_seed_generator"
57 "components/service/attestation/claims/sources/null_lifecycle"
58 "components/service/attestation/claims/sources/instance_id"
Julian Hallb7db5802021-07-26 16:20:40 +010059 "components/service/attestation/claims/sources/implementation_id"
Julian Hallcaa4af82021-05-19 12:02:36 +010060 "components/service/attestation/claims/sources/event_log"
61 "components/service/attestation/claims/sources/event_log/mock"
Julian Hall644b57a2021-06-30 08:45:19 +010062 "components/service/attestation/reporter/local"
63 "components/service/attestation/reporter/eat"
64 "components/service/attestation/key_mngr/local"
Julian Hallcaa4af82021-05-19 12:02:36 +010065 "components/service/attestation/provider"
66 "components/service/attestation/provider/serializer/packed-c"
67 "protocols/rpc/common/packed-c"
68 "environments/opteesp"
69)
70
71target_sources(attestation PRIVATE
72 attestation_sp.c
73)
74
75#-------------------------------------------------------------------------------
76# Use the selected platform to provide drivers needed by the deployment
77#
78#-------------------------------------------------------------------------------
79add_platform(TARGET "attestation")
80
81#-------------------------------------------------------------------------------
82# Components used from external projects
83#
84#-------------------------------------------------------------------------------
85
86# Temporary dependency on mbedcrypto
87set(MBEDTLS_USER_CONFIG_FILE
88 "${TS_ROOT}/components/service/crypto/client/cpp/config_mbedtls_user.h"
89 CACHE STRING "Configuration file for mbedcrypto")
Andrew Beggs97a00d42021-06-15 15:45:46 +000090list(APPEND MBEDTLS_EXTRA_INCLUDES ${SP_DEV_KIT_INCLUDE_DIR})
Julian Hallcaa4af82021-05-19 12:02:36 +010091
92# Mbed TLS provides libmbedcrypto
93include(../../../external/MbedTLS/MbedTLS.cmake)
94target_link_libraries(attestation PRIVATE mbedcrypto)
95
96# Qcbor
Andrew Beggs97a00d42021-06-15 15:45:46 +000097set (QCBOR_EXTERNAL_INCLUDE_PATHS ${SP_DEV_KIT_INCLUDE_DIR})
Julian Hallcaa4af82021-05-19 12:02:36 +010098include(${TS_ROOT}/external/qcbor/qcbor.cmake)
99target_link_libraries(attestation PRIVATE qcbor)
100
101# t_cose
Andrew Beggs97a00d42021-06-15 15:45:46 +0000102set (TCOSE_EXTERNAL_INCLUDE_PATHS ${SP_DEV_KIT_INCLUDE_DIR})
Julian Hallcaa4af82021-05-19 12:02:36 +0100103include(${TS_ROOT}/external/t_cose/t_cose.cmake)
104target_link_libraries(attestation PRIVATE t_cose)
105
106if(CMAKE_CROSSCOMPILING)
107 target_link_libraries(attestation PRIVATE stdc++ gcc m)
108endif()
109
110#################################################################
111
112target_compile_definitions(attestation PRIVATE
113 ARM64=1
114)
115
116target_include_directories(attestation PRIVATE
117 ${TS_ROOT}
118 ${TS_ROOT}/components
119 ${TS_ROOT}/deployments/attestation/opteesp
120)
121
122if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
123 target_compile_options(attestation PRIVATE
124 -fdiagnostics-show-option
Julian Hallcaa4af82021-05-19 12:02:36 +0100125 -gdwarf-2
126 -mstrict-align
127 -O0
Andrew Beggs97a00d42021-06-15 15:45:46 +0000128 -std=c99
Julian Hallcaa4af82021-05-19 12:02:36 +0100129 )
130
131 # Options for GCC that control linking
132 target_link_options(attestation PRIVATE
Julian Hallcaa4af82021-05-19 12:02:36 +0100133 -zmax-page-size=4096
134 )
135 # Options directly for LD, these are not understood by GCC
136 target_link_options(attestation PRIVATE
137 -Wl,--as-needed
138 -Wl,--sort-section=alignment
139 # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list
140 )
141endif()
142
143compiler_generate_stripped_elf(TARGET attestation NAME "${SP_UUID}.stripped.elf" RES STRIPPED_ELF)
144
145######################################## install
146if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
147 set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
148endif()
149#TODO: api headers
150
151install(TARGETS attestation
152 PUBLIC_HEADER DESTINATION ${TS_ENV}/include
153 RUNTIME DESTINATION ${TS_ENV}/bin
154 )
155install(FILES ${STRIPPED_ELF} DESTINATION ${TS_ENV}/bin)
156
157get_property(_PROTO_FILES TARGET attestation PROPERTY PROTOBUF_FILES)
158install(FILES ${_PROTO_FILES} DESTINATION ${TS_ENV}/lib/protobuf)
159
160
161set(EXPORT_SP_NAME "attestation")
162set(EXPORT_SP_UUID ${SP_UUID})
163include(${TS_ROOT}/environments/opteesp/ExportSp.cmake)