1#-------------------------------------------------------------------------------
2# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8if (NOT TFM_PARTITION_PROTECTED_STORAGE)
9    return()
10endif()
11
12cmake_minimum_required(VERSION 3.21)
13
14add_library(tfm_app_rot_partition_ps STATIC)
15
16add_dependencies(tfm_app_rot_partition_ps manifest_tool)
17
18target_include_directories(tfm_app_rot_partition_ps
19    INTERFACE
20        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
21    PRIVATE
22        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/protected_storage
23)
24target_include_directories(tfm_partitions
25    INTERFACE
26        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/protected_storage
27)
28
29target_sources(tfm_app_rot_partition_ps
30    PRIVATE
31        tfm_ps_req_mngr.c
32        tfm_protected_storage.c
33        ps_object_system.c
34        ps_object_table.c
35        ps_utils.c
36        $<$<BOOL:${PS_ENCRYPTION}>:crypto/ps_crypto_interface.c>
37        $<$<BOOL:${PS_ENCRYPTION}>:ps_encrypted_object.c>
38        # The test_ps_nv_counters.c will be used instead, when PS secure test is
39        # ON and PS_TEST_NV_COUNTERS is ON
40        $<$<NOT:$<AND:$<BOOL:${TEST_S_PS}>,$<BOOL:${PS_TEST_NV_COUNTERS}>>>:nv_counters/ps_nv_counters.c>
41)
42
43if (NOT TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
44    set(PS_FILESYSTEM_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../internal_trusted_storage)
45
46    target_include_directories(tfm_app_rot_partition_ps
47        PRIVATE
48            ${PS_FILESYSTEM_SOURCE_PATH}
49    )
50
51    target_sources(tfm_app_rot_partition_ps
52        PRIVATE
53            ps_filesystem_interface.c
54            ${PS_FILESYSTEM_SOURCE_PATH}/tfm_internal_trusted_storage.c
55            ${PS_FILESYSTEM_SOURCE_PATH}/its_utils.c
56            ${PS_FILESYSTEM_SOURCE_PATH}/flash/its_flash.c
57            ${PS_FILESYSTEM_SOURCE_PATH}/flash/its_flash_nand.c
58            ${PS_FILESYSTEM_SOURCE_PATH}/flash/its_flash_nor.c
59            ${PS_FILESYSTEM_SOURCE_PATH}/flash/its_flash_ram.c
60            ${PS_FILESYSTEM_SOURCE_PATH}/flash_fs/its_flash_fs.c
61            ${PS_FILESYSTEM_SOURCE_PATH}/flash_fs/its_flash_fs_dblock.c
62            ${PS_FILESYSTEM_SOURCE_PATH}/flash_fs/its_flash_fs_mblock.c
63    )
64endif()
65
66# The generated sources
67target_sources(tfm_app_rot_partition_ps
68    PRIVATE
69        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/protected_storage/auto_generated/intermedia_tfm_protected_storage.c
70)
71target_sources(tfm_partitions
72    INTERFACE
73        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/protected_storage/auto_generated/load_info_tfm_protected_storage.c
74)
75
76target_link_libraries(tfm_app_rot_partition_ps
77    PRIVATE
78        secure_fw
79        platform_s
80        tfm_config
81        tfm_sprt
82        psa_crypto_config
83)
84
85target_compile_definitions(tfm_app_rot_partition_ps
86    PRIVATE
87        $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:TFM_PARTITION_INTERNAL_TRUSTED_STORAGE>
88)
89
90############################ Partition Defs ####################################
91
92target_link_libraries(tfm_partitions
93    INTERFACE
94        tfm_app_rot_partition_ps
95)
96
97target_compile_definitions(tfm_config
98    INTERFACE
99        TFM_PARTITION_PROTECTED_STORAGE
100)
101