diff --git a/OVMFbin/OVMF_VARS-pure-efi.fd b/OVMFbin/OVMF_VARS-pure-efi.fd index 80b9da2..cd4ff9d 100644 Binary files a/OVMFbin/OVMF_VARS-pure-efi.fd and b/OVMFbin/OVMF_VARS-pure-efi.fd differ diff --git a/kernel/bin/CustomOS.img b/kernel/bin/CustomOS.img index df8a151..9ccb1c6 100644 Binary files a/kernel/bin/CustomOS.img and b/kernel/bin/CustomOS.img differ diff --git a/kernel/bin/kernel.elf b/kernel/bin/kernel.elf index f9af8cf..b83a579 100755 Binary files a/kernel/bin/kernel.elf and b/kernel/bin/kernel.elf differ diff --git a/kernel/lib/efiMemory.o b/kernel/lib/efiMemory.o new file mode 100644 index 0000000..cfce2dc Binary files /dev/null and b/kernel/lib/efiMemory.o differ diff --git a/kernel/lib/kernel.o b/kernel/lib/kernel.o index c85e5ca..cfa38b8 100644 Binary files a/kernel/lib/kernel.o and b/kernel/lib/kernel.o differ diff --git a/kernel/src/efiMemory.cpp b/kernel/src/efiMemory.cpp new file mode 100644 index 0000000..e9d5559 --- /dev/null +++ b/kernel/src/efiMemory.cpp @@ -0,0 +1,18 @@ +#include "efiMemory.h" + +const char* EFI_MEMORY_TYPE_STRINGS[] = { + "EfiReservedMemoryType", + "EfiLoaderCode", + "EfiLoaderData", + "EfiBootServicesCode", + "EfiBootServicesData", + "EfiRuntimeServicesCode", + "EfiRuntimeServicesData", + "EfiConventionalMemory", + "EfiUnusableMemory", + "EfiACPIReclaimMemory", + "EfiACPIMemoryNVS", + "EfiMemoryMappedIO", + "EfiMemoryMappedIOPortSpace", + "EfiPalCode" +}; \ No newline at end of file diff --git a/kernel/src/efiMemory.h b/kernel/src/efiMemory.h new file mode 100644 index 0000000..8acdf72 --- /dev/null +++ b/kernel/src/efiMemory.h @@ -0,0 +1,12 @@ +#pragma once +#include + +struct EFI_MEMORY_DESCRIPTOR { + uint32_t type; + void* physAddr; + void* virtAddr; + uint64_t numPages; + uint64_t attribs; +}; + +extern const char* EFI_MEMORY_TYPE_STRINGS[]; \ No newline at end of file diff --git a/kernel/src/kernel.cpp b/kernel/src/kernel.cpp index af5cf45..41fb9a4 100644 --- a/kernel/src/kernel.cpp +++ b/kernel/src/kernel.cpp @@ -2,6 +2,7 @@ #include #include "BasicRenderer.h" #include "cstr.h" +#include "efiMemory.h" struct BootInfo { @@ -20,19 +21,17 @@ extern "C" void __stack_chk_fail(void) { extern "C" void _start(BootInfo* bootInfo) { BasicRenderer newRenderer = BasicRenderer(bootInfo->framebuffer, bootInfo->psf1_Font); - newRenderer.Print(0xFFFFFF, to_string((uint64_t)1234976)); - newRenderer.cursorPosition = {0, 18}; - newRenderer.Print(0xFFFFFF, to_string((int64_t)-1234976)); - newRenderer.cursorPosition = {0, 36}; - newRenderer.Print(0xFFFFFF, to_string(-3.141)); - newRenderer.cursorPosition = {0, 54}; - newRenderer.Print(0xFFFFFF, to_hstring((uint64_t)0xF0)); - newRenderer.cursorPosition = {0, 72}; - newRenderer.Print(0xFFFFFF, to_hstring((uint32_t)0xF0)); - newRenderer.cursorPosition = {0, 90}; - newRenderer.Print(0xFFFFFF, to_hstring((uint16_t)0xF0)); - newRenderer.cursorPosition = {0, 108}; - newRenderer.Print(0xFFFFFF, to_hstring((uint8_t)0xF0)); + + // display information of memory map + uint64_t mMapEntries = bootInfo->mMapSize / bootInfo->mMapDescriptorSize; + for (int i = 0; i < mMapEntries; i++) { + EFI_MEMORY_DESCRIPTOR* desc = (EFI_MEMORY_DESCRIPTOR*)((uint64_t)bootInfo->mMap + (i * bootInfo->mMapDescriptorSize)); + newRenderer.Print(0xFFFFFFFF, EFI_MEMORY_TYPE_STRINGS[desc->type]); + newRenderer.Print(0xFFFFFFFF, " "); + newRenderer.Print(0xFFFF00FF, to_string(desc->numPages * 4096 / 1024)); + newRenderer.Print(0xFFFF00FF, " KB"); + newRenderer.cursorPosition = {0, newRenderer.cursorPosition.y + 18}; + } return; } \ No newline at end of file