From 7c0fe01f6a310685f2e4721d2fc5f51c22cf67e8 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sat, 30 Mar 2019 14:58:12 +0100 Subject: [PATCH] printing mem stuff --- kaleid/include/kernel/base.h | 3 +++ kaleid/include/kernel/mm.h | 5 +++++ kaleid/kernel/init/init.c | 16 ++++++++-------- kaleid/kernel/mm/map.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/kaleid/include/kernel/base.h b/kaleid/include/kernel/base.h index 84f961d..42622ee 100644 --- a/kaleid/include/kernel/base.h +++ b/kaleid/include/kernel/base.h @@ -187,6 +187,9 @@ extern volatile Processor_t cpuTable[NCPUS]; static inline void _##pref##Set##name(type __val) \ { KeGetCurCPU().field = __val; } +#define BARRIER() do{\ + asm volatile("": : :"memory");__sync_synchronize();}while(0) + //------------------------------------------// // Needed by basically everyone diff --git a/kaleid/include/kernel/mm.h b/kaleid/include/kernel/mm.h index 22c4346..c06bd8d 100644 --- a/kaleid/include/kernel/mm.h +++ b/kaleid/include/kernel/mm.h @@ -83,6 +83,11 @@ struct GdtPtr_t // void MmInitMemoryMap(void); +// +// Initializes the memory map structure +// +void MmPrintMemoryMap(void); + // // Returns the size of the first available memory zone // from the start address pointer diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index a8592b7..2a04bcd 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -113,9 +113,6 @@ void BtInitBootInfo(multiboot_info_t *mbi) extern void pstest(void); extern error_t IoInitVGABuffer(void); -#define BARRIER() do{\ - asm volatile("": : :"memory");__sync_synchronize();}while(0) - // // Entry point of the Kaleid kernel // @@ -127,14 +124,13 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, int mbMagic) // Initialize the BootInfo_t structure BtInitBootInfo(mbInfo); - // Get ready to print things IoInitVGABuffer(); BARRIER(); // Hello world - KernLog("%c%c%c OS/K\n\n", 219, 219, 219); + KernLog("%c%c%c OS/K\n \n", 219, 219, 219); KalAlwaysAssert(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC); @@ -151,11 +147,15 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, int mbMagic) MmInitHeap(); + PsInitSched(); + BARRIER(); - int i = 0; - while(i < 517) { KernLog("%d\n", i++);} - PsInitSched(); + /* int i = 0; */ + /* while(i < 517) { KernLog("%d\n", i++);} */ + + MmPrintMemoryMap(); + // We're out PsFiniSched(); diff --git a/kaleid/kernel/mm/map.c b/kaleid/kernel/mm/map.c index 30bc0f6..c3178c4 100644 --- a/kaleid/kernel/mm/map.c +++ b/kaleid/kernel/mm/map.c @@ -172,3 +172,33 @@ void *MmGetFirstAvailZone(void *start) { return current; } + +void MmPrintMemoryMap(void) { + char *avStr = ""; + + for (int i=0; i < memoryMap.length; i++) { + + switch (memoryMap.entry[i].type) { + + case AVAILABLE_ZONE: avStr="Available"; + break; + case RESERVED_ZONE: avStr="Reserved"; + break; + case ACPI_ZONE: avStr="ACPI"; + break; + case NVS_ZONE: avStr="NVS"; + break; + case BADRAM_ZONE: avStr="Bad Ram"; + break; + default:; + + + } + + KernLog("Mem zone : %p\t%s\twith length:%dKio\n", + memoryMap.entry[i].addr, + avStr, + memoryMap.entry[i].length / KB + ); + } +}