# SPDX-License-Identifier: GPL-2.0-only

menuconfig FS_PSTORE
	select FS_LEGACY
	bool
	prompt "pstore fs support"
	help
	  Support for persistent storage to read data from the last crash, like
	  panic, dmesg and ftrace.

if FS_PSTORE

config FS_PSTORE_CONSOLE
	bool
	prompt "Log console messages"
	help
	  When the option is enabled, pstore will log console messages.

config FS_PSTORE_RAMOOPS
	bool
	depends on RELOCATABLE
	depends on ARM
	depends on OFTREE
	select REED_SOLOMON
	select REED_SOLOMON_ENC8
	select REED_SOLOMON_DEC8
	prompt "pstore RAM backend"
	help
	  Here the data is stored in a specific memory area that is neither
	  overwritten by barebox nor the kernel.

if FS_PSTORE_RAMOOPS

config FS_PSTORE_RAMOOPS_ALWAYS
	bool
	prompt "Enable pstore RAM backend without a device tree node"
	default y
	help
	  Enables the RAM backend for pstore automatically instead of
	  requiring an explicit "ramoops"-compatible node. barebox will
	  take care to fix up the device tree node into the kernel device
	  tree. This is skipped when barebox runs as EFI payload.

	  Opt out is possible by adding a ramoops-compatible node with
	  status = "disabled".

config FS_PSTORE_RAMOOPS_TEST
	bool
	prompt "Test RAM retention instead of storing records"
	help
	  Use the RAM area to test how much of it survives a reset instead
	  of for pstore: On every start, barebox compares the area against
	  a fixed pseudo-random pattern, reports how many bytes survived
	  and which ranges were lost, and then fills it with the pattern
	  again for the next reset.

	  The kernel only gets the area as reserved memory, so this also
	  covers resets triggered by the kernel. The first start after
	  power-on reports what survived with the power off.

	  pstore is not available with this option enabled.

config FS_PSTORE_RAMOOPS_RO
	bool
	default y
	prompt "pstore RAM backend read only"
	help
	  This keeps the old contents of the console area when barebox writes
	  its own console output to it, instead of erasing it first. Select
	  this if you want to see the same ramoops in the kernel.

	  Either way, barebox only resets an area when writing to it, never
	  when merely reading it.

config FS_PSTORE_RAMOOPS_SIZE
	int
	prompt "Size of the RAMOOPS area"
	default 2097152
	help
	  Size of the RAMOOPS area that is reserved. This is passed to the
	  kernel as well as argument. Default is 2MiB.

config FS_PSTORE_RAMOOPS_CONSOLE_SIZE
	int
	prompt "Size of the console area"
	default 131072 # 2^17
	range 4096 1073741824 # Random upper limitation of 1GiB
	help
	  Size of the RAMOOPS console area that is reserved. This is passed to
	  the kernel as well as argument. It should be a power of 2.

config FS_PSTORE_RAMOOPS_FTRACE_SIZE
	int
	prompt "Size of the ftrace area"
	default 131072 # 2^17
	range 4096 1073741824 # Random upper limitation of 1GiB
	help
	  Size of the RAMOOPS ftrace area that is reserved. This is passed to
	  the kernel as well as argument. It should be a power of 2.

config FS_PSTORE_RAMOOPS_PMSG_SIZE
	int
	prompt "Size of the userspace message area"
	default 131072 # 2^17
	range 4096 1073741824 # Random upper limitation of 1GiB
	help
	  Size of the RAMOOPS pmsg area that is reserved. This is passed to
	  the kernel as well as argument. It should be a power of 2.

config FS_PSTORE_RAMOOPS_RECORD_SIZE
	int
	prompt "Size of each oops area"
	default 131072 # 2^17
	range 4096 1073741824 # Random upper limitation of 1GiB
	help
	  Size of each RAMOOPS oops area. There are multiple oops/panic areas
	  to store individual oops/panic messages. This is the size of each of
	  these areas. It should be a power of 2.

config FS_PSTORE_ECC_SIZE
	int
	prompt "ECC size"
	default 16
	help
	  ECC size used. This is the amount of bytes for reed solomon codes
	  that is used. 0 disables ECC.

endif

endif
