# Copyright (c) 2016 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

menu "OS Support Library"

config ZVFS_OPEN_MAX
	int "Maximum number of open file descriptors"
	depends on ZVFS
	default 0
	help
	  Maximum number of open file descriptors, this includes
	  files, sockets, special devices, etc. If subsystems
	  specify ZVFS_OPEN_ADD_SIZE_* options, these will be added together
	  and the sum will be compared to the ZVFS_OPEN_MAX value.
	  If the sum is greater than the ZVFS_OPEN_MAX option (even if this
	  has the default 0 value), then the actual file descriptor count will be
	  rounded up to the sum of the individual requirements (unless the
	  ZVFS_OPEN_IGNORE_MIN option is enabled). If the final value, after
	  considering both this option as well as sum of the custom
	  requirements, ends up being zero, then no file descriptors will be
	  available.

config ZVFS_OPEN_IGNORE_MIN
	bool "Ignore the minimum fd count requirement"
	help
	  This option can be set to force setting a smaller file descriptor
	  count than what's specified by enabled subsystems. This can be useful
	  when optimizing memory usage and a more precise minimum fd count
	  is known for a given application.

config PRINTK_SYNC
	bool "Serialize printk() calls"
	default y if SMP && MP_MAX_NUM_CPUS > 1 && !(EFI_CONSOLE && LOG)
	help
	  When true, a spinlock will be taken around the output from a
	  single printk() call, preventing the output data from
	  interleaving with concurrent usage from another CPU or an
	  preempting interrupt.

config MPSC_PBUF
	bool "Multi producer, single consumer packet buffer"
	select TIMEOUT_64BIT
	help
	  Enable usage of mpsc packet buffer. Packet buffer is capable of
	  storing variable length packets in a circular way and operate directly
	  on the buffer memory.

config SPSC_PBUF
	bool "Single producer, single consumer packet buffer"
	help
	  Enable usage of spsc packet buffer. Packet buffer is capable of
	  storing variable length packets in a circular way and operate directly
	  on the buffer memory.

if SPSC_PBUF

choice SPSC_PBUF_CACHE_HANDLING
	prompt "Cache handling"
	default SPSC_PBUF_CACHE_ALWAYS if SPSC_PBUF_USE_CACHE && !SPSC_PBUF_NO_CACHE
	default SPSC_PBUF_CACHE_NEVER if !SPSC_PBUF_USE_CACHE && SPSC_PBUF_NO_CACHE
	default SPSC_PBUF_CACHE_FLAG

config SPSC_PBUF_CACHE_FLAG
	bool "Use cache flag"
	help
	  Use instance specific configuration flag for cache handling.

config SPSC_PBUF_CACHE_ALWAYS
	bool "Always handle cache"
	help
	  Handle cache writeback and invalidation for all instances. Option used
	  to avoid runtime check and thus reduce memory footprint. Beware! It shall
	  be used only if all packet buffer instances are used for data sharing
	  between cores.

config SPSC_PBUF_CACHE_NEVER
	bool "Never handle cache"
	help
	  Discar cache handling for all instances. Option used to avoid runtime
	  check and thus reduce memory footprint.

endchoice

config SPSC_PBUF_USE_CACHE
	bool

config SPSC_PBUF_NO_CACHE
	bool

if SPSC_PBUF_CACHE_FLAG || SPSC_PBUF_CACHE_ALWAYS

config SPSC_PBUF_REMOTE_DCACHE_LINE
	int "Remote cache line size"
	default 32
	help
	  If a packet buffer is used for data sharing between two cores then
	  this value should be set to the data cache line size of the remote core.
	  If local data cache line is detected at runtime then it should be
	  maximum of local and remote line size.

endif # SPSC_PBUF_CACHE_FLAG || SPSC_PBUF_CACHE_ALWAYS

config SPSC_PBUF_UTILIZATION
	bool "Track maximum utilization"
	help
	  When enabled, maximum utilization is tracked which can be used to
	  determine the size of the packet buffer.

endif # SPSC_PBUF

if MPSC_PBUF
config MPSC_CLEAR_ALLOCATED
	bool "Clear allocated packet"
	help
	  When enabled packet space is zeroed before returning from allocation.
endif

if SCHED_DEADLINE

config P4WQ_INIT_STAGE_EARLY
	bool "Early initialization of P4WQ threads"
	help
	  Initialize P4WQ threads early so that the P4WQ can be used on devices
	  initialization sequence.

endif

config REBOOT
	bool "Reboot functionality"
	help
	  Enable the sys_reboot() API. Enabling this can drag in other subsystems
	  needed to perform a "safe" reboot (e.g. to stop the system clock before
	  issuing a reset).

config RESET_ON_FATAL_ERROR
	bool "Reset the system when a fatal error occurs after printing relevant debug output"
	select REBOOT
	help
		Initiate a system reset when a fatal error would normally halt the system.

config HAS_POWEROFF
	bool
	help
	  Option to signal that power off functionality is implemented.

config POWEROFF
	bool "Power off functionality"
	depends on HAS_POWEROFF
	help
	  Enable support for system power off.

config BOOT_BANNER
	bool "Boot banner"
	default y
	select PRINTK
	help
	  This option outputs a banner to the console device at the end of boot.

config BOOT_BANNER_STRING
	string "Boot banner string"
	depends on BOOT_BANNER
	default "Booting Zephyr OS build"
	help
	  Use this option to set the boot banner.

config BOOT_DELAY
	int "Boot delay in milliseconds"
	depends on MULTITHREADING
	default 0
	help
	  This option delays bootup for the specified amount of
	  milliseconds. This is used to allow serial ports to get ready
	  before starting to print information on them during boot, as
	  some systems might boot to fast for a receiving endpoint to
	  detect the new USB serial bus, enumerate it and get ready to
	  receive before it actually gets data. A similar effect can be
	  achieved by waiting for DCD on the serial port--however, not
	  all serial ports have DCD.

config BOOT_CLEAR_SCREEN
	bool "Clear screen"
	help
	  Use this option to clear the screen before printing anything else.
	  Using a VT100 enabled terminal on the client side is required for this to work.

menuconfig BOOTARGS
	bool "Support bootargs"
	help
	  Enables bootargs support and passing them to main().

if BOOTARGS

config DYNAMIC_BOOTARGS
	bool "Support dynamic bootargs"
	help
	  Enables dynamic bootargs support.

config BOOTARGS_STRING
	string "static bootargs string"
	depends on !DYNAMIC_BOOTARGS
	help
	  Static bootargs string. It includes argv[0], so if its expected that it
	  contains executable name it should be put at the beginning of this string.

config BOOTARGS_ARGS_BUFFER_SIZE
	int "Size of buffer containing main arguments in bytes"
	default 1024
	help
	  Configures size of buffer containing all arguments passed to main.

endif # BOOTARGS

rsource "Kconfig.atomics"
rsource "Kconfig.cbprintf"
rsource "zvfs/Kconfig"
rsource "cpu_load/Kconfig"

endmenu
