#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

comment "ARMv8-M Configuration Options"

config ARMV8M_HAVE_ICACHE
	bool
	default n

config ARMV8M_HAVE_DCACHE
	bool
	default n

config ARMV8M_ICACHE
	bool "Use I-Cache"
	default n
	depends on ARMV8M_HAVE_ICACHE
	select ARCH_ICACHE

config ARMV8M_DCACHE
	bool "Use D-Cache"
	default n
	depends on ARMV8M_HAVE_DCACHE
	select ARCH_DCACHE

config ARMV8M_DCACHE_WRITETHROUGH
	bool "D-Cache Write-Through"
	default n
	depends on ARMV8M_DCACHE

config ARMV8M_HAVE_ITCM
	bool
	default n

config ARMV8M_HAVE_DTCM
	bool
	default n

config ARMV8M_ITCM
	bool "Use ITCM"
	default n
	depends on ARMV8M_HAVE_ITCM

config ARMV8M_DTCM
	bool "Use DTCM"
	default n
	depends on ARMV8M_HAVE_DTCM

config ARMV8M_TARGET2_PREL
	bool "R_ARM_TARGET2 is PC relative"
	default CXX_EXCEPTION
	depends on LIBC_ARCH_ELF
	---help---
		Perform a PC relative relocation for relocation type R_ARM_TARGET2

choice
	prompt "Select the stack protection Schema"
	default ARMV8M_STACKCHECK_HARDWARE if DEBUG_FEATURES
	default ARMV8M_STACKCHECK_NONE

config ARMV8M_STACKCHECK_NONE
	bool "Do not check for stack overflow"

config ARMV8M_STACKCHECK
	bool "Check for stack overflow on each function call"
	---help---
		This check uses R10 to check for a stack overflow within each
		function call. This has performances and code size impacts, but it
		will be able to catch hard to find stack overflows.

		Currently only available only for the STM32, SAM3/4 and SAMA5D
		architectures.  The changes are not complex and patches for
		other architectures will be accepted.

		This option requires that you are using a GCC toolchain and that
		you also include -finstrument-functions in your CFLAGS when you
		compile.  This addition to your CFLAGS should probably be added
		to the definition of the CFFLAGS in your board Make.defs file.

config ARMV8M_STACKCHECK_HARDWARE
	bool "Check for stack overflow by stack pointer limit register"
	---help---
		This option signifies the CPU has the MSPLIM, PSPLIM registers.

		The stack pointer limit registers, MSPLIM, PSPLIM, limit the
		extend to which the Main and Process Stack Pointers, respectively,
		can descend. MSPLIM, PSPLIM are always present in ARMv8-M
		MCUs that implement the ARMv8-M Main Extension (Mainline).

		In an ARMv8-M Mainline implementation with the Security Extension
		the MSPLIM, PSPLIM registers have additional Secure instances.
		In an ARMv8-M Baseline implementation with the Security Extension
		the MSPLIM, PSPLIM registers have only Secure instances.

endchoice

config ARMV8M_STACKCHECK_BREAKPOINT
	bool "Breakpoint on stack overflow"
	default n
	depends on ARMV8M_STACKCHECK
	---help---
		If enabled, a hard-coded breakpoint will be inserted to the stack
		overflow trap. This is useful to stop the execution of the program
		and diagnose the issue before the hardfault handler is called (and
		context information is lost).

config ARMV8M_ITMSYSLOG
	bool "ITM SYSLOG support"
	default n
	select SYSLOG_REGISTER
	---help---
		Enable hooks to support ITM syslog output.  This requires additional
		MCU support in order to be used.  See arch/arm/src/armv8-m/itm_syslog.h
		for additional initialization information.

if ARMV8M_ITMSYSLOG

config ARMV8M_ITMSYSLOG_PORT
	int "ITM SYSLOG Port"
	default 0
	range 0 31

config ARMV8M_ITMSYSLOG_SWODIV
	int "ITM SYSLOG SWO divider"
	default 15
	range 1 8192

endif # ARMV8M_ITMSYSLOG

config ARMV8M_SYSTICK
	bool "SysTick timer driver"
	depends on TIMER
	---help---
		Enable SysTick timer driver.

config ARMV8M_TRUSTZONE_HYBRID
	bool "Hybrid with secure and non-secure."
	default n
	depends on SMP
	---help---
		Enable the hybrid with secure and non-secure domain.
		In SMP mode, you can enable this configuration when one
		core supports secure and the other does not.

config ARMV8M_TRUSTZONE_CPU_BITMASK
	hex "Security support bitmap for multicore."
	depends on ARMV8M_TRUSTZONE_HYBRID
	default 0
	---help---
		Set Security bitmap for multicore, bit 0 means core 0.

config ARMV8M_CMSE
	bool "ARMv8-M Security Extensions"
	---help---
		Enable ARMv8-M Security Extensions.
