From 2d1ff7482b97bf6db2ed9da794c125b3a763a9d7 Mon Sep 17 00:00:00 2001 From: stefan Date: Sun, 22 Aug 2010 11:00:56 +0000 Subject: [PATCH] - add a more precise calculation of the kernel position git-svn-id: http://svn.lfbs.rwth-aachen.de/svn/scc/trunk/MetalSVM@122 315a16e6-25f9-4109-90ae-ca3045a26c18 --- link.ld | 5 +++-- mm/memory.c | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/link.ld b/link.ld index ab752f97..29f6243f 100644 --- a/link.ld +++ b/link.ld @@ -1,10 +1,11 @@ OUTPUT_FORMAT("binary") ENTRY(start) phys = 0x00100000; -kernel_start = .; + SECTIONS { .text phys : AT(phys) { + kernel_start = .; code = .; *(multiboot) *(.text) @@ -24,6 +25,6 @@ SECTIONS . = ALIGN(4096); } end = .; + kernel_end = .; } . = ALIGN(4096); -kernel_end = .; diff --git a/mm/memory.c b/mm/memory.c index 575339f6..6646f598 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -142,16 +142,19 @@ int mmu_init(void) #error Currently, MetalSVM supports only Multiboot or the RockCreek processor! #endif - /* kernel is aligned to page size */ kernel_size = (size_t) &kernel_end - (size_t) &kernel_start; + if (kernel_size % PAGE_SIZE) + kernel_size += PAGE_SIZE - kernel_size % PAGE_SIZE; atomic_int32_add(&total_allocated_pages, kernel_size/PAGE_SIZE); atomic_int32_sub(&total_available_pages, kernel_size/PAGE_SIZE); /* set kernel space as used */ for(i=(size_t) &kernel_start / PAGE_SIZE; i < (size_t) &kernel_end / PAGE_SIZE; i++) page_set_mark(i); + if ((size_t) &kernel_end % PAGE_SIZE) + page_set_mark(i); - alloc_start = (unsigned int) (&kernel_end) / PAGE_SIZE + 1; + alloc_start = (unsigned int) (&kernel_end) / PAGE_SIZE; alloc_start += 128*1024; return 0;