x86: linker: define z_mapped_* symbols
We will use this to map the kernel instead of all RAM. The end of the kernel is always page-aligned, regardless of CONFIG_SRAM_REGION_PERMISSIONS as it must be mapped. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
8a365048bb
commit
891776ec2a
2 changed files with 31 additions and 12 deletions
|
@ -51,14 +51,20 @@
|
||||||
#define RAMABLE_REGION RAM
|
#define RAMABLE_REGION RAM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_MMU
|
||||||
|
#define MMU_PAGE_ALIGN . = ALIGN(CONFIG_MMU_PAGE_SIZE);
|
||||||
|
#else
|
||||||
|
#define MMU_PAGE_ALIGN
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Used to align areas with separate memory permission characteristics
|
/* Used to align areas with separate memory permission characteristics
|
||||||
* so that the page permissions can be set in the MMU. Without this,
|
* so that the page permissions can be set in the MMU. Without this,
|
||||||
* the kernel is just one blob with the same RWX permissions on all RAM
|
* the kernel is just one blob with the same RWX permissions on all RAM
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_SRAM_REGION_PERMISSIONS
|
#ifdef CONFIG_SRAM_REGION_PERMISSIONS
|
||||||
#define MMU_PAGE_ALIGN . = ALIGN(CONFIG_MMU_PAGE_SIZE);
|
#define MMU_PAGE_ALIGN_PERM MMU_PAGE_ALIGN
|
||||||
#else
|
#else
|
||||||
#define MMU_PAGE_ALIGN
|
#define MMU_PAGE_ALIGN_PERM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ENTRY(CONFIG_KERNEL_ENTRY)
|
ENTRY(CONFIG_KERNEL_ENTRY)
|
||||||
|
@ -90,6 +96,9 @@ SECTIONS
|
||||||
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
|
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
|
||||||
{
|
{
|
||||||
_image_text_start = .;
|
_image_text_start = .;
|
||||||
|
#ifndef CONFIG_XIP
|
||||||
|
z_mapped_start = .;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Located in generated directory. This file is populated by calling
|
/* Located in generated directory. This file is populated by calling
|
||||||
* zephyr_linker_sources(ROM_START ...). This typically contains the vector
|
* zephyr_linker_sources(ROM_START ...). This typically contains the vector
|
||||||
|
@ -112,7 +121,7 @@ SECTIONS
|
||||||
|
|
||||||
#include <linker/kobject-text.ld>
|
#include <linker/kobject-text.ld>
|
||||||
|
|
||||||
MMU_PAGE_ALIGN
|
MMU_PAGE_ALIGN_PERM
|
||||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||||
|
|
||||||
_image_text_end = .;
|
_image_text_end = .;
|
||||||
|
@ -156,7 +165,7 @@ SECTIONS
|
||||||
|
|
||||||
#include <linker/cplusplus-rom.ld>
|
#include <linker/cplusplus-rom.ld>
|
||||||
|
|
||||||
MMU_PAGE_ALIGN
|
MMU_PAGE_ALIGN_PERM
|
||||||
/* ROM ends here, position counter will now be in RAM areas */
|
/* ROM ends here, position counter will now be in RAM areas */
|
||||||
#ifdef CONFIG_XIP
|
#ifdef CONFIG_XIP
|
||||||
_image_rom_end = .;
|
_image_rom_end = .;
|
||||||
|
@ -177,6 +186,10 @@ SECTIONS
|
||||||
/* RAMABLE_REGION */
|
/* RAMABLE_REGION */
|
||||||
GROUP_START(RAMABLE_REGION)
|
GROUP_START(RAMABLE_REGION)
|
||||||
|
|
||||||
|
#ifdef CONFIG_XIP
|
||||||
|
MMU_PAGE_ALIGN
|
||||||
|
z_mapped_start = .;
|
||||||
|
#endif
|
||||||
/* Located in generated directory. This file is populated by the
|
/* Located in generated directory. This file is populated by the
|
||||||
* zephyr_linker_sources() Cmake function.
|
* zephyr_linker_sources() Cmake function.
|
||||||
*/
|
*/
|
||||||
|
@ -184,8 +197,8 @@ SECTIONS
|
||||||
|
|
||||||
#ifdef CONFIG_USERSPACE
|
#ifdef CONFIG_USERSPACE
|
||||||
/* APP SHARED MEMORY REGION */
|
/* APP SHARED MEMORY REGION */
|
||||||
#define SMEM_PARTITION_ALIGN(size) MMU_PAGE_ALIGN
|
#define SMEM_PARTITION_ALIGN(size) MMU_PAGE_ALIGN_PERM
|
||||||
#define APP_SHARED_ALIGN MMU_PAGE_ALIGN
|
#define APP_SHARED_ALIGN MMU_PAGE_ALIGN_PERM
|
||||||
|
|
||||||
#include <app_smem.ld>
|
#include <app_smem.ld>
|
||||||
|
|
||||||
|
@ -198,7 +211,7 @@ SECTIONS
|
||||||
|
|
||||||
SECTION_PROLOGUE(_BSS_SECTION_NAME, (NOLOAD),)
|
SECTION_PROLOGUE(_BSS_SECTION_NAME, (NOLOAD),)
|
||||||
{
|
{
|
||||||
MMU_PAGE_ALIGN
|
MMU_PAGE_ALIGN_PERM
|
||||||
#if !defined(CONFIG_USERSPACE)
|
#if !defined(CONFIG_USERSPACE)
|
||||||
_image_ram_start = .;
|
_image_ram_start = .;
|
||||||
#endif
|
#endif
|
||||||
|
@ -227,7 +240,7 @@ SECTIONS
|
||||||
|
|
||||||
#include <linker/common-noinit.ld>
|
#include <linker/common-noinit.ld>
|
||||||
|
|
||||||
MMU_PAGE_ALIGN
|
MMU_PAGE_ALIGN_PERM
|
||||||
|
|
||||||
SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,)
|
SECTION_DATA_PROLOGUE(_DATA_SECTION_NAME,,)
|
||||||
{
|
{
|
||||||
|
@ -261,7 +274,7 @@ SECTIONS
|
||||||
#include <snippets-rwdata.ld>
|
#include <snippets-rwdata.ld>
|
||||||
|
|
||||||
#ifdef CONFIG_X86_KPTI
|
#ifdef CONFIG_X86_KPTI
|
||||||
MMU_PAGE_ALIGN
|
MMU_PAGE_ALIGN_PERM
|
||||||
z_shared_kernel_page_start = .;
|
z_shared_kernel_page_start = .;
|
||||||
/* Special page containing supervisor data that is still mapped in
|
/* Special page containing supervisor data that is still mapped in
|
||||||
* user mode page tables. IDT, GDT, TSSes, trampoline stack, and
|
* user mode page tables. IDT, GDT, TSSes, trampoline stack, and
|
||||||
|
@ -302,7 +315,7 @@ SECTIONS
|
||||||
|
|
||||||
#ifdef CONFIG_X86_KPTI
|
#ifdef CONFIG_X86_KPTI
|
||||||
z_trampoline_stack_start = .;
|
z_trampoline_stack_start = .;
|
||||||
MMU_PAGE_ALIGN
|
MMU_PAGE_ALIGN_PERM
|
||||||
z_trampoline_stack_end = .;
|
z_trampoline_stack_end = .;
|
||||||
z_shared_kernel_page_end = .;
|
z_shared_kernel_page_end = .;
|
||||||
|
|
||||||
|
@ -334,6 +347,8 @@ SECTIONS
|
||||||
_image_ram_end = .;
|
_image_ram_end = .;
|
||||||
_image_ram_all = (KERNEL_BASE_ADDR + KERNEL_RAM_SIZE) - _image_ram_start;
|
_image_ram_all = (KERNEL_BASE_ADDR + KERNEL_RAM_SIZE) - _image_ram_start;
|
||||||
|
|
||||||
|
z_mapped_end = .;
|
||||||
|
z_mapped_size = z_mapped_end - z_mapped_start;
|
||||||
_end = .; /* end of image */
|
_end = .; /* end of image */
|
||||||
|
|
||||||
GROUP_END(RAMABLE_REGION)
|
GROUP_END(RAMABLE_REGION)
|
||||||
|
|
|
@ -70,7 +70,7 @@ SECTIONS
|
||||||
"shared kernel area is not one memory page");
|
"shared kernel area is not one memory page");
|
||||||
#endif /* CONFIG_X86_KPTI */
|
#endif /* CONFIG_X86_KPTI */
|
||||||
|
|
||||||
MMU_PAGE_ALIGN
|
. = ALIGN(CONFIG_MMU_PAGE_SIZE);
|
||||||
_lodata_end = .;
|
_lodata_end = .;
|
||||||
} > LOCORE
|
} > LOCORE
|
||||||
|
|
||||||
|
@ -87,6 +87,7 @@ SECTIONS
|
||||||
{
|
{
|
||||||
_image_rom_start = .;
|
_image_rom_start = .;
|
||||||
_image_text_start = .;
|
_image_text_start = .;
|
||||||
|
z_mapped_start = .;
|
||||||
*(.text)
|
*(.text)
|
||||||
*(.text.*)
|
*(.text.*)
|
||||||
|
|
||||||
|
@ -179,14 +180,17 @@ SECTIONS
|
||||||
|
|
||||||
/* Must be last in RAM */
|
/* Must be last in RAM */
|
||||||
#include <linker/kobject.ld>
|
#include <linker/kobject.ld>
|
||||||
|
. = ALIGN(CONFIG_MMU_PAGE_SIZE);
|
||||||
_image_ram_end = .;
|
_image_ram_end = .;
|
||||||
|
z_mapped_end = .;
|
||||||
_end = .;
|
_end = .;
|
||||||
|
|
||||||
/* All unused memory also owned by the kernel for heaps */
|
/* All unused memory also owned by the kernel for heaps */
|
||||||
__kernel_ram_end = KERNEL_BASE_ADDR + KERNEL_RAM_SIZE;
|
__kernel_ram_end = KERNEL_BASE_ADDR + KERNEL_RAM_SIZE;
|
||||||
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
|
__kernel_ram_size = __kernel_ram_end - __kernel_ram_start;
|
||||||
|
|
||||||
|
z_mapped_size = z_mapped_end - z_mapped_start;
|
||||||
|
|
||||||
#include <linker/debug-sections.ld>
|
#include <linker/debug-sections.ld>
|
||||||
|
|
||||||
/DISCARD/ :
|
/DISCARD/ :
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue