From c245268812a63bae0610de9a416dc7de97edde07 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Fri, 5 Sep 2014 09:34:53 +0200 Subject: Moved kernel and reclaimed ACPI memory finally our 2 stage bootloader also works with LBA loading via BIOS --- kernel/kernel.c | 25 ++++++++++++------------- kernel/mem.c | 20 +++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-) (limited to 'kernel') diff --git a/kernel/kernel.c b/kernel/kernel.c index 0feca14..45f798d 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -107,18 +107,6 @@ void kernel_main(uint32_t initial_stack, int mp) // int_init(0x08); - // - // Memory Init - // - // after this is set up we can allocate and deallocate blocks - // of physical memory :) - // - // we know that here, the bootloader placed the mamory map and - // the number of entries. - // - mem_init(0x7c00+1,*((uint16_t *)(0x7c00))); - - // // Gather Info about other processors. (APs) // ACPI or MP @@ -130,10 +118,21 @@ void kernel_main(uint32_t initial_stack, int mp) if(!mp_find(&procdata)) panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!"); + // + // Memory Init + // + // after this is set up we can allocate and deallocate blocks + // of physical memory :) + // + // we know that here, the bootloader placed the mamory map and + // the number of entries. + // + mem_init(0x7c00+1,*((uint16_t *)(0x7c00))); + // // Start the other Processors (also before paging !) // - smp_start_aps(&procdata,0x80000); // starts at 0x90000 +// smp_start_aps(&procdata,0x80000); // starts at 0x90000 // but it will be copied over mbr // diff --git a/kernel/mem.c b/kernel/mem.c index ffa56c4..af58877 100644 --- a/kernel/mem.c +++ b/kernel/mem.c @@ -159,7 +159,7 @@ void mem_init(uint16_t *memmap,uint16_t entries) mem_free_blocks=0; // count available mem - uint32_t total_mem=0, highest_end=0, high_end_low=0; + uint32_t total_mem=0, highest_end=0, high_end_low=0,last_end=0; log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"the memory map contains %d entries.",entries); @@ -178,18 +178,20 @@ void mem_init(uint16_t *memmap,uint16_t entries) memmap[8],low_end,high_end); #endif - if(memmap[8]==1) + if(memmap[8]==1||memmap[8]==3) { total_mem+=memmap[4]+(memmap[5]<<16); - } - if(memmap[8]==1) - { - if(high_end>highest_end){ + if(high_end>highest_end) + { highest_end=high_end; - high_end_low=low_end; + high_end_low=last_end; } } + else + { + last_end=high_end+1; + } memmap+=12; @@ -201,9 +203,9 @@ void mem_init(uint16_t *memmap,uint16_t entries) mem_array_size=blocks/32+1; + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Highest end area: 0x%08X - 0x%08X",high_end_low,highest_end); if(highest_end-high_end_low