x86: intel64: set up memory sections

Some linker symbols indicating the bounds of various memory
areas needed for setting up boot MMU regions are now in
place.

MMU_BOOT_REGION macros added to align the bounds of these
sections if we're using runtime page tables.

_image_rodata_start moved to the proper place, it was not
accounting for the rodata sections specified in
linker/common_rom.ld.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2019-10-18 13:47:44 -07:00 committed by Andrew Boie
commit 8ec765b0bf

View file

@ -12,6 +12,13 @@
#define ROMABLE_REGION RAM #define ROMABLE_REGION RAM
#define RAMABLE_REGION RAM #define RAMABLE_REGION RAM
#ifdef CONFIG_X86_MMU
#define MMU_PAGE_SIZE KB(4)
#define MMU_PAGE_ALIGN . = ALIGN(MMU_PAGE_SIZE);
#else
#define MMU_PAGE_ALIGN
#endif
ENTRY(CONFIG_KERNEL_ENTRY) ENTRY(CONFIG_KERNEL_ENTRY)
SECTIONS SECTIONS
@ -27,11 +34,14 @@ SECTIONS
_locore_start = .; _locore_start = .;
*(.locore) *(.locore)
*(.locore.*) *(.locore.*)
MMU_PAGE_ALIGN
_lorodata_start = .; _lorodata_start = .;
*(.lorodata) *(.lorodata)
MMU_PAGE_ALIGN
_lodata_start = .; _lodata_start = .;
*(.tss) *(.tss)
*(.lodata) *(.lodata)
MMU_PAGE_ALIGN
_lodata_end = .; _lodata_end = .;
} }
@ -47,16 +57,20 @@ SECTIONS
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,ALIGN(16)) SECTION_PROLOGUE(_TEXT_SECTION_NAME,,ALIGN(16))
{ {
_image_rom_start = .; _image_rom_start = .;
_image_text_start = .;
*(.text) *(.text)
*(.text.*) *(.text.*)
MMU_PAGE_ALIGN
} GROUP_LINK_IN(ROMABLE_REGION) } GROUP_LINK_IN(ROMABLE_REGION)
_image_text_end = .;
_image_text_size = _image_text_end - _image_text_start;
_image_rodata_start = .;
#include <linker/common-rom.ld> #include <linker/common-rom.ld>
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,ALIGN(16)) SECTION_PROLOGUE(_RODATA_SECTION_NAME,,ALIGN(16))
{ {
_image_rodata_start = .;
*(.rodata) *(.rodata)
*(.rodata.*) *(.rodata.*)
@ -70,13 +84,16 @@ SECTIONS
#include <linker/cplusplus-rom.ld> #include <linker/cplusplus-rom.ld>
MMU_PAGE_ALIGN
_image_rodata_end = .; _image_rodata_end = .;
_image_rodata_size = _image_rodata_end - _image_rodata_start; _image_rodata_size = _image_rodata_end - _image_rodata_start;
_image_rom_end = .; _image_rom_end = .;
SECTION_PROLOGUE(_DATA_SECTION_NAME,,ALIGN(16)) SECTION_PROLOGUE(_DATA_SECTION_NAME,,ALIGN(16))
{ {
MMU_PAGE_ALIGN
_image_ram_start = .; _image_ram_start = .;
__kernel_ram_start = .;
*(.data) *(.data)
*(.data.*) *(.data.*)
#include <snippets-rwdata.ld> #include <snippets-rwdata.ld>
@ -117,6 +134,10 @@ SECTIONS
_image_ram_end = .; _image_ram_end = .;
_end = .; _end = .;
/* All unused memory also owned by the kernel for heaps */
__kernel_ram_end = PHYS_RAM_ADDR + KB(DT_RAM_SIZE);
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
#include <linker/debug-sections.ld> #include <linker/debug-sections.ld>
/DISCARD/ : /DISCARD/ :