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.15)
13cmake_policy(SET CMP0079 NEW)
14
15add_library(tfm_app_rot_partition_ps STATIC)
16
17add_dependencies(tfm_app_rot_partition_ps manifest_tool)
18
19target_include_directories(tfm_app_rot_partition_ps
20    INTERFACE
21        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
22    PRIVATE
23        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/protected_storage
24)
25target_include_directories(tfm_partitions
26    INTERFACE
27        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/protected_storage
28)
29
30target_sources(tfm_app_rot_partition_ps
31    PRIVATE
32        tfm_ps_req_mngr.c
33        tfm_protected_storage.c
34        ps_object_system.c
35        ps_object_table.c
36        ps_utils.c
37        $<$<BOOL:${PS_ENCRYPTION}>:crypto/ps_crypto_interface.c>
38        $<$<BOOL:${PS_ENCRYPTION}>:ps_encrypted_object.c>
39        # The test_ps_nv_counters.c will be used instead, when PS secure test is
40        # ON and PS_TEST_NV_COUNTERS is ON
41        $<$<NOT:$<AND:$<BOOL:${TEST_S_PS}>,$<BOOL:${PS_TEST_NV_COUNTERS}>>>:nv_counters/ps_nv_counters.c>
42)
43
44if (NOT TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
45    set(PS_FILESYSTEM_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../internal_trusted_storage)
46
47    target_include_directories(tfm_app_rot_partition_ps
48        PRIVATE
49            ${PS_FILESYSTEM_SOURCE_PATH}
50    )
51
52    target_sources(tfm_app_rot_partition_ps
53        PRIVATE
54            ps_filesystem_interface.c
55            ${PS_FILESYSTEM_SOURCE_PATH}/tfm_internal_trusted_storage.c
56            ${PS_FILESYSTEM_SOURCE_PATH}/its_utils.c
57            ${PS_FILESYSTEM_SOURCE_PATH}/flash/its_flash.c
58            ${PS_FILESYSTEM_SOURCE_PATH}/flash/its_flash_nand.c
59            ${PS_FILESYSTEM_SOURCE_PATH}/flash/its_flash_nor.c
60            ${PS_FILESYSTEM_SOURCE_PATH}/flash/its_flash_ram.c
61            ${PS_FILESYSTEM_SOURCE_PATH}/flash_fs/its_flash_fs.c
62            ${PS_FILESYSTEM_SOURCE_PATH}/flash_fs/its_flash_fs_dblock.c
63            ${PS_FILESYSTEM_SOURCE_PATH}/flash_fs/its_flash_fs_mblock.c
64    )
65endif()
66
67# The generated sources
68target_sources(tfm_app_rot_partition_ps
69    PRIVATE
70        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/protected_storage/auto_generated/intermedia_tfm_protected_storage.c
71)
72target_sources(tfm_partitions
73    INTERFACE
74        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/protected_storage/auto_generated/load_info_tfm_protected_storage.c
75)
76
77target_link_libraries(tfm_app_rot_partition_ps
78    PRIVATE
79        secure_fw
80        platform_s
81        tfm_config
82        tfm_sprt
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