# Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.

# SPDX-License-Identifier: MIT

config KERNEL
	bool "RTOS Kernel"
	default y
	help
	  Enable RTOS kernel.

if KERNEL

config KERNEL_ARCH_DIR
	string
	default "AML_ARM_64_BIT" if ARM64 && GIC_V2
	default "AML_ARM_64_BIT_SRE" if ARM64 && GIC_V3
	default "AML_ARM_32_BIT" if ARM
	default "AML_RISC-V" if RISCV
	default "AML_Xtensa" if XTENSA
	help
	  System arch dir string.


config KERNEL_COMPILER_DIR
	string
	default "GCC" if ARM || ARM64
	default "GCC" if RISCV
	default "XCC" if XTENSA
	help
	  System compiler dir string.

config DMALLOC
	bool "Debug Memory Allocation"
	help
	  Enable the memory allocation statistics of tasks.

if DMALLOC
config DMALLOC_SIZE
	hex "Debug Memory Allocation Buffer Size"
	default 128
	help
	  Set the buffer size of memory allocation statistics.
endif # DMALLOC

config MEMORY_ERROR_DETECTION
	bool "Memory Error Detection"
	help
	  Enable detecting out-of-bounds access, memory leaks.

if MEMORY_ERROR_DETECTION
config MEMORY_ERROR_DETECTION_SIZE
	hex "Memory Error Detection Buffer Size"
	default 1000
	help
	  Indicates that the MED tool can track the maximum number of malloc nodes.

config MEMORY_ERROR_DETECTION_PRINT
	bool "Memory Error Detection Print"
	help
	  Print details of memory error field.

config MEMORY_ERROR_DETECTION_FREE_BLOCK
	bool "Free Block Memory Error Detection"
	help
	  Enables integrity checks for free memory blocks and helps detect
	  use-after-free errors during memory operations.

config MEMORY_ERROR_DETECTION_FREE_BLOCK_ENHANCE
	bool "Enhanced Free Block Memory Error Detection"
	depends on MEMORY_ERROR_DETECTION_FREE_BLOCK
	help
	  This feature introduces additional runtime overhead due to the
	  per-free validation process. On memory-constrained or performance-sensitive
	  systems, enabling this option may lead to increased execution time or
	  even program instability.

config MEMORY_ERROR_DETECTION_BACKTRACE
	bool "Memory Error Detection Backtrace"
	depends on BACKTRACE
	help
	  Integrate node backtrace information into the Memory Error Detection.

config MEMORY_ERROR_DETECTION_STATIC_SUPPORT
	bool "Memory Error Detection static region scan"
	help
	  Memory leak detection tool support scanning the .bss and .data sections.

config MEMORY_ERROR_DETECTION_BENCHMARKS
	bool "Memory Error Detection Benchmarks Test"
	help
	  Memory error detection tool performance test.
endif # MEMORY_ERROR_DETECTION

choice
	prompt "Choose heap strategy type"
	default KERNEL_HEAP_TYPE_5  if ARM || ARM64 || RISCV
	default KERNEL_HEAP_TYPE_4  if XTENSA
	help
	  Set kernel heap strategy type:
	  Chose the heap type in your project config file if you want to change default type.
	  Type 1-5 if from original kernel,type 4_comm is only for comm project.
	  Default value is set by arch value.

config KERNEL_HEAP_TYPE_1
	bool "Heap strategy type 1"
	help
	  Use heap strategy type 1.
config KERNEL_HEAP_TYPE_2
	bool "Heap strategy type 2"
	help
	  Use heap strategy type 2.
config KERNEL_HEAP_TYPE_3
	bool "Heap strategy type 3"
	help
	  Use heap strategy type 3.
config KERNEL_HEAP_TYPE_4
	bool "Heap strategy type 4"
	help
	  Use heap strategy type 4.
config KERNEL_HEAP_TYPE_5
	bool "Heap strategy type 5"
	help
	  Use heap strategy type 5.
config KERNEL_HEAP_TYPE_4_COMM
	bool "Heap strategy type 4 of COMM"
	help
	  Use heap strategy type 4 of comm.
endchoice

endif # KERNEL
