blob: c111503605d49bfa8b1d8664bb8b5623ecb3357b [file] [log] [blame]
Jamie Foxab30e712023-03-30 17:48:36 +01001#-------------------------------------------------------------------------------
Tamas Banfb0efd72025-03-14 14:55:05 +01002# Copyright (c) 2023-2025, Arm Limited. All rights reserved.
Jamie Foxab30e712023-03-30 17:48:36 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8if (NOT TFM_PARTITION_DPE)
9 return()
10endif()
11
12cmake_minimum_required(VERSION 3.15)
13cmake_policy(SET CMP0079 NEW)
14
15# The name of the target is required to be of the pattern
16# tfm_app_rot_partition_x or tfm_psa_rot_partition_x, as it affects how the
17# linker script will lay the partition in memory.
18add_library(tfm_app_rot_partition_dpe STATIC)
19
20target_sources(tfm_app_rot_partition_dpe
21 PRIVATE
Jamie Fox34681992023-09-04 18:14:06 +010022 dpe_boot_data.c
Maulik Patel2358bbb2023-07-21 10:56:56 +010023 dpe_certificate.c
Jamie Foxab30e712023-03-30 17:48:36 +010024 dpe_cmd_decode.c
Maulik Patelad2f3db2023-05-17 15:41:36 +010025 dpe_context_mngr.c
Maulik Patel58595d32023-06-22 10:08:53 +010026 dpe_crypto_interface.c
Jamie Foxe7f8b4e2023-05-30 18:03:20 +010027 dpe_log.c
Jamie Foxab30e712023-03-30 17:48:36 +010028 dpe_req_mngr.c
29)
30
31# Add the source files generated by parse tools when building.
32# The intermedia file defines the partition stack.
33target_sources(tfm_app_rot_partition_dpe
34 PRIVATE
35 ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/dice_protection_environment/auto_generated/intermedia_tfm_dpe.c
36)
37
38# The load info file includes the static data of the partition.
39target_sources(tfm_partitions
40 INTERFACE
41 ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/dice_protection_environment/auto_generated/load_info_tfm_dpe.c
42)
43
44target_include_directories(tfm_app_rot_partition_dpe
45 PRIVATE
46 ${CMAKE_CURRENT_SOURCE_DIR}
47 PUBLIC
48 ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/dice_protection_environment
49)
50
Maulik Patelad2f3db2023-05-17 15:41:36 +010051target_compile_definitions(tfm_app_rot_partition_dpe
52 PRIVATE
Jamie Fox63c33f12024-04-12 17:36:07 +010053 $<$<OR:$<BOOL:${TFM_S_REG_TEST}>,$<BOOL:${TFM_NS_REG_TEST}>>:DPE_TEST_MODE>
Maulik Patelad2f3db2023-05-17 15:41:36 +010054)
55
Jamie Foxab30e712023-03-30 17:48:36 +010056target_link_libraries(tfm_app_rot_partition_dpe
57 PRIVATE
58 tfm_sprt
59 qcbor
Maulik Patel2358bbb2023-07-21 10:56:56 +010060 tfm_t_cose_s
Jamie Fox34681992023-09-04 18:14:06 +010061 platform_s
Antonio de Angelis2f6601f2024-02-07 13:34:59 +000062 psa_crypto_config
Jamie Foxab30e712023-03-30 17:48:36 +010063)
64
65############################ Secure API ########################################
66
67target_sources(tfm_sprt
68 PRIVATE
69 ${CMAKE_CURRENT_SOURCE_DIR}/interface/src/dpe_cmd_encode.c
70 ${CMAKE_CURRENT_SOURCE_DIR}/interface/src/dpe_client.c
71)
72
73target_include_directories(tfm_sprt
74 PUBLIC
75 ${CMAKE_CURRENT_SOURCE_DIR}/interface/include
76)
77
78target_link_libraries(tfm_sprt
79 PRIVATE
80 qcbor
81)
82
Jamie Foxab30e712023-03-30 17:48:36 +010083############################ Partition Defs ####################################
84
85target_link_libraries(tfm_partitions
86 INTERFACE
87 tfm_app_rot_partition_dpe
88)
89
90target_compile_definitions(tfm_config
91 INTERFACE
92 TFM_PARTITION_DPE
93)
94
95install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/interface/src/dpe_cmd_encode.c
96 ${CMAKE_CURRENT_SOURCE_DIR}/interface/src/dpe_client.c
Jamie Fox805db7b2023-11-01 18:46:58 +000097 DESTINATION ${INSTALL_INTERFACE_SRC_DIR})
Jamie Foxab30e712023-03-30 17:48:36 +010098
Jamie Fox63c33f12024-04-12 17:36:07 +010099install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/interface/include/
Jamie Fox805db7b2023-11-01 18:46:58 +0000100 DESTINATION ${INSTALL_INTERFACE_INC_DIR})
Tamas Banafc4f3c2024-08-13 11:46:58 +0200101
102############################## Host Build ######################################
103
104if (HOST_BUILD)
105
106 find_package(Python3)
107
Tamas Ban545bb5c2024-08-13 12:00:52 +0200108 if (NOT DEFINED TFM_TEST_PATH)
109 message(FATAL_ERROR "TFM_TEST_PATH is not defined. It is needed to locate test framework source.")
110 endif()
111
Tamas Banafc4f3c2024-08-13 11:46:58 +0200112 add_custom_target(dpe_host
113 ALL
114 SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dpe_host/dpe_host
115 )
116
117 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dpe_host/dpe_host
118 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test/host/main.c
119 COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/dpe_host
120 COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR}/test/host
121 -B ${CMAKE_CURRENT_BINARY_DIR}/dpe_host
122 -G ${CMAKE_GENERATOR}
123 -DMBEDCRYPTO_PATH=${MBEDCRYPTO_PATH} # External dependency
124 -DQCBOR_PATH=${QCBOR_PATH} # External dependency
Tamas Banfb0efd72025-03-14 14:55:05 +0100125 -DTFM_PATH=${CMAKE_SOURCE_DIR} # To locate tfm_t_cose.cmake
126 -DT_COSE_PATH=${T_COSE_PATH} # External dependency
Tamas Ban545bb5c2024-08-13 12:00:52 +0200127 -DTFM_TEST_PATH=${TFM_TEST_PATH} # To locate test framework src
Jackson Cooper-Driver90d89a02025-03-03 16:41:37 +0000128 -DLOG_LEVEL_UNPRIV=${TFM_PARTITION_LOG_LEVEL}
Tamas Ban808cbcd2024-08-13 13:32:06 +0200129 $<$<BOOL:${AFL_CC}>:-DCMAKE_C_COMPILER=${AFL_CC}>
130 $<$<BOOL:${AFL_CC}>:-DFUZZ_TEST=ON>
Tamas Banafc4f3c2024-08-13 11:46:58 +0200131 COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/dpe_host
132 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/dpe_host/dpe_host ${CMAKE_BINARY_DIR}/bin/host/dpe
133 )
134
135endif()