diff --git a/arch/Kconfig b/arch/Kconfig index 81918352ea6..5d099b993c9 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -577,6 +577,26 @@ config KERNEL_RAM_SIZE address space, and that these RAM mappings are all within the virtual region [KERNEL_VM_BASE..KERNEL_VM_BASE + KERNEL_RAM_SIZE). +config KERNEL_VM_OFFSET + hex "Kernel offset within address space" + default 0 + help + Offset that the kernel image begins within its address space, + if this is not the same offset from the beginning of RAM. + + Some care may need to be taken in selecting this value. In certain + build-time cases, or when a physical address cannot be looked up + in page tables, the equation: + + virt = phys + ((KERNEL_VM_BASE + KERNEL_VM_OFFSET) - + SRAM_BASE_ADDRESS) + + Will be used to convert between physical and virtual addresses for + memory that is mapped at boot. + + This uncommon and is only necessary if the beginning of VM and + physical memory have dissimilar alignment. + config KERNEL_VM_SIZE hex "Size of kernel address space in bytes" default 0xC0000000 diff --git a/arch/x86/include/x86_mmu.h b/arch/x86/include/x86_mmu.h index c4c80753838..52084858ec8 100644 --- a/arch/x86/include/x86_mmu.h +++ b/arch/x86/include/x86_mmu.h @@ -81,9 +81,10 @@ * walking and creating page tables. */ #ifdef CONFIG_MMU -#define Z_X86_VIRT_OFFSET (CONFIG_KERNEL_VM_BASE - CONFIG_SRAM_BASE_ADDRESS) +#define Z_X86_VIRT_OFFSET ((CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) - \ + CONFIG_SRAM_BASE_ADDRESS) #else -#define Z_X86_VIRT_OFFSET 0 +#define Z_X86_VIRT_OFFSET 0 #endif /* ASM code */