get memory map
This commit is contained in:
18
kernel/src/efiMemory.cpp
Normal file
18
kernel/src/efiMemory.cpp
Normal file
@@ -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"
|
||||
};
|
||||
12
kernel/src/efiMemory.h
Normal file
12
kernel/src/efiMemory.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
struct EFI_MEMORY_DESCRIPTOR {
|
||||
uint32_t type;
|
||||
void* physAddr;
|
||||
void* virtAddr;
|
||||
uint64_t numPages;
|
||||
uint64_t attribs;
|
||||
};
|
||||
|
||||
extern const char* EFI_MEMORY_TYPE_STRINGS[];
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdint.h>
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user