x86: enable MMU for application memory

Configuring the RAM/ROM regions will be the same for all
x86 targets as this is done with linker symbols.

Peripheral configuration left at the SOC level.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-08-01 15:22:06 -07:00 committed by Anas Nashif
commit 25a8aef275
3 changed files with 26 additions and 15 deletions

View file

@ -4,14 +4,38 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include<kernel.h>
#include<mmustructs.h>
#include <kernel.h>
#include <mmustructs.h>
#include <linker/linker-defs.h>
/* Ref to _x86_mmu_buffer_validate documentation for details */
#define USER_PERM_BIT_POS ((u32_t)0x1)
#define GET_RW_PERM(flags) (flags & BUFF_WRITEABLE)
#define GET_US_PERM(flags) ((flags & BUFF_USER) >> USER_PERM_BIT_POS)
/* Common regions for all x86 processors.
* Peripheral I/O ranges configured at the SOC level
*/
/* Mark text and rodata as read-only.
* Userspace may read all text and rodata.
*/
MMU_BOOT_REGION((u32_t)&_image_rom_start, (u32_t)&_image_rom_size,
MMU_ENTRY_READ | MMU_ENTRY_USER);
#ifdef CONFIG_APPLICATION_MEMORY
/* User threads by default can read/write app-level memory. */
MMU_BOOT_REGION((u32_t)&__app_ram_start, (u32_t)&__app_ram_size,
MMU_ENTRY_WRITE | MMU_ENTRY_USER);
#endif
/* __kernel_ram_size includes all unused memory, which is used for heaps.
* User threads cannot access this unless granted at runtime. This is done
* automatically for stacks.
*/
MMU_BOOT_REGION((u32_t)&__kernel_ram_start, (u32_t)&__kernel_ram_size,
MMU_ENTRY_WRITE | MMU_ENTRY_RUNTIME_USER);
/**
* brief check page directory flags
*

View file

@ -21,16 +21,7 @@
#include <linker/linker-defs.h>
#ifdef CONFIG_X86_MMU
/* Mark text and rodata as read-only, for XIP rest of flash unmapped */
MMU_BOOT_REGION((u32_t)&_image_rom_start, (u32_t)&_image_rom_size,
MMU_ENTRY_READ);
/* From _image_ram_start to the end of all RAM, read/write */
MMU_BOOT_REGION((u32_t)&_image_ram_start, (u32_t)&_image_ram_all,
MMU_ENTRY_WRITE);
MMU_BOOT_REGION(CONFIG_LOAPIC_BASE_ADDRESS, KB(4), MMU_ENTRY_WRITE);
MMU_BOOT_REGION(CONFIG_IOAPIC_BASE_ADDRESS, MB(1), MMU_ENTRY_WRITE);
MMU_BOOT_REGION(CONFIG_HPET_TIMER_BASE_ADDRESS, KB(4), MMU_ENTRY_WRITE);
#endif /* CONFIG_X86_MMU*/

View file

@ -25,10 +25,6 @@
#ifdef CONFIG_X86_MMU
MMU_BOOT_REGION(CONFIG_PHYS_LOAD_ADDR, CONFIG_ROM_SIZE*1024, MMU_ENTRY_WRITE);
MMU_BOOT_REGION(CONFIG_PHYS_RAM_ADDR, CONFIG_RAM_SIZE*1024, MMU_ENTRY_WRITE);
/* loapic */
MMU_BOOT_REGION(CONFIG_LOAPIC_BASE_ADDRESS, 4*1024, MMU_ENTRY_WRITE);