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

rsource "provisioning/Kconfig"

menuconfig SUIT
	bool "Enable SUIT modules"

if SUIT

config SUIT_DFU
	bool "Enable SUIT DFU - the interface for SUIT for the user application"
	depends on !SUIT_PLATFORM_VARIANT_SDFW
	default y if !ZTEST

choice SUIT_PLATFORM_VARIANT
	prompt "SUIT platform implementation variant"
	default SUIT_PLATFORM_VARIANT_APP if !ZTEST

config SUIT_PLATFORM_VARIANT_SDFW
	bool "Set SUIT platform variant to Secure domain"

config SUIT_PLATFORM_VARIANT_APP
	bool "Set SUIT platform variant to application domain"

endchoice # SUIT_PLATFORM_VARIANT

if SUIT_DFU

choice SUIT_DFU_CANDIDATE_PROCESSING_LEVEL
	prompt "Select the level of SUIT candidate processing inside the user application"

config SUIT_DFU_CANDIDATE_PROCESSING_MINIMAL
	bool "Application defaults for minimal SUIT candidate processing"
	help
		This configuration can be used to allow update using SUIT when no interpretation
		of the SUIT envelope is needed by the local domain apart from basic format checking.
		This is equivalent to a situation where it is known that none of the manifests
		(the top manifest nor its dependencies) contains a suit-payload-fetch sequence.
		The only role of the application core is store the SUIT candidate envelope
		followed by passing the control to the Secure Domain.
	imply SUIT_ORCHESTRATOR_APP
	imply SUIT_ORCHESTRATOR_APP_CANDIDATE_PROCESSING
	imply SUIT_ENVELOPE_INFO
	imply SUIT_UTILS
	imply SUIT_METADATA
	imply SSF_SUIT_SERVICE_ENABLED
	imply SUIT_MPI_GENERATE

config SUIT_DFU_CANDIDATE_PROCESSING_FULL
	bool "Application defaults for support of full SUIT envelope processing by the local domain"
	help
		This configuration can be used if processing of the SUIT envelope is needed by the
		local domain. This is equivalent to a situation where one of the manifests
		(the top manifest or its dependencies) may contain a suit-payload-fetch sequence.
		Before passing control to the Secure Domain, the local domain implementation of
		the SUIT DFU module processes the envelope and fetches any additional needed
		data using the registered fetch sources.
	imply SUIT_ORCHESTRATOR_APP
	imply SUIT_ORCHESTRATOR_APP_CANDIDATE_PROCESSING
	imply SUIT_ENVELOPE_INFO
	imply SUIT_UTILS
	imply SUIT_DIGEST
	imply SUIT_CRYPTO
	imply SSF_SUIT_SERVICE_ENABLED
	imply SUIT_PLAT_CHECK_COMPONENT_COMPATIBILITY
	imply SUIT_PLAT_CHECK_CLASSES
	imply SUIT_METADATA
	imply SUIT_CHECK_IMAGE_MATCH
	imply SUIT_STREAM
	imply SUIT_STREAM_FETCH_SOURCE_MGR
	imply SUIT_STREAM_SOURCE_CACHE
	imply SUIT_STREAM_SOURCE_MEMPTR
	imply SUIT_STREAM_SINK_DIGEST
	imply SUIT_STREAM_SINK_MEMPTR
	imply SUIT_CACHE
	imply SUIT_CACHE_RW
	imply SUIT_STREAM_SINK_CACHE
	imply SUIT_STREAM_SINK_FLASH
	imply SUIT_MEMPTR_STORAGE
	imply SUIT_PLATFORM
	imply SUIT_PROCESSOR
	imply SUIT_MPI_GENERATE
	imply SUIT_SINK_SELECTOR

config SUIT_DFU_CANDIDATE_PROCESSING_NONE
	bool "Disable any processing of the SUIT candidate envelope"
	help
		If this configuration is used no processing of the SUIT envelope will be performed.
		It will not be possible to start the update from inside the application using the
		SUIT DFU API.
		In a general use case this Kconfig option will only be use for companion images
		used by the Secure Domain to fetch additional data with the use of the application
		core.
	imply SUIT_ORCHESTRATOR_APP
	imply SUIT_MPI_GENERATE

endchoice # SUIT_APP_ENVELOPE_PROCESSING_LEVEL

config SUIT_STREAMING_REQUESTS_FROM_SDFW_SUPPORT
	bool "Enable support for streaming requests coming from SDFW"
	help
		In some cases when the Secure Domain processes the SUIT manifests may need to fetch
		additional data from outside the device. As the Secure Domain does not have access
		to any transport it needs to communicate with an application (a "companion image")
		running on one of the local domains to fetch data.
		Setting this Kconfig option will enable all the modules needed for
		such a local domain application.
		The implementer of this application needs to initialize the needed subsystems
		using suit_dfu_initialize and register transports as fetch sources.
	imply SUIT_ORCHESTRATOR_APP
	imply SUIT_UTILS
	imply SUIT_METADATA
	imply SSF_SUIT_SERVICE_ENABLED
	imply SUIT_STREAM_FETCH_SOURCE_MGR
	imply SUIT_STREAM_SOURCE_IPC
	imply SUIT_STREAM
	imply SUIT_STREAM_IPC_PROVIDER

endif # SUIT_DFU

config SUIT_ENABLE_DEFAULTS_SDFW
	bool "SDFW SUIT defaults"
	imply SUIT_CRYPTO
	imply SUIT_DEVCONFIG
	imply SUIT_PLAT_CHECK_COMPONENT_COMPATIBILITY
	imply SUIT_PLAT_CHECK_CLASSES
	imply SUIT_AUTHENTICATE
	imply SUIT_DIGEST
	imply SUIT_DIGEST_CACHE
	imply SUIT_CHECK_IMAGE_MATCH
	imply SUIT_MCI
	imply SUIT_METADATA
	imply SUIT_ORCHESTRATOR
	imply SUIT_PLATFORM
	imply SUIT_STREAM
	imply SUIT_STREAM_SINK_MEMPTR
	imply SUIT_STREAM_SINK_FLASH
	imply SUIT_STREAM_SINK_DIGEST
	imply SUIT_STREAM_SINK_RAM
	imply SUIT_STREAM_SINK_SDFW
	imply SUIT_STREAM_SINK_SDFW_RECOVERY
	imply SUIT_STREAM_SOURCE_CACHE
	imply SUIT_STREAM_SOURCE_MEMPTR
	imply SUIT_STREAM_SOURCE_IPC
	imply SUIT_STREAM_IPC_REQUESTOR
	imply SUIT_MEMPTR_STORAGE
	imply SUIT_UTILS
	imply SUIT_CACHE
	imply SUIT_STORAGE
	imply SUIT_SINK_SELECTOR
	imply SUIT_EXECUTION_MODE
	imply SUIT_UPDATE_REBOOT_ENABLED
	imply SUIT_BOOT_RECOVERY_REBOOT_ENABLED

config SUIT_ENABLE_DEFAULTS_SDFW_EXTMEM
	bool "SDFW SUIT defaults with external flash support"
	depends on SUIT_PLATFORM_VARIANT_SDFW
	imply SUIT_STREAM_SOURCE_EXTMEM
	imply SUIT_STREAM_SINK_EXTMEM
	imply SSF_EXTMEM_SERVICE_ENABLED

rsource "cache/Kconfig"
rsource "mci/Kconfig"
rsource "metadata/Kconfig"
rsource "storage/Kconfig"
rsource "orchestrator/Kconfig"
rsource "orchestrator_app/Kconfig"
rsource "memptr_storage/Kconfig"
rsource "platform/Kconfig"
rsource "stream/Kconfig"
rsource "utils/Kconfig"
rsource "envelope_info/Kconfig"
rsource "execution_mode/Kconfig"
rsource "memory_layout/Kconfig"

# Configure SUIT_LOG_LEVEL
module = SUIT
module-str = Software Updates for Internet of Things
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"

endif # SUIT
