From e473d63728a1f826f707e0f410487ee86e78f8de Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 14 May 2019 14:39:44 +0200 Subject: [PATCH] reorg --- boot/loader/loader.asm | 8 ++++---- build/kernel.ld | 2 +- kaleid/kernel/init/info.c | 15 +++++---------- kaleid/kernel/mm/map.c | 18 +++++++----------- 4 files changed, 17 insertions(+), 26 deletions(-) diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 2312c73..5ab3ed2 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -31,15 +31,15 @@ %include "boot/loader/cpu/cpu.inc" %include "boot/loader/mem/structures.inc" -global MB_start -global MB_header +global BtStartLoader +global BtHeader extern BtStartKern [BITS 32] [section .multiboot] ;; MAGNIFICENT MULTIBOOT HEADER FOR GRUB ------------------------------------ ;; -MB_header: +BtHeader: ALIGN 4 dd MB_HEADER_MAGIC dd MB_HEADER_FLAGS @@ -53,7 +53,7 @@ MB_header: [section .text] ;;MULTIBOOT POINT ENTRY FOR GRUB -------------------------------------------- ;; -MB_start: +BtStartLoader: mov esp, KERNEL_STACK ; Setup the stack push 0 ; Reset EFLAGS popf diff --git a/build/kernel.ld b/build/kernel.ld index 90bd5b7..55fb5ed 100644 --- a/build/kernel.ld +++ b/build/kernel.ld @@ -24,7 +24,7 @@ //----------------------------------------------------------------------------*/ -ENTRY(MB_start) /* the name of the entry label */ +ENTRY(BtStartLoader) /* the name of the entry label */ SECTIONS { . = 0x00100000; /* the code should be loaded at 1 MB */ diff --git a/kaleid/kernel/init/info.c b/kaleid/kernel/init/info.c index 9ea858e..8fde487 100644 --- a/kaleid/kernel/init/info.c +++ b/kaleid/kernel/init/info.c @@ -31,7 +31,7 @@ // void BtInitBootInfo(multiboot_info_t *mbi, void *codeSeg) { - extern ulong MB_header; + extern ulong BtHeader; extern ulong newKernelEnd; extern ulong newStackEnd; @@ -43,7 +43,7 @@ void BtInitBootInfo(multiboot_info_t *mbi, void *codeSeg) if (BtLoaderInfo.grubFlags & MULTIBOOT_INFO_BOOT_LOADER_NAME) { BtLoaderInfo.grubName = (char*)(ulong)(mbi->boot_loader_name); - BtLoaderInfo.kernelAddr = (void*)&MB_header; + BtLoaderInfo.kernelAddr = (void*)&BtHeader; BtLoaderInfo.kernelEndAddr = (void*)newKernelEnd; BtLoaderInfo.stackEndAddr = (void*)newStackEnd; BtLoaderInfo.codeSegment = codeSeg; @@ -108,16 +108,11 @@ void BtInitBootInfo(multiboot_info_t *mbi, void *codeSeg) } void BtDoSanityChecks(uint mbMagic) { - uint tmp; if (!(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC)) - KeStartPanic("[Init] Magic number %x is incorrect\n", mbMagic); + KeStartPanic("[Init]\tMagic number %x is incorrect\n", mbMagic); - tmp = (BtLoaderInfo.kernelEndAddr - - BtLoaderInfo.kernelAddr) / KB; - DebugLog("[Init] Kernel successfully loaded at %p with %x magic\n" - " and it uses %dKB\n\n", - BtLoaderInfo.kernelAddr, - mbMagic, tmp); + DebugLog("[Init]\tKernel successfully loaded at %p\n", + BtLoaderInfo.kernelAddr); } diff --git a/kaleid/kernel/mm/map.c b/kaleid/kernel/mm/map.c index 2768b5f..3145126 100644 --- a/kaleid/kernel/mm/map.c +++ b/kaleid/kernel/mm/map.c @@ -38,10 +38,11 @@ void MmInitMemoryMap(void) { error_t rc; - if ((rc = InitMemoryMap())) - KeStartPanic("[Init] The memory map failed to initialize. Error : %d", - rc - ); + rc = InitMemoryMap(); + + if (rc) + KeStartPanic("[Mm]\tThe memory map failed to initialize.\nError : %s", + strerror(rc) ); } static error_t InitMemoryMap(void) @@ -84,9 +85,6 @@ static error_t InitMemoryMap(void) i++; } - DebugLog("[InitMemoryMap] %d entries detected in the memory map\n", - memoryMap.length); - // compute the free ram size for (i = 0; i < memoryMap.length; i++) { if (memoryMap.entry[i].type == AVAILABLE_ZONE) { @@ -100,10 +98,8 @@ static error_t InitMemoryMap(void) if (memoryMap.freeRamSize < MINIMUM_RAM_SIZE) return ENOMEM; - DebugLog("[InitMemoryMap] Available Ram Size : %u Mio, Used Ram Size : %u Kio\n\n", - memoryMap.freeRamSize / MB, memoryMap.nonfreeRamSize / KB); - /*DebugLog("[InitMemoryMap] Physical Ram Size : %d Mio\n\n", - (memoryMap.freeRamSize + memoryMap.nonfreeRamSize) / MB);*/ + KernLog("[Mm]\tAvailable Ram Size : %u Mio\n", + memoryMap.freeRamSize / MB); // Magic value in memory to prevent smashing ulong * heapStart = BtLoaderInfo.stackEndAddr + 8;