# Kconfig - debug configuration options

#
# Copyright (c) 2015 Wind River Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


menu "Safe memory access"

config MEM_SAFE
	bool
	prompt "Enable safe memory access"
	default n
	help
	Add the routines available in mem_safe.h to the system. This is added as a
	kconfig option instead of simply linking against the library because some
	implementations might require initialization.

choice
prompt "Safe memory access implementation"
default MEM_SAFE_CHECK_BOUNDARIES

config MEM_SAFE_CHECK_BOUNDARIES
	bool
	prompt "Software validation of memory access within memory regions"
	help
	This implementation checks the application image's text/rodata boundaries
	for its read-only region and the data/bss/noinit boundaries for its
	read-write region, in software.

	Other regions can be added as needed by using the sys_mem_safe_region_add()
	API. The number of regions that can be added is controlled via the
	MEM_SAFE_NUM_REGIONS kconfig option.

	This implementation requires initialization and thus consumes some boot
	time.

endchoice

config MEM_SAFE_NUM_EXTRA_REGIONS
	int
	prompt "Number of safe memory access regions that can be added at runtime"
	depends on MEM_SAFE_CHECK_BOUNDARIES
	default 0
	help
	The functions available in mem_safe.h check if memory is within read-only
	or read-write regions before accessing it instead of crashing. The kernel
	image is added as a valid region automatically, but other regions can be
	added if the application makes access to additional memory outside of the
	image's boundaries.

endmenu
