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 |
| 47 | $<$<BOOL:${PLATFORM_DUMMY_ATTEST_HAL}>:ext/common/template/attest_hal.c> |
| 48 | $<$<BOOL:${PLATFORM_DUMMY_NV_COUNTERS}>:ext/common/template/nv_counters.c> |
| 49 | $<$<BOOL:${PLATFORM_DUMMY_CRYPTO_KEYS}>:ext/common/template/crypto_keys.c> |
| 50 | $<$<BOOL:${PLATFORM_DUMMY_IAK}>:ext/common/template/tfm_initial_attestation_key_material.c> |
| 51 | ) |
| 52 | |
| 53 | target_link_libraries(platform_s |
| 54 | PUBLIC |
| 55 | platform_region_defs |
| 56 | PRIVATE |
| 57 | psa_interface |
| 58 | tfm_secure_api |
| 59 | $<$<BOOL:${BL2}>:platform_bl2> |
| 60 | tfm_arch |
| 61 | ) |
| 62 | |
| 63 | target_compile_definitions(platform_s |
| 64 | PRIVATE |
| 65 | $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:SYMMETRIC_INITIAL_ATTESTATION> |
| 66 | ) |
| 67 | |
| 68 | #========================= Platform Non-Secure ================================# |
| 69 | |
| 70 | target_include_directories(platform_ns |
| 71 | PUBLIC |
| 72 | ext |
| 73 | ext/common |
| 74 | ext/driver |
| 75 | ext/common |
| 76 | include |
| 77 | ext/cmsis |
| 78 | ) |
| 79 | |
| 80 | target_sources(platform_ns |
| 81 | PRIVATE |
| 82 | ext/common/uart_stdout.c |
| 83 | ) |
| 84 | |
| 85 | target_link_libraries(platform_ns |
| 86 | PUBLIC |
| 87 | platform_region_defs |
| 88 | ) |
| 89 | |
| 90 | #========================= Platform BL2 =======================================# |
| 91 | if(BL2) |
| 92 | #TODO import policy |
| 93 | target_include_directories(platform_bl2 |
| 94 | PUBLIC |
| 95 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 96 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/cmsis> |
| 97 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/driver> |
| 98 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext/common> |
| 99 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext> |
Tamas Ban | 37aedb5 | 2020-10-01 10:54:48 +0100 | [diff] [blame^] | 100 | $<$<BOOL:${CRYPTO_HW_ACCELERATOR}>:${CMAKE_CURRENT_SOURCE_DIR}/ext/accelerator/interface> |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 101 | ) |
| 102 | |
| 103 | target_sources(platform_bl2 |
| 104 | PRIVATE |
| 105 | ext/common/uart_stdout.c |
| 106 | ext/common/boot_hal.c |
| 107 | $<$<BOOL:${PLATFORM_DUMMY_NV_COUNTERS}>:ext/common/template/nv_counters.c> |
| 108 | $<$<BOOL:${PLATFORM_DUMMY_CRYPTO_KEYS}>:ext/common/template/crypto_keys.c> |
| 109 | $<$<BOOL:${PLATFORM_DUMMY_ROTPK}>:ext/common/template/tfm_rotpk.c> |
| 110 | $<$<BOOL:${PLATFORM_DUMMY_IAK}>:ext/common/template/tfm_initial_attestation_key_material.c> |
| 111 | ) |
| 112 | |
| 113 | target_link_libraries(platform_bl2 |
| 114 | PUBLIC |
| 115 | platform_region_defs |
| 116 | PRIVATE |
| 117 | psa_interface |
| 118 | bl2_hal |
| 119 | tfm_arch |
| 120 | ) |
| 121 | |
Balint Matyi | bf0780b | 2020-07-09 14:39:16 +0100 | [diff] [blame] | 122 | if (NOT DEFINED MCUBOOT_UPGRADE_STRATEGY) |
| 123 | message(FATAL_ERROR "MCUBOOT_UPGRADE_STRATEGY is undefined") |
| 124 | else() |
| 125 | string(CONCAT UPGRADE_STRATEGY "MCUBOOT_" ${MCUBOOT_UPGRADE_STRATEGY}) |
| 126 | endif() |
| 127 | |
Raef Coles | 1cb0ecc | 2020-07-10 09:56:01 +0100 | [diff] [blame] | 128 | target_compile_definitions(platform_bl2 |
| 129 | PUBLIC |
| 130 | BL2 |
| 131 | MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER} |
| 132 | $<$<STREQUAL:${MCUBOOT_SIGNATURE_TYPE},RSA>:MCUBOOT_SIGN_RSA> |
| 133 | $<$<STREQUAL:${MCUBOOT_SIGNATURE_TYPE},RSA>:MCUBOOT_SIGN_RSA_LEN=${MCUBOOT_SIGNATURE_KEY_LEN}> |
| 134 | MCUBOOT_${MCUBOOT_UPGRADE_STRATEGY} |
| 135 | $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:SYMMETRIC_INITIAL_ATTESTATION> |
| 136 | $<$<BOOL:${MCUBOOT_HW_KEY}>:MCUBOOT_HW_KEY> |
| 137 | ) |
| 138 | endif() |
| 139 | |
| 140 | #========================= Platform region defs ===============================# |
| 141 | |
| 142 | #TODO maybe just link the other platforms to this |
| 143 | target_compile_definitions(platform_region_defs |
| 144 | INTERFACE |
| 145 | $<$<BOOL:${BL2}>:BL2> |
| 146 | $<$<BOOL:${SECURE_UART1}>:SECURE_UART1> |
| 147 | DAUTH_${DEBUG_AUTHENTICATION} |
| 148 | $<$<BOOL:${BL2}>:MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}> |
| 149 | $<$<STREQUAL:${MCUBOOT_EXECUTION_SLOT},2>:LINK_TO_SECONDARY_PARTITION> |
| 150 | ) |