1# Copyright (c) 2024 Nordic Semiconductor
2# SPDX-License-Identifier: Apache-2.0
3
4choice SECURE_STORAGE_ITS_STORE_IMPLEMENTATION
5	prompt "ITS store module implementation"
6
7DT_ITS_PARTITION := $(dt_chosen_path,secure_storage_its_partition)
8DT_CHOSEN_Z_SETTINGS_PARTITION := zephyr,settings-partition
9DT_SETTINGS_PARTITIION := $(dt_chosen_path,$(DT_CHOSEN_Z_SETTINGS_PARTITION))
10DT_STORAGE_PARTITION := $(dt_nodelabel_path,storage_partition)
11
12config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_ZMS
13	bool "ITS store module implementation using ZMS for storage"
14	depends on FLASH_HAS_DRIVER_ENABLED \
15	 && $(dt_path_enabled,$(DT_ITS_PARTITION)) \
16	 && $(dt_node_has_compat,$(dt_node_parent,$(DT_ITS_PARTITION)),fixed-partitions)
17	select ZMS
18	help
19	  This implementation of the ITS store module makes direct use of ZMS for storage.
20	  It needs a `secure_storage_its_partition` devicetree chosen property that points
21	  to a fixed storage partition that will be dedicated to the ITS. It has lower
22	  overhead compared to the settings-based implementation, both in terms of runtime
23	  execution and storage space, and also ROM footprint if the settings subsystem is disabled.
24	  As this implementations directly maps the PSA storage UIDs to ZMS entry IDs, it limits
25	  their values to the first 30 bits.
26
27config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_SETTINGS
28	bool "ITS store module implementation using the settings subsystem for storage"
29	depends on FLASH_HAS_DRIVER_ENABLED \
30	 && (($(dt_path_enabled,$(DT_SETTINGS_PARTITIION)) \
31	     && $(dt_node_has_compat,$(dt_node_parent,$(DT_SETTINGS_PARTITIION)),fixed-partitions))\
32	  || ($(dt_path_enabled,$(DT_STORAGE_PARTITION)) \
33	      && $(dt_node_has_compat,$(dt_node_parent,$(DT_STORAGE_PARTITION)),fixed-partitions)))
34	imply FLASH_MAP
35	imply NVS
36	select SETTINGS
37
38config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_NONE
39	bool "No ITS store module implementation"
40
41config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_CUSTOM
42	bool "Custom ITS store module implementation"
43	help
44	  Implement the functions declared in <zephyr/secure_storage/its/store.h>.
45	  The header is made available when this Kconfig option is enabled.
46
47endchoice # SECURE_STORAGE_ITS_STORE_IMPLEMENTATION
48
49if SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_ZMS
50
51config SECURE_STORAGE_ITS_STORE_ZMS_SECTOR_SIZE
52	int "Sector size of the ZMS partition"
53	default 4096
54	help
55	  The sector size impacts the runtime behavior of ZMS and restricts the maximum
56	  ITS entry data size (which is the sector size minus ZMS and ITS overhead).
57	  Changing it will result in loss of existing data stored on a partition.
58	  It must be a multiple of the flash page size on devices that require an erase.
59	  See the ZMS documentation for more information.
60
61endif # SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_ZMS
62
63if SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_SETTINGS
64
65config SECURE_STORAGE_ITS_STORE_SETTINGS_PREFIX
66	string "Subtree in which to store the settings, with a trailing slash. Can be empty."
67	default "its/"
68
69endif # SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_SETTINGS
70