menu "Kernel configuration"

        config KERNEL_TARGET_HAS_MMU
                bool
                prompt "Enable MMU support in the kernel" if TARGET_HAS_MMU
                default n
                help
                        Boolean to mark whether the target has an MMU/Memory Mapper. If this option is selected,
                        the target needs to have a memory mapping organized as 4 pages of 16KB. Each page can be
                        mapped to any 16KB of physical address space.
                        As such, when enabled, the target must implement an `mmu_h.asm` interface.

        config KERNEL_REPRODUCIBLE_BUILD
                bool "Generate a reproducible binary"
                default n
                help
                        When this option is enabled, compiling the project several times with
                        the same configuration will produce the exact same binary. Thus, information
                        like build time will be excluded from the binary.

        config KERNEL_STACK_ADDR
                hex "Kernel stack virtual address"
                default 0xFFFF
                range 0x0000 0xFFFF
                help
                        After initializing the MMU, the kernel will set the Stack Pointer (SP).
                        This value defines the top of the stack in the virtual memory. It is highly
                        advised to use the top of the usable RAM.
                        If the kernel has MMU support, this value will also be the user stack address.
                        Else, the user stack address will be KERNEL_BSS address minus 1.

        config KERNEL_RAM_START
                hex
                prompt "Kernel RAM start address" if !KERNEL_TARGET_HAS_MMU
                default 0xC000
                range 0x0000 0xFFFF
                help
                        When the kernel has no MMU support, this value must be set to beginning of the kernel usable RAM.
                        This space ends at KERNEL_STACK_ADDR. It will containt he BSS, drivers RAM and kernel stack.
                        The user programs stack will be set the the KERNEL_RAM_START - 1.
                        When the kernel has MMU support, this is not required as the kernel will take a whole a whole
                        virtual page: 16KB.

        config KERNEL_COLDBOOT_HOOK
                bool
                # If the target has already a hook installed, do not show this option
                prompt "Hook routine at coldboot" if !TARGET_HAS_COLDBOOT_HOOK
                default TARGET_HAS_COLDBOOT_HOOK
                help
                        When enabled, the kernel will call the routine named `target_coldboot` right
                        after initializing the MMU (if any) and setting up the stack.
                        This routine must be defined in the target code.

        config KERNEL_EXIT_HOOK
                bool
                prompt "Hook routine at program exit" if !TARGET_HAS_EXIT_HOOK
                default TARGET_HAS_EXIT_HOOK
                help
                        When enabled, the kernel will call the routine named `target_exit` right
                        after exiting a user program.
                        This routine must be defined in the target code.

        config KERNEL_DRIVERS_HOOK
                bool
                prompt "Hook routine called after drivers initialization" if !TARGET_HAS_DRIVERS_HOOK
                default TARGET_HAS_DRIVERS_HOOK
                help
                        When enabled, the kernel will call the routine named `target_drivers_hook` right
                        after the drivers initialization.
                        This routine must be defined in the target code.

        config KERNEL_MAX_NESTED_PROGRAMS
                int "Maximum number of nested programs"
                depends on KERNEL_TARGET_HAS_MMU
                default 3
                range 1 10
                help
                        When a program A performs an exec syscall to load program B in memory, it is possible
                        to save A so that it is resumed once B finishes executing.
                        This value represents the maximum depth of exec that can be performed recursively by
                        programs.
                        For example, if this value is set to 1, no program can be saved in RAM when performing an exec.
                        If this value is set to 2, A can exec B, but B cannot exec without being overwritten/covered.

        config KERNEL_MAX_LOADED_DRIVERS
                int "Maximum number of loaded drivers"
                default 16
                range 0 255
                help
                        Maximum number of drivers that can be loaded into the kernel.
                        This is valid for both loaded drivers at compile time and at runtime.
                        Must be a power of 2.

        config KERNEL_MAX_OPENED_DEVICES
                int "Maximum number of opened devices"
                default 16
                range 16 128
                help
                        Maximum number of opened devices for a program. This includes opened
                        drivers as well as opened files.

        config KERNEL_MAX_OPENED_FILES
                int "Maximum number of opened files"
                default 16
                range 16 128
                help
                        Maximum number of opened files at once. This only does not include opened
                        drivers.

        config KERNEL_PATH_MAX
                int "Maximum path length (files/directories)"
                default 128
                range 64 4096
                help
                        Maximum length of a single absolute file path. Incrementing this value will make
                        the kernel use more RAM.

        config KERNEL_INIT_EXECUTABLE
                string "Executable to launch on boot"
                default "A:/init.bin"
                help
                        Executable to load and execute on after system boot

        config KERNEL_INIT_EXECUTABLE_ADDR
                hex "Virtual address to load the initial program in"
                range 0x4000 0xFF00
                default 0x4000
                help
                        After the kernel has finished initializing all its components and its drivers,
                        it will load the KERNEL_INIT_EXECUTABLE in RAM. This constant defines the virtual
                        address where it will be loaded and executed from.

        config KERNEL_LOG_BOOT_MOUNTED_DISKS
                bool "Print the mounted disks in the boot banner"
                default y
                help
                        If this option is enabled, the kernel will print the disks that are mounted on boot.

        config KERNEL_ENABLE_ZEALFS_SUPPORT
                bool "Enable support for ZealFS file system"
                default y
                help
                        If this option is enabled, ZealFS support will be added to the kernel, thus, disks using
                        it can be mounted.
                        Disable this option if you don't have any disk using ZealFS or if you want to reduce
                        kernel size. (saves around 1.3KB)
endmenu