Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
David Hu | be31873 | 2020-11-23 17:08:32 +0800 | [diff] [blame] | 2 | # Copyright (c) 2020-2021, Arm Limited. All rights reserved. |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
Raef Coles | 6981732 | 2020-10-19 14:14:14 +0100 | [diff] [blame] | 7 | cmake_minimum_required(VERSION 3.15) |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 8 | cmake_policy(SET CMP0076 NEW) |
| 9 | cmake_policy(SET CMP0079 NEW) |
| 10 | |
| 11 | add_library(platform_s STATIC) |
| 12 | add_library(platform_region_defs INTERFACE) |
| 13 | |
| 14 | # under the multicore topology, NS is declared in the same place as the PSA |
| 15 | # interface so that it picks up the compiler definitions for the NS CPU |
| 16 | if(NOT TFM_MULTI_CORE_TOPOLOGY) |
David Hu | 1d2329a | 2020-12-16 19:17:06 +0800 | [diff] [blame] | 17 | add_library(platform_ns STATIC EXCLUDE_FROM_ALL) |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 18 | endif() |
| 19 | |
| 20 | if (BL2) |
| 21 | add_library(platform_bl2 STATIC) |
| 22 | endif() |
| 23 | |
| 24 | set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 25 | |
Øyvind Rønningstad | 1dab74b | 2020-12-01 15:26:39 +0100 | [diff] [blame] | 26 | add_subdirectory(ext/target/${TFM_PLATFORM} target) |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 27 | |
| 28 | #========================= Platform Secure ====================================# |
| 29 | |
| 30 | target_include_directories(platform_s |
| 31 | PUBLIC |
| 32 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 33 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext> |
| 34 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/common> |
| 35 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/driver> |
| 36 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/cmsis> |
Tamas Ban | 37aedb5 | 2020-10-01 10:54:48 +0100 | [diff] [blame] | 37 | $<$<BOOL:${CRYPTO_HW_ACCELERATOR}>:${CMAKE_CURRENT_SOURCE_DIR}/ext/accelerator/interface> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 38 | ) |
| 39 | |
| 40 | target_sources(platform_s |
| 41 | PRIVATE |
| 42 | ext/common/template/attest_hal.c |
Mark Horvath | b9ac0d5 | 2020-09-09 10:48:22 +0200 | [diff] [blame] | 43 | $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${CMAKE_CURRENT_SOURCE_DIR}/ext/common/tfm_hal_ps.c> |
| 44 | $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${CMAKE_CURRENT_SOURCE_DIR}/ext/common/tfm_hal_its.c> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 45 | ext/common/tfm_platform.c |
Gabor Abonyi | 931622b | 2020-10-19 15:08:40 +0200 | [diff] [blame] | 46 | $<$<BOOL:${PLATFORM_DEFAULT_UART_STDOUT}>:${CMAKE_CURRENT_SOURCE_DIR}/ext/common/uart_stdout.c> |
Shawn Shan | 90f102f | 2021-02-19 10:45:07 +0800 | [diff] [blame] | 47 | $<$<NOT:$<STREQUAL:${TFM_SPM_LOG_LEVEL},TFM_SPM_LOG_LEVEL_SILENCE>>:ext/common/tfm_hal_spm_logdev_peripheral.c> |
Summer Qin | df8716b | 2020-08-05 11:19:44 +0800 | [diff] [blame] | 48 | ext/common/tfm_hal_memory_symbols.c |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 49 | $<$<BOOL:${PLATFORM_DUMMY_ATTEST_HAL}>:ext/common/template/attest_hal.c> |
| 50 | $<$<BOOL:${PLATFORM_DUMMY_NV_COUNTERS}>:ext/common/template/nv_counters.c> |
| 51 | $<$<BOOL:${PLATFORM_DUMMY_CRYPTO_KEYS}>:ext/common/template/crypto_keys.c> |
Michel Jaouen | 4dc2442 | 2020-09-25 14:24:45 +0200 | [diff] [blame] | 52 | $<$<BOOL:${PLATFORM_DUMMY_ROTPK}>:ext/common/template/tfm_rotpk.c> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 53 | $<$<BOOL:${PLATFORM_DUMMY_IAK}>:ext/common/template/tfm_initial_attestation_key_material.c> |
| 54 | ) |
| 55 | |
| 56 | target_link_libraries(platform_s |
| 57 | PUBLIC |
| 58 | platform_region_defs |
| 59 | PRIVATE |
| 60 | psa_interface |
| 61 | tfm_secure_api |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 62 | tfm_arch |
| 63 | ) |
| 64 | |
| 65 | target_compile_definitions(platform_s |
Shawn Shan | 6f33aad | 2020-10-16 15:30:17 +0800 | [diff] [blame] | 66 | PUBLIC |
| 67 | TFM_SPM_LOG_LEVEL=${TFM_SPM_LOG_LEVEL} |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 68 | PRIVATE |
| 69 | $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:SYMMETRIC_INITIAL_ATTESTATION> |
Mingyang Sun | 9763dee | 2020-12-07 10:45:17 +0800 | [diff] [blame] | 70 | $<$<OR:$<VERSION_GREATER:${TFM_ISOLATION_LEVEL},1>,$<STREQUAL:"${TEST_PSA_API}","IPC">>:CONFIG_TFM_ENABLE_MEMORY_PROTECT> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 71 | ) |
| 72 | |
| 73 | #========================= Platform Non-Secure ================================# |
| 74 | |
| 75 | target_include_directories(platform_ns |
| 76 | PUBLIC |
| 77 | ext |
| 78 | ext/common |
| 79 | ext/driver |
| 80 | ext/common |
| 81 | include |
| 82 | ext/cmsis |
| 83 | ) |
| 84 | |
| 85 | target_sources(platform_ns |
| 86 | PRIVATE |
Gabor Abonyi | 931622b | 2020-10-19 15:08:40 +0200 | [diff] [blame] | 87 | $<$<BOOL:${PLATFORM_DEFAULT_UART_STDOUT}>:${CMAKE_CURRENT_SOURCE_DIR}/ext/common/uart_stdout.c> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 88 | ) |
| 89 | |
| 90 | target_link_libraries(platform_ns |
| 91 | PUBLIC |
| 92 | platform_region_defs |
David Hu | b7a131e | 2020-12-04 17:20:27 +0800 | [diff] [blame] | 93 | tfm_ns_interface |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 94 | ) |
| 95 | |
Raef Coles | c342d5c | 2020-10-12 10:08:38 +0100 | [diff] [blame] | 96 | target_compile_definitions(platform_ns |
| 97 | PRIVATE |
| 98 | $<$<BOOL:${TFM_IRQ_TEST}>:TFM_ENABLE_IRQ_TEST> |
| 99 | $<$<BOOL:${TFM_PERIPH_ACCESS_TEST}>:TFM_ENABLE_PERIPH_ACCESS_TEST> |
| 100 | ) |
| 101 | |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 102 | #========================= Platform BL2 =======================================# |
| 103 | if(BL2) |
| 104 | #TODO import policy |
| 105 | target_include_directories(platform_bl2 |
| 106 | PUBLIC |
| 107 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 108 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/cmsis> |
| 109 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/driver> |
| 110 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/common> |
| 111 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext> |
Tamas Ban | 37aedb5 | 2020-10-01 10:54:48 +0100 | [diff] [blame] | 112 | $<$<BOOL:${CRYPTO_HW_ACCELERATOR}>:${CMAKE_CURRENT_SOURCE_DIR}/ext/accelerator/interface> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 113 | ) |
| 114 | |
| 115 | target_sources(platform_bl2 |
| 116 | PRIVATE |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 117 | ext/common/boot_hal.c |
Gabor Abonyi | 931622b | 2020-10-19 15:08:40 +0200 | [diff] [blame] | 118 | $<$<BOOL:${PLATFORM_DEFAULT_UART_STDOUT}>:${CMAKE_CURRENT_SOURCE_DIR}/ext/common/uart_stdout.c> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 119 | $<$<BOOL:${PLATFORM_DUMMY_NV_COUNTERS}>:ext/common/template/nv_counters.c> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 120 | $<$<BOOL:${PLATFORM_DUMMY_ROTPK}>:ext/common/template/tfm_rotpk.c> |
David Hu | 3521a0f | 2020-11-04 06:52:35 +0000 | [diff] [blame] | 121 | $<$<BOOL:${PLATFORM_DUMMY_IAK}>:ext/common/template/tfm_initial_attestation_key_material.c> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 122 | ) |
| 123 | |
| 124 | target_link_libraries(platform_bl2 |
| 125 | PUBLIC |
| 126 | platform_region_defs |
| 127 | PRIVATE |
| 128 | psa_interface |
| 129 | bl2_hal |
| 130 | tfm_arch |
| 131 | ) |
| 132 | |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 133 | target_compile_definitions(platform_bl2 |
| 134 | PUBLIC |
| 135 | BL2 |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 136 | MCUBOOT_${MCUBOOT_UPGRADE_STRATEGY} |
| 137 | $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:SYMMETRIC_INITIAL_ATTESTATION> |
| 138 | $<$<BOOL:${MCUBOOT_HW_KEY}>:MCUBOOT_HW_KEY> |
Tamas Ban | 1bfc9da | 2020-07-09 13:55:38 +0100 | [diff] [blame] | 139 | MCUBOOT_FIH_PROFILE_${MCUBOOT_FIH_PROFILE} |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 140 | ) |
| 141 | endif() |
| 142 | |
| 143 | #========================= Platform region defs ===============================# |
| 144 | |
| 145 | #TODO maybe just link the other platforms to this |
| 146 | target_compile_definitions(platform_region_defs |
| 147 | INTERFACE |
| 148 | $<$<BOOL:${BL2}>:BL2> |
| 149 | $<$<BOOL:${SECURE_UART1}>:SECURE_UART1> |
| 150 | DAUTH_${DEBUG_AUTHENTICATION} |
Michel Jaouen | 4dc2442 | 2020-09-25 14:24:45 +0200 | [diff] [blame] | 151 | MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER} |
| 152 | $<$<STREQUAL:${MCUBOOT_SIGNATURE_TYPE},RSA>:MCUBOOT_SIGN_RSA> |
| 153 | $<$<STREQUAL:${MCUBOOT_SIGNATURE_TYPE},RSA>:MCUBOOT_SIGN_RSA_LEN=${MCUBOOT_SIGNATURE_KEY_LEN}> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 154 | $<$<STREQUAL:${MCUBOOT_EXECUTION_SLOT},2>:LINK_TO_SECONDARY_PARTITION> |
Soby Mathew | 5869e4c | 2020-10-09 18:07:30 +0100 | [diff] [blame] | 155 | $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_${TEST_PSA_API}> |
Mark Horvath | b9ac0d5 | 2020-09-09 10:48:22 +0200 | [diff] [blame] | 156 | $<$<BOOL:${FORWARD_PROT_MSG}>:FORWARD_PROT_MSG=${FORWARD_PROT_MSG}> |
Tamas Ban | ec109ea | 2020-11-24 14:13:30 +0000 | [diff] [blame] | 157 | $<$<BOOL:${TFM_CODE_SHARING}>:CODE_SHARING> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 158 | ) |