arch: add KERNEL_VM_OFFSET

This is only needed if the base address of SRAM doesn't
have the same alignment as the base address of the virtual
address space.

Fix the calculations on X86 where this is the case.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-12-17 23:37:47 -08:00 committed by Anas Nashif
commit 69355d13a8
2 changed files with 23 additions and 2 deletions

View file

@ -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

View file

@ -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 */