kernel: x86: MMU: Macros & Linker scripts for Boot time table creation
Macro is used to create a structure to specify the boot time page table configuration. Needed by the gen_mmu.py script to generate the actual page tables. Linker script is needed for the following: 1. To place the MMU page tables at 4KByte boundary. 2. To keep the configuration structure created by the Macro(mentioned above). Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
This commit is contained in:
parent
569c6e5203
commit
9bbf5335b9
4 changed files with 54 additions and 1 deletions
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <kernel_structs.h>
|
||||
#include <swapstk.h>
|
||||
|
||||
#include <mmustructs.h>
|
||||
|
||||
#include <kernel_offsets.h>
|
||||
|
||||
|
@ -88,6 +88,7 @@ GEN_OFFSET_SYM(NANO_ESF, eflags);
|
|||
/* size of the ISR_LIST structure. Used by linker scripts */
|
||||
|
||||
GEN_ABSOLUTE_SYM(__ISR_LIST_SIZEOF, sizeof(ISR_LIST));
|
||||
GEN_ABSOLUTE_SYM(__MMU_REGION_SIZEOF, sizeof(struct mmu_region));
|
||||
|
||||
|
||||
GEN_ABS_SYM_END
|
||||
|
|
|
@ -116,6 +116,30 @@
|
|||
#ifndef _ASMLANGUAGE
|
||||
#include <zephyr/types.h>
|
||||
|
||||
/* Structure used by gen_mmu.py to create page directories and page tables.
|
||||
* In order to populate this structure use macro MMU_BOOT_REGION.
|
||||
*/
|
||||
struct mmu_region {
|
||||
u32_t address; /*Start address of the memory region */
|
||||
u32_t size; /* Size of the memory region*/
|
||||
u32_t flags; /* Permissions needed for this region*/
|
||||
};
|
||||
|
||||
/* permission_flags are calculated using the macros
|
||||
* region_size has to be provided in bytes
|
||||
* for read write access = MMU_ENTRY_READ/MMU_ENTRY_WRITE
|
||||
* for supervisor/user mode access = MMU_ENTRY_SUPERVISOR/MMU_ENTRY_USER
|
||||
*/
|
||||
|
||||
#define MMU_BOOT_REGION(addr, region_size, permission_flags) \
|
||||
static struct mmu_region region_##addr \
|
||||
__attribute__((__section__(".mmulist"), used)) = \
|
||||
{ \
|
||||
.address = addr, \
|
||||
.size = region_size, \
|
||||
.flags = permission_flags, \
|
||||
}
|
||||
|
||||
/*
|
||||
* The following defines the format of a 32-bit page directory entry
|
||||
* that references a page table (as opposed to a 4 Mb page).
|
||||
|
|
|
@ -39,6 +39,7 @@ MEMORY
|
|||
*/
|
||||
|
||||
IDT_LIST : ORIGIN = 2K, LENGTH = 2K
|
||||
MMU_LIST : ORIGIN = 4k, LENGTH = 1K
|
||||
}
|
||||
|
||||
#include <arch/x86/linker.ld>
|
||||
|
|
|
@ -140,6 +140,13 @@ SECTIONS
|
|||
#include <custom-rwdata.ld>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_X86_MMU
|
||||
/* Page Tables are located here if MMU is enabled.*/
|
||||
. = ALIGN(4096);
|
||||
__mmu_tables_start = .;
|
||||
KEEP(*(.mmu_data));
|
||||
__mmu_tables_end = .;
|
||||
#endif
|
||||
. = ALIGN(4);
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
|
@ -214,6 +221,23 @@ SECTIONS
|
|||
KEEP(*(.gnu.linkonce.intList.*))
|
||||
__INT_LIST_END__ = .;
|
||||
} > IDT_LIST
|
||||
|
||||
#ifdef CONFIG_X86_MMU
|
||||
/* Memory management unit*/
|
||||
SECTION_PROLOGUE(mmulist, (OPTIONAL),)
|
||||
{
|
||||
/* get size of the mmu lists needed for gen_mmu.py*/
|
||||
LONG((__MMU_LIST_END__ - __MMU_LIST_START__) / __MMU_REGION_SIZEOF)
|
||||
/* Get the start of mmu tables in data section so that the address
|
||||
* of the page tables can be calculated.
|
||||
*/
|
||||
LONG(__mmu_tables_start)
|
||||
__MMU_LIST_START__ = .;
|
||||
KEEP(*(.mmulist))
|
||||
__MMU_LIST_END__ = .;
|
||||
} > MMU_LIST
|
||||
#endif /* CONFIG_X86_MMU */
|
||||
|
||||
#else
|
||||
/DISCARD/ :
|
||||
{
|
||||
|
@ -221,9 +245,12 @@ SECTIONS
|
|||
KEEP(*(.spurNoErrIsr))
|
||||
KEEP(*(.intList))
|
||||
KEEP(*(.gnu.linkonce.intList.*))
|
||||
KEEP(*(.mmulist))
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef CONFIG_CUSTOM_SECTIONS_LD
|
||||
/* Located in project source directory */
|
||||
#include <custom-sections.ld>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue