| #------------------------------------------------------------------------------- |
| # Copyright (c) 2023-2025, Arm Limited. All rights reserved. |
| # |
| # SPDX-License-Identifier: BSD-3-Clause |
| # |
| #------------------------------------------------------------------------------- |
| |
| if (NOT TFM_PARTITION_DPE) |
| return() |
| endif() |
| |
| cmake_minimum_required(VERSION 3.15) |
| cmake_policy(SET CMP0079 NEW) |
| |
| # The name of the target is required to be of the pattern |
| # tfm_app_rot_partition_x or tfm_psa_rot_partition_x, as it affects how the |
| # linker script will lay the partition in memory. |
| add_library(tfm_app_rot_partition_dpe STATIC) |
| |
| target_sources(tfm_app_rot_partition_dpe |
| PRIVATE |
| dpe_boot_data.c |
| dpe_certificate.c |
| dpe_cmd_decode.c |
| dpe_context_mngr.c |
| dpe_crypto_interface.c |
| dpe_log.c |
| dpe_req_mngr.c |
| ) |
| |
| # Add the source files generated by parse tools when building. |
| # The intermedia file defines the partition stack. |
| target_sources(tfm_app_rot_partition_dpe |
| PRIVATE |
| ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/dice_protection_environment/auto_generated/intermedia_tfm_dpe.c |
| ) |
| |
| # The load info file includes the static data of the partition. |
| target_sources(tfm_partitions |
| INTERFACE |
| ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/dice_protection_environment/auto_generated/load_info_tfm_dpe.c |
| ) |
| |
| target_include_directories(tfm_app_rot_partition_dpe |
| PRIVATE |
| ${CMAKE_CURRENT_SOURCE_DIR} |
| PUBLIC |
| ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/dice_protection_environment |
| ) |
| |
| target_compile_definitions(tfm_app_rot_partition_dpe |
| PRIVATE |
| $<$<OR:$<BOOL:${TFM_S_REG_TEST}>,$<BOOL:${TFM_NS_REG_TEST}>>:DPE_TEST_MODE> |
| ) |
| |
| target_link_libraries(tfm_app_rot_partition_dpe |
| PRIVATE |
| tfm_sprt |
| qcbor |
| tfm_t_cose_s |
| platform_s |
| psa_crypto_config |
| ) |
| |
| ############################ Secure API ######################################## |
| |
| target_sources(tfm_sprt |
| PRIVATE |
| ${CMAKE_CURRENT_SOURCE_DIR}/interface/src/dpe_cmd_encode.c |
| ${CMAKE_CURRENT_SOURCE_DIR}/interface/src/dpe_client.c |
| ) |
| |
| target_include_directories(tfm_sprt |
| PUBLIC |
| ${CMAKE_CURRENT_SOURCE_DIR}/interface/include |
| ) |
| |
| target_link_libraries(tfm_sprt |
| PRIVATE |
| qcbor |
| ) |
| |
| ############################ Partition Defs #################################### |
| |
| target_link_libraries(tfm_partitions |
| INTERFACE |
| tfm_app_rot_partition_dpe |
| ) |
| |
| target_compile_definitions(tfm_config |
| INTERFACE |
| TFM_PARTITION_DPE |
| ) |
| |
| install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/interface/src/dpe_cmd_encode.c |
| ${CMAKE_CURRENT_SOURCE_DIR}/interface/src/dpe_client.c |
| DESTINATION ${INSTALL_INTERFACE_SRC_DIR}) |
| |
| install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/interface/include/ |
| DESTINATION ${INSTALL_INTERFACE_INC_DIR}) |
| |
| ############################## Host Build ###################################### |
| |
| if (HOST_BUILD) |
| |
| find_package(Python3) |
| |
| if (NOT DEFINED TFM_TEST_PATH) |
| message(FATAL_ERROR "TFM_TEST_PATH is not defined. It is needed to locate test framework source.") |
| endif() |
| |
| add_custom_target(dpe_host |
| ALL |
| SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dpe_host/dpe_host |
| ) |
| |
| add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dpe_host/dpe_host |
| DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test/host/main.c |
| COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/dpe_host |
| COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_SOURCE_DIR}/test/host |
| -B ${CMAKE_CURRENT_BINARY_DIR}/dpe_host |
| -G ${CMAKE_GENERATOR} |
| -DMBEDCRYPTO_PATH=${MBEDCRYPTO_PATH} # External dependency |
| -DQCBOR_PATH=${QCBOR_PATH} # External dependency |
| -DTFM_PATH=${CMAKE_SOURCE_DIR} # To locate tfm_t_cose.cmake |
| -DT_COSE_PATH=${T_COSE_PATH} # External dependency |
| -DTFM_TEST_PATH=${TFM_TEST_PATH} # To locate test framework src |
| -DLOG_LEVEL_UNPRIV=${TFM_PARTITION_LOG_LEVEL} |
| $<$<BOOL:${AFL_CC}>:-DCMAKE_C_COMPILER=${AFL_CC}> |
| $<$<BOOL:${AFL_CC}>:-DFUZZ_TEST=ON> |
| COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/dpe_host |
| COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/dpe_host/dpe_host ${CMAKE_BINARY_DIR}/bin/host/dpe |
| ) |
| |
| endif() |