Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2020, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | cmake_minimum_required(VERSION 3.13) |
| 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) |
| 17 | add_library(platform_ns STATIC) |
| 18 | endif() |
| 19 | |
| 20 | if (BL2) |
| 21 | add_library(platform_bl2 STATIC) |
| 22 | endif() |
| 23 | |
| 24 | set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 25 | |
| 26 | add_subdirectory(ext/target/${TFM_PLATFORM}) |
| 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 |
| 43 | ext/common/tfm_hal_ps.c |
| 44 | ext/common/tfm_hal_its.c |
| 45 | ext/common/tfm_platform.c |
| 46 | ext/common/uart_stdout.c |
Shawn Shan | 6f33aad | 2020-10-16 15:30:17 +0800 | [diff] [blame] | 47 | ext/common/tfm_hal_spm_logdev_peripheral.c |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 48 | $<$<BOOL:${PLATFORM_DUMMY_ATTEST_HAL}>:ext/common/template/attest_hal.c> |
| 49 | $<$<BOOL:${PLATFORM_DUMMY_NV_COUNTERS}>:ext/common/template/nv_counters.c> |
| 50 | $<$<BOOL:${PLATFORM_DUMMY_CRYPTO_KEYS}>:ext/common/template/crypto_keys.c> |
Michel Jaouen | 4dc2442 | 2020-09-25 14:24:45 +0200 | [diff] [blame] | 51 | $<$<BOOL:${PLATFORM_DUMMY_ROTPK}>:ext/common/template/tfm_rotpk.c> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 52 | $<$<BOOL:${PLATFORM_DUMMY_IAK}>:ext/common/template/tfm_initial_attestation_key_material.c> |
| 53 | ) |
| 54 | |
| 55 | target_link_libraries(platform_s |
| 56 | PUBLIC |
| 57 | platform_region_defs |
| 58 | PRIVATE |
| 59 | psa_interface |
| 60 | tfm_secure_api |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 61 | tfm_arch |
| 62 | ) |
| 63 | |
| 64 | target_compile_definitions(platform_s |
Shawn Shan | 6f33aad | 2020-10-16 15:30:17 +0800 | [diff] [blame] | 65 | PUBLIC |
| 66 | TFM_SPM_LOG_LEVEL=${TFM_SPM_LOG_LEVEL} |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 67 | PRIVATE |
| 68 | $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:SYMMETRIC_INITIAL_ATTESTATION> |
| 69 | ) |
| 70 | |
| 71 | #========================= Platform Non-Secure ================================# |
| 72 | |
| 73 | target_include_directories(platform_ns |
| 74 | PUBLIC |
| 75 | ext |
| 76 | ext/common |
| 77 | ext/driver |
| 78 | ext/common |
| 79 | include |
| 80 | ext/cmsis |
| 81 | ) |
| 82 | |
| 83 | target_sources(platform_ns |
| 84 | PRIVATE |
| 85 | ext/common/uart_stdout.c |
| 86 | ) |
| 87 | |
| 88 | target_link_libraries(platform_ns |
| 89 | PUBLIC |
| 90 | platform_region_defs |
Raef Coles | abe4f2c | 2020-10-02 10:32:35 +0100 | [diff] [blame] | 91 | psa_interface |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 92 | ) |
| 93 | |
Raef Coles | c342d5c | 2020-10-12 10:08:38 +0100 | [diff] [blame] | 94 | target_compile_definitions(platform_ns |
| 95 | PRIVATE |
| 96 | $<$<BOOL:${TFM_IRQ_TEST}>:TFM_ENABLE_IRQ_TEST> |
| 97 | $<$<BOOL:${TFM_PERIPH_ACCESS_TEST}>:TFM_ENABLE_PERIPH_ACCESS_TEST> |
David Hu | 6086394 | 2020-10-14 14:49:19 +0800 | [diff] [blame] | 98 | $<$<BOOL:${TFM_MULTI_CORE_MULTI_CLIENT_CALL}>:TFM_MULTI_CORE_MULTI_CLIENT_CALL> |
Raef Coles | c342d5c | 2020-10-12 10:08:38 +0100 | [diff] [blame] | 99 | ) |
| 100 | |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 101 | #========================= Platform BL2 =======================================# |
| 102 | if(BL2) |
| 103 | #TODO import policy |
| 104 | target_include_directories(platform_bl2 |
| 105 | PUBLIC |
| 106 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 107 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/cmsis> |
| 108 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/driver> |
| 109 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/common> |
| 110 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext> |
Tamas Ban | 37aedb5 | 2020-10-01 10:54:48 +0100 | [diff] [blame] | 111 | $<$<BOOL:${CRYPTO_HW_ACCELERATOR}>:${CMAKE_CURRENT_SOURCE_DIR}/ext/accelerator/interface> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 112 | ) |
| 113 | |
| 114 | target_sources(platform_bl2 |
| 115 | PRIVATE |
| 116 | ext/common/uart_stdout.c |
| 117 | ext/common/boot_hal.c |
| 118 | $<$<BOOL:${PLATFORM_DUMMY_NV_COUNTERS}>:ext/common/template/nv_counters.c> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 119 | $<$<BOOL:${PLATFORM_DUMMY_ROTPK}>:ext/common/template/tfm_rotpk.c> |
| 120 | $<$<BOOL:${PLATFORM_DUMMY_IAK}>:ext/common/template/tfm_initial_attestation_key_material.c> |
| 121 | ) |
| 122 | |
| 123 | target_link_libraries(platform_bl2 |
| 124 | PUBLIC |
| 125 | platform_region_defs |
| 126 | PRIVATE |
| 127 | psa_interface |
| 128 | bl2_hal |
| 129 | tfm_arch |
| 130 | ) |
| 131 | |
Balint Matyi | bf0780b | 2020-07-09 14:39:16 +0100 | [diff] [blame] | 132 | if (NOT DEFINED MCUBOOT_UPGRADE_STRATEGY) |
| 133 | message(FATAL_ERROR "MCUBOOT_UPGRADE_STRATEGY is undefined") |
| 134 | else() |
| 135 | string(CONCAT UPGRADE_STRATEGY "MCUBOOT_" ${MCUBOOT_UPGRADE_STRATEGY}) |
| 136 | endif() |
| 137 | |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 138 | target_compile_definitions(platform_bl2 |
| 139 | PUBLIC |
| 140 | BL2 |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 141 | MCUBOOT_${MCUBOOT_UPGRADE_STRATEGY} |
| 142 | $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:SYMMETRIC_INITIAL_ATTESTATION> |
| 143 | $<$<BOOL:${MCUBOOT_HW_KEY}>:MCUBOOT_HW_KEY> |
Tamas Ban | 1bfc9da | 2020-07-09 13:55:38 +0100 | [diff] [blame] | 144 | MCUBOOT_FIH_PROFILE_${MCUBOOT_FIH_PROFILE} |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 145 | ) |
| 146 | endif() |
| 147 | |
| 148 | #========================= Platform region defs ===============================# |
| 149 | |
| 150 | #TODO maybe just link the other platforms to this |
| 151 | target_compile_definitions(platform_region_defs |
| 152 | INTERFACE |
| 153 | $<$<BOOL:${BL2}>:BL2> |
| 154 | $<$<BOOL:${SECURE_UART1}>:SECURE_UART1> |
| 155 | DAUTH_${DEBUG_AUTHENTICATION} |
Michel Jaouen | 4dc2442 | 2020-09-25 14:24:45 +0200 | [diff] [blame] | 156 | MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER} |
| 157 | $<$<STREQUAL:${MCUBOOT_SIGNATURE_TYPE},RSA>:MCUBOOT_SIGN_RSA> |
| 158 | $<$<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] | 159 | $<$<STREQUAL:${MCUBOOT_EXECUTION_SLOT},2>:LINK_TO_SECONDARY_PARTITION> |
Soby Mathew | 5869e4c | 2020-10-09 18:07:30 +0100 | [diff] [blame] | 160 | $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_${TEST_PSA_API}> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 161 | ) |