#
# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

menuconfig SUIT_STREAM
	bool "Enable SUIT stream module"

if SUIT_STREAM

config SUIT_STREAM_SINK_COMPONENT_MEM_SUPPORTED
	bool
	help
	  Helper symbol indicating that a sink backend
	  for MEM component is implemented.

config SUIT_STREAM_SINK_CACHE
	bool "Enable SUIT cache sink"
	depends on SUIT_CACHE_RW
	depends on SUIT_STREAM_SINK_FLASH

config SUIT_STREAM_SINK_MEMPTR
	bool "Enable memory pointer storage sink"
	depends on SUIT_MEMPTR_STORAGE

config SUIT_STREAM_SINK_FLASH
	bool "Enable NVM storage sink"
	depends on FLASH
	depends on SUIT_UTILS
	depends on SUIT_MEMPTR_STORAGE
	select SUIT_STREAM_SINK_COMPONENT_MEM_SUPPORTED

config SUIT_STREAM_SINK_RAM
	bool "Enable RAM buffer sink"
	select SUIT_STREAM_SINK_COMPONENT_MEM_SUPPORTED

config SUIT_STREAM_SINK_EXTMEM
	bool "Enable external memory sink"
	select SUIT_STREAM_SINK_COMPONENT_MEM_SUPPORTED

menuconfig SUIT_STREAM_SINK_SDFW
	bool "Enable SDFW sink"
	depends on SUIT_UTILS
	depends on SOC_SERIES_NRF54HX
	select PSA_WANT_ALG_SHA_512
	select SUIT_STREAM_SINK_DIGEST

if SUIT_STREAM_SINK_SDFW

config SUIT_SDFW_UPDATE_SIGNED_MANIFEST_OFFSET
	hex "Offset between start of the SDFW update candidate image and Signed Manifest section"
	default 0

config SUIT_SDFW_UPDATE_DIGEST_OFFSET
	hex "Offset between start of the SDFW update candidate image and SM.TBS.FW.DIGEST section"
	default 0x20

config SUIT_SDFW_UPDATE_PUBLIC_KEY_OFFSET
	hex "Offset between start of the SDFW update candidate image and Public Key section"
	default 0x100

config SUIT_SDFW_UPDATE_SIGNATURE_OFFSET
	hex "Offset between start of the SDFW update candidate image and Signature section"
	default 0x120

config SUIT_SDFW_UPDATE_FIRMWARE_OFFSET
	hex "Offset between start of the SDFW update candidate image and Firmware section"
	default 0x160

config SUIT_SDFW_UPDATE_MAX_SIZE
	hex "Maximum size of SDFW update"
	range 0x00000080 0x000FD000
	default 0x000FD000
	help
	  Range is based on documentation of register UROT.SM.TBS.LAYOUT.USLOT.MAX

endif # SUIT_STREAM_SINK_SDFW

menuconfig SUIT_STREAM_SINK_SDFW_RECOVERY
	bool "Enable SDFW Recovery sink"
	depends on SUIT_UTILS
	depends on SOC_SERIES_NRF54HX
	select PSA_WANT_ALG_SHA_512
	select SUIT_STREAM_SINK_DIGEST

if SUIT_STREAM_SINK_SDFW_RECOVERY

config SUIT_SDFW_RECOVERY_UPDATE_SIGNED_MANIFEST_OFFSET
	hex "Offset between start of the SDFW Recovery update candidate image and Signed Manifest section"
	default 0

config SUIT_SDFW_RECOVERY_UPDATE_DIGEST_OFFSET
	hex "Offset between start of the SDFW Recovery update candidate image and SM.TBS.FW.DIGEST section"
	default 0x20

config SUIT_SDFW_RECOVERY_UPDATE_PUBLIC_KEY_OFFSET
	hex "Offset between start of the SDFW Recovery update candidate image and Public Key section"
	default 0x100

config SUIT_SDFW_RECOVERY_UPDATE_SIGNATURE_OFFSET
	hex "Offset between start of the SDFW Recovery update candidate image and Signature section"
	default 0x120

config SUIT_SDFW_RECOVERY_UPDATE_FIRMWARE_OFFSET
	hex "Offset between start of the SDFW Recovery update candidate image and Firmware section"
	default 0x160

config SUIT_SDFW_RECOVERY_UPDATE_MAX_SIZE
	hex "Maximum size of SDFW Recovery update"
	range 0x00000080 0x000FD000
	default 0x000FD000
	help
	  Range is based on documentation of register UROT.SM.TBS.LAYOUT.RSLOT.MAX

endif # SUIT_STREAM_SINK_SDFW_RECOVERY

config SUIT_STREAM_SINK_DIGEST
	bool "Enable digest sink"
	select PSA_WANT_ALG_SHA_256 if SOC_FAMILY_NORDIC_NRF

if SUIT_STREAM_SINK_DIGEST
	config SUIT_STREAM_SINK_DIGEST_CONTEXT_COUNT
	int "Maximum number of contexts"
	default 1
endif # SUIT_STREAM_SINK_DIGEST

config SUIT_STREAM_SOURCE_CACHE
	bool "Enable SUIT cache source"
	depends on SUIT_CACHE

config SUIT_STREAM_SOURCE_MEMPTR
	bool "Enable memory pointer storage source"

config SUIT_STREAM_FETCH_SOURCE_MGR
	bool "Fetch source manager"

config SUIT_STREAM_FETCH_MAX_SOURCES
	int "The maximum number of fetch sources to be able to be registered by fetch source manager"
	default 3
	depends on SUIT_STREAM_FETCH_SOURCE_MGR

config SUIT_STREAM_SOURCE_EXTMEM
	bool "Enable external memory storage source"

config SUIT_STREAM_SOURCE_FLASH
	bool "Enable flash memory storage source"
	depends on FLASH

menuconfig SUIT_STREAM_SOURCE_IPC
	bool "Enable feeding images from external sources to SDFW"

if SUIT_STREAM_SOURCE_IPC

config SUIT_STREAM_IPC_REQUESTOR
	bool "Part of functionality executed in SDFW"

config SUIT_STREAM_IPC_REQUESTOR_MAX_CHUNKS
	int "The maximum number of image chunks simultaneously enqueable by requestor"
	default 3
	depends on SUIT_STREAM_IPC_REQUESTOR

config SUIT_STREAM_IPC_PROVIDER
	bool "Part of functionality executed on App Core"
	depends on SUIT_STREAM_FETCH_SOURCE_MGR

config SUIT_STREAM_IPC_PROVIDER_BUFFERS
	int "The number of buffers supported by provider. For optimal performance should be equal to CONFIG_SUIT_STREAM_IPC_REQUESTOR_MAX_CHUNKS"
	default 3
	depends on SUIT_STREAM_IPC_PROVIDER

config SUIT_STREAM_IPC_PROVIDER_BUFFER_SIZE
	int "Size of single buffer in bytes"
	default 8192
	depends on SUIT_STREAM_IPC_PROVIDER

config SUIT_STREAM_IPC_STREAMER_REQUESTING_PERIOD
	int "Image request repetition period in milliseconds"
	range 100 10000
	default 1000

config SUIT_STREAM_IPC_STREAMER_CHUNK_TIMEOUT
	int "Max streamer provider inactivity before timeout in milliseconds"
	range 1000 60000
	default 10000

endif # SUIT_STREAM_SOURCE_IPC

endif # SUIT_STREAM
