x86: use CONFIG_SRAM_OFFSET instead of CONFIG_X86_KERNEL_OFFSET

This changes x86 to use CONFIG_SRAM_OFFSET instead of
arch-specific CONFIG_X86_KERNEL_OFFSET. This allows the common
MMU macro Z_BOOT_VIRT_TO_PHYS() and Z_BOOT_PHYS_TO_VIRT() to
function properly if we ever need to map the kernel into
virtual address space that does not have the same starting
physical address.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2021-02-20 11:11:24 -08:00 committed by Anas Nashif
commit d340afd456
3 changed files with 9 additions and 6 deletions

View file

@ -181,9 +181,8 @@ endif # FPU || X86_64
endmenu
config X86_KERNEL_OFFSET
int "Kernel offset from beginning of RAM"
default 1048576
config SRAM_OFFSET
default 0x100000 if X86_PC_COMPATIBLE
help
A lot of x86 that resemble PCs have many reserved physical memory
regions within the first megabyte. Specify an offset from the
@ -195,6 +194,9 @@ config X86_KERNEL_OFFSET
This value normally need to be page-aligned.
config KERNEL_VM_OFFSET
default 0x100000 if MMU
config MAX_IRQ_LINES
int "Number of IRQ lines"
default 128
@ -248,6 +250,7 @@ config X86_PC_COMPATIBLE
bool
default y
select ARCH_HAS_RESERVED_PAGE_FRAMES
select HAS_SRAM_OFFSET
help
Hidden option to signal building for PC-compatible platforms
with BIOS, ACPI, etc.

View file

@ -24,6 +24,6 @@ CONFIG_X86_KPTI=n
CONFIG_KERNEL_VM_SIZE=0x400000
CONFIG_KERNEL_VM_BASE=0x0
CONFIG_KERNEL_VM_OFFSET=0x100000
CONFIG_X86_KERNEL_OFFSET=0
CONFIG_SRAM_OFFSET=0
CONFIG_DEMAND_PAGING=y
CONFIG_BACKING_STORE_RAM=y

View file

@ -28,8 +28,8 @@
#define PHYS_RAM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_sram))
#define PHYS_RAM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_sram))
#define KERNEL_BASE_ADDR (PHYS_RAM_ADDR + CONFIG_X86_KERNEL_OFFSET)
#define KERNEL_RAM_SIZE (PHYS_RAM_SIZE - CONFIG_X86_KERNEL_OFFSET)
#define KERNEL_BASE_ADDR (PHYS_RAM_ADDR + CONFIG_SRAM_OFFSET)
#define KERNEL_RAM_SIZE (PHYS_RAM_SIZE - CONFIG_SRAM_OFFSET)
#ifdef CONFIG_XIP
/* "ROM" is flash, we leave rodata and text there and just copy in data.