Balint Dobszay | ad82efb | 2024-11-21 13:53:09 +0100 | [diff] [blame^] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | cmake_minimum_required(VERSION 3.18 FATAL_ERROR) |
| 8 | |
| 9 | # Set default platform. |
| 10 | set(TS_PLATFORM "arm/fvp/fvp_base_revc-2xaemv8a" CACHE STRING "Target platform location.") |
| 11 | |
| 12 | # Set default build type to MinSizWithDebInfo to avoid running ouf of secure memory on low resource |
| 13 | # IoT platforms. |
| 14 | if (NOT DEFINED CMAKE_BUILD_TYPE) |
| 15 | set(CMAKE_BUILD_TYPE "MinSizWithDebInfo" CACHE STRING "Build type.") |
| 16 | endif() |
| 17 | |
| 18 | include(../../../deployment.cmake REQUIRED) |
| 19 | |
| 20 | include(${TS_ROOT}/environments/opteesp/env.cmake) |
| 21 | project(trusted-services LANGUAGES C ASM) |
| 22 | add_executable(ftpm) |
| 23 | target_include_directories(ftpm PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}") |
| 24 | |
| 25 | set(SP_BIN_UUID_CANON "17b862a4-1806-4faf-86b3-089a58353861") |
| 26 | set(SP_FFA_UUID_CANON "${SP_BIN_UUID_CANON}") |
| 27 | set(SP_HEAP_SIZE "128 * 1024" CACHE STRING "SP heap size in bytes") |
| 28 | set(SP_BOOT_ORDER "10" CACHE STRING "Boot order of the SP") |
| 29 | set(TRACE_PREFIX "FTPM" CACHE STRING "Trace prefix") |
| 30 | |
| 31 | set(TPM_CRB_NS_ADDRESS "0x84000000" CACHE STRING "Address of non-secure TPM CRB") |
| 32 | set(TPM_CRB_NS_PAGE_COUNT "4" CACHE STRING "Size of non-secure TPM CRB in 4k pages") |
| 33 | set(TPM_CRB_S_ADDRESS "0x07900000" CACHE STRING "Address of secure TPM CRB") |
| 34 | set(TPM_CRB_S_PAGE_COUNT "1" CACHE STRING "Size of secure TPM CRB in 4k pages") |
| 35 | |
| 36 | # Convert to format used in the SP manifest DT |
| 37 | uint64_split(VALUE ${TPM_CRB_NS_ADDRESS} OUT_PREFIX CRB_NS_ADDR) |
| 38 | uint64_split(VALUE ${TPM_CRB_S_ADDRESS} OUT_PREFIX CRB_S_ADDR) |
| 39 | |
| 40 | target_include_directories(ftpm PRIVATE |
| 41 | ${CMAKE_CURRENT_LIST_DIR} |
| 42 | ) |
| 43 | |
| 44 | #------------------------------------------------------------------------------- |
| 45 | # Set target platform to provide drivers needed by the deployment |
| 46 | # |
| 47 | #------------------------------------------------------------------------------- |
| 48 | add_platform(TARGET "ftpm") |
| 49 | |
| 50 | add_components(TARGET "ftpm" |
| 51 | BASE_DIR ${TS_ROOT} |
| 52 | COMPONENTS environments/opteesp |
| 53 | ) |
| 54 | |
| 55 | include(../../env/commonsp/ftpm_sp.cmake REQUIRED) |
| 56 | include(../../ftpm.cmake REQUIRED) |
| 57 | include(../../infra/ms_tpm_backend.cmake REQUIRED) |
| 58 | |
| 59 | #------------------------------------------------------------------------------- |
| 60 | # Deployment specific build options |
| 61 | # |
| 62 | #------------------------------------------------------------------------------- |
| 63 | target_compile_definitions(ftpm PRIVATE |
| 64 | ARM64=1 |
| 65 | TPM_CRB_NS_PA=${TPM_CRB_NS_ADDRESS} |
| 66 | TPM_CRB_S_PA=${TPM_CRB_S_ADDRESS} |
| 67 | ) |
| 68 | |
| 69 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU") |
| 70 | target_compile_options(ftpm PRIVATE |
| 71 | -std=c99 |
| 72 | ) |
| 73 | endif() |
| 74 | |
| 75 | #------------------------------------------------------------------------------- |
| 76 | # Deployment specific install options |
| 77 | # |
| 78 | #------------------------------------------------------------------------------- |
| 79 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
| 80 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE) |
| 81 | endif() |
| 82 | install(TARGETS ftpm |
| 83 | PUBLIC_HEADER DESTINATION ${TS_ENV}/include |
| 84 | RUNTIME DESTINATION ${TS_ENV}/bin |
| 85 | ) |
| 86 | |
| 87 | include(${TS_ROOT}/tools/cmake/common/ExportSp.cmake) |
| 88 | export_sp( |
| 89 | SP_FFA_UUID_CANON ${SP_FFA_UUID_CANON} |
| 90 | SP_BIN_UUID_CANON ${SP_BIN_UUID_CANON} |
| 91 | SP_BOOT_ORDER ${SP_BOOT_ORDER} |
| 92 | SP_NAME "ftpm" |
| 93 | DTS_IN ${CMAKE_CURRENT_LIST_DIR}/default_ftpm.dts.in |
| 94 | JSON_IN ${TS_ROOT}/environments/opteesp/sp_pkg.json.in |
| 95 | ) |