Jamie Fox | ab30e71 | 2023-03-30 17:48:36 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Tamas Ban | fb0efd7 | 2025-03-14 14:55:05 +0100 | [diff] [blame] | 2 | # Copyright (c) 2023-2025, Arm Limited. All rights reserved. |
Jamie Fox | ab30e71 | 2023-03-30 17:48:36 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | if (NOT TFM_PARTITION_DPE) |
| 9 | return() |
| 10 | endif() |
| 11 | |
| 12 | cmake_minimum_required(VERSION 3.15) |
| 13 | cmake_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. |
| 18 | add_library(tfm_app_rot_partition_dpe STATIC) |
| 19 | |
| 20 | target_sources(tfm_app_rot_partition_dpe |
| 21 | PRIVATE |
Jamie Fox | 3468199 | 2023-09-04 18:14:06 +0100 | [diff] [blame] | 22 | dpe_boot_data.c |
Maulik Patel | 2358bbb | 2023-07-21 10:56:56 +0100 | [diff] [blame] | 23 | dpe_certificate.c |
Jamie Fox | ab30e71 | 2023-03-30 17:48:36 +0100 | [diff] [blame] | 24 | dpe_cmd_decode.c |
Maulik Patel | ad2f3db | 2023-05-17 15:41:36 +0100 | [diff] [blame] | 25 | dpe_context_mngr.c |
Maulik Patel | 58595d3 | 2023-06-22 10:08:53 +0100 | [diff] [blame] | 26 | dpe_crypto_interface.c |
Jamie Fox | e7f8b4e | 2023-05-30 18:03:20 +0100 | [diff] [blame] | 27 | dpe_log.c |
Jamie Fox | ab30e71 | 2023-03-30 17:48:36 +0100 | [diff] [blame] | 28 | 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. |
| 33 | target_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. |
| 39 | target_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 | |
| 44 | target_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 Patel | ad2f3db | 2023-05-17 15:41:36 +0100 | [diff] [blame] | 51 | target_compile_definitions(tfm_app_rot_partition_dpe |
| 52 | PRIVATE |
Jamie Fox | 63c33f1 | 2024-04-12 17:36:07 +0100 | [diff] [blame] | 53 | $<$<OR:$<BOOL:${TFM_S_REG_TEST}>,$<BOOL:${TFM_NS_REG_TEST}>>:DPE_TEST_MODE> |
Maulik Patel | ad2f3db | 2023-05-17 15:41:36 +0100 | [diff] [blame] | 54 | ) |
| 55 | |
Jamie Fox | ab30e71 | 2023-03-30 17:48:36 +0100 | [diff] [blame] | 56 | target_link_libraries(tfm_app_rot_partition_dpe |
| 57 | PRIVATE |
| 58 | tfm_sprt |
| 59 | qcbor |
Maulik Patel | 2358bbb | 2023-07-21 10:56:56 +0100 | [diff] [blame] | 60 | tfm_t_cose_s |
Jamie Fox | 3468199 | 2023-09-04 18:14:06 +0100 | [diff] [blame] | 61 | platform_s |
Antonio de Angelis | 2f6601f | 2024-02-07 13:34:59 +0000 | [diff] [blame] | 62 | psa_crypto_config |
Jamie Fox | ab30e71 | 2023-03-30 17:48:36 +0100 | [diff] [blame] | 63 | ) |
| 64 | |
| 65 | ############################ Secure API ######################################## |
| 66 | |
| 67 | target_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 | |
| 73 | target_include_directories(tfm_sprt |
| 74 | PUBLIC |
| 75 | ${CMAKE_CURRENT_SOURCE_DIR}/interface/include |
| 76 | ) |
| 77 | |
| 78 | target_link_libraries(tfm_sprt |
| 79 | PRIVATE |
| 80 | qcbor |
| 81 | ) |
| 82 | |
Jamie Fox | ab30e71 | 2023-03-30 17:48:36 +0100 | [diff] [blame] | 83 | ############################ Partition Defs #################################### |
| 84 | |
| 85 | target_link_libraries(tfm_partitions |
| 86 | INTERFACE |
| 87 | tfm_app_rot_partition_dpe |
| 88 | ) |
| 89 | |
| 90 | target_compile_definitions(tfm_config |
| 91 | INTERFACE |
| 92 | TFM_PARTITION_DPE |
| 93 | ) |
| 94 | |
| 95 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/interface/src/dpe_cmd_encode.c |
| 96 | ${CMAKE_CURRENT_SOURCE_DIR}/interface/src/dpe_client.c |
Jamie Fox | 805db7b | 2023-11-01 18:46:58 +0000 | [diff] [blame] | 97 | DESTINATION ${INSTALL_INTERFACE_SRC_DIR}) |
Jamie Fox | ab30e71 | 2023-03-30 17:48:36 +0100 | [diff] [blame] | 98 | |
Jamie Fox | 63c33f1 | 2024-04-12 17:36:07 +0100 | [diff] [blame] | 99 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/interface/include/ |
Jamie Fox | 805db7b | 2023-11-01 18:46:58 +0000 | [diff] [blame] | 100 | DESTINATION ${INSTALL_INTERFACE_INC_DIR}) |
Tamas Ban | afc4f3c | 2024-08-13 11:46:58 +0200 | [diff] [blame] | 101 | |
| 102 | ############################## Host Build ###################################### |
| 103 | |
| 104 | if (HOST_BUILD) |
| 105 | |
| 106 | find_package(Python3) |
| 107 | |
Tamas Ban | 545bb5c | 2024-08-13 12:00:52 +0200 | [diff] [blame] | 108 | 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 Ban | afc4f3c | 2024-08-13 11:46:58 +0200 | [diff] [blame] | 112 | 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 Ban | fb0efd7 | 2025-03-14 14:55:05 +0100 | [diff] [blame] | 125 | -DTFM_PATH=${CMAKE_SOURCE_DIR} # To locate tfm_t_cose.cmake |
| 126 | -DT_COSE_PATH=${T_COSE_PATH} # External dependency |
Tamas Ban | 545bb5c | 2024-08-13 12:00:52 +0200 | [diff] [blame] | 127 | -DTFM_TEST_PATH=${TFM_TEST_PATH} # To locate test framework src |
Jackson Cooper-Driver | 90d89a0 | 2025-03-03 16:41:37 +0000 | [diff] [blame^] | 128 | -DLOG_LEVEL_UNPRIV=${TFM_PARTITION_LOG_LEVEL} |
Tamas Ban | 808cbcd | 2024-08-13 13:32:06 +0200 | [diff] [blame] | 129 | $<$<BOOL:${AFL_CC}>:-DCMAKE_C_COMPILER=${AFL_CC}> |
| 130 | $<$<BOOL:${AFL_CC}>:-DFUZZ_TEST=ON> |
Tamas Ban | afc4f3c | 2024-08-13 11:46:58 +0200 | [diff] [blame] | 131 | 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 | |
| 135 | endif() |