added missing kernel VMA regions
This commit is contained in:
parent
39bb5e8d56
commit
aa6abef955
3 changed files with 32 additions and 11 deletions
|
@ -31,7 +31,7 @@ extern "C" {
|
|||
/// Binary exponent of minimal buddy size
|
||||
#define BUDDY_MIN 3 // 8 Byte >= sizeof(buddy_t)
|
||||
/// Binary exponent of the size which we allocate with buddy_fill()
|
||||
#define BUDDY_ALLOC 15 // 32 KByte >= PAGE_SIZE
|
||||
#define BUDDY_ALLOC 16 // 64 KByte = 16 * PAGE_SIZE
|
||||
|
||||
#define BUDDY_LISTS (BUDDY_MAX-BUDDY_MIN+1)
|
||||
#define BUDDY_MAGIC 0xBABE
|
||||
|
|
|
@ -49,9 +49,17 @@ extern "C" {
|
|||
#define VMA_HEAP (VMA_READ|VMA_WRITE|VMA_CACHEABLE)
|
||||
|
||||
// boundaries for VAS allocation
|
||||
#define VMA_KERN_MIN PAGE_SIZE // we skip the first page
|
||||
#define VMA_KERN_MAX KERNEL_SPACE
|
||||
#define VMA_USER_MAX PAGE_MAP_PGT
|
||||
|
||||
// we skip the first kb which are reserved for APICs, VGA, Multiboot, SMP etc.
|
||||
#define VMA_KERN_MIN 0xC0000
|
||||
|
||||
// last three top level entries are reserved
|
||||
#ifdef CONFIG_X86_32
|
||||
#define VMA_USER_MAX 0xFF400000
|
||||
#elif defined (CONFIG_X86_64)
|
||||
#define VMA_USER_MAX 0xFFFFFE8000000000
|
||||
#endif
|
||||
|
||||
struct vma;
|
||||
|
||||
|
|
29
mm/memory.c
29
mm/memory.c
|
@ -35,6 +35,7 @@
|
|||
#include <asm/SCC_API.h>
|
||||
#include <asm/icc.h>
|
||||
#endif
|
||||
#include <asm/apic.h>
|
||||
|
||||
/*
|
||||
* Set whole address space as occupied:
|
||||
|
@ -54,6 +55,8 @@ atomic_int32_t total_available_pages = ATOMIC_INIT(0);
|
|||
extern const void kernel_start;
|
||||
extern const void kernel_end;
|
||||
|
||||
extern apic_mp_t* apic_mp;
|
||||
|
||||
inline static int page_marked(size_t i)
|
||||
{
|
||||
size_t index = i >> 3;
|
||||
|
@ -306,22 +309,26 @@ int mmu_init(void)
|
|||
PAGE_FLOOR((size_t) &kernel_end),
|
||||
VMA_READ|VMA_WRITE|VMA_EXECUTE|VMA_CACHEABLE);
|
||||
|
||||
// TODO: should we move the following architecture specific VMA regions
|
||||
// to arch_paging_init() ?
|
||||
|
||||
// add Multiprocessing Tables to VMA list
|
||||
vma_add(PAGE_CEIL((size_t) apic_mp),
|
||||
PAGE_FLOOR((size_t) apic_mp + sizeof(apic_mp_t)),
|
||||
VMA_READ|VMA_WRITE|VMA_EXECUTE|VMA_CACHEABLE);
|
||||
|
||||
// add IOAPIC and LAPIC to VMA list
|
||||
vma_add((size_t) &kernel_start - 2*PAGE_SIZE,
|
||||
(size_t) &kernel_start,
|
||||
VMA_READ|VMA_WRITE);
|
||||
vma_add(LAPIC_ADDR, LAPIC_ADDR + PAGE_SIZE, VMA_READ|VMA_WRITE);
|
||||
vma_add(IOAPIC_ADDR, IOAPIC_ADDR + PAGE_SIZE, VMA_READ|VMA_WRITE);
|
||||
|
||||
#ifdef CONFIG_VGA
|
||||
// add VGA to VMA list
|
||||
vma_add(PAGE_CEIL(VIDEO_MEM_ADDR),
|
||||
PAGE_FLOOR(VIDEO_MEM_ADDR) + PAGE_SIZE,
|
||||
VMA_READ|VMA_WRITE);
|
||||
vma_add(VIDEO_MEM_ADDR, VIDEO_MEM_ADDR + PAGE_SIZE, VMA_READ|VMA_WRITE);
|
||||
#endif
|
||||
|
||||
#if MAX_CORES > 1
|
||||
// reserve page for SMP boot code
|
||||
vma_add(PAGE_CEIL(SMP_SETUP_ADDR),
|
||||
PAGE_FLOOR(SMP_SETUP_ADDR) + PAGE_SIZE,
|
||||
vma_add(SMP_SETUP_ADDR, SMP_SETUP_ADDR + PAGE_SIZE,
|
||||
VMA_READ|VMA_WRITE|VMA_EXECUTE|VMA_CACHEABLE);
|
||||
#endif
|
||||
|
||||
|
@ -335,6 +342,12 @@ int mmu_init(void)
|
|||
PAGE_FLOOR((size_t) mb_info + sizeof(multiboot_info_t)),
|
||||
VMA_READ|VMA_CACHEABLE);
|
||||
|
||||
if (mb_info->flags & MULTIBOOT_INFO_MEM_MAP) {
|
||||
vma_add(PAGE_CEIL((size_t) mb_info->mmap_addr),
|
||||
PAGE_FLOOR((size_t) mb_info->mmap_addr + mb_info->mmap_length),
|
||||
VMA_READ|VMA_CACHEABLE);
|
||||
}
|
||||
|
||||
if (mb_info->flags & MULTIBOOT_INFO_MODS) {
|
||||
multiboot_module_t* mmodule = (multiboot_module_t*) ((size_t) mb_info->mods_addr);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue