get memory map
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
kernel/lib/efiMemory.o
Normal file
BIN
kernel/lib/efiMemory.o
Normal file
Binary file not shown.
Binary file not shown.
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 <stdint.h>
|
||||||
#include "BasicRenderer.h"
|
#include "BasicRenderer.h"
|
||||||
#include "cstr.h"
|
#include "cstr.h"
|
||||||
|
#include "efiMemory.h"
|
||||||
|
|
||||||
|
|
||||||
struct BootInfo {
|
struct BootInfo {
|
||||||
@@ -20,19 +21,17 @@ extern "C" void __stack_chk_fail(void) {
|
|||||||
|
|
||||||
extern "C" void _start(BootInfo* bootInfo) {
|
extern "C" void _start(BootInfo* bootInfo) {
|
||||||
BasicRenderer newRenderer = BasicRenderer(bootInfo->framebuffer, bootInfo->psf1_Font);
|
BasicRenderer newRenderer = BasicRenderer(bootInfo->framebuffer, bootInfo->psf1_Font);
|
||||||
newRenderer.Print(0xFFFFFF, to_string((uint64_t)1234976));
|
|
||||||
newRenderer.cursorPosition = {0, 18};
|
// display information of memory map
|
||||||
newRenderer.Print(0xFFFFFF, to_string((int64_t)-1234976));
|
uint64_t mMapEntries = bootInfo->mMapSize / bootInfo->mMapDescriptorSize;
|
||||||
newRenderer.cursorPosition = {0, 36};
|
for (int i = 0; i < mMapEntries; i++) {
|
||||||
newRenderer.Print(0xFFFFFF, to_string(-3.141));
|
EFI_MEMORY_DESCRIPTOR* desc = (EFI_MEMORY_DESCRIPTOR*)((uint64_t)bootInfo->mMap + (i * bootInfo->mMapDescriptorSize));
|
||||||
newRenderer.cursorPosition = {0, 54};
|
newRenderer.Print(0xFFFFFFFF, EFI_MEMORY_TYPE_STRINGS[desc->type]);
|
||||||
newRenderer.Print(0xFFFFFF, to_hstring((uint64_t)0xF0));
|
newRenderer.Print(0xFFFFFFFF, " ");
|
||||||
newRenderer.cursorPosition = {0, 72};
|
newRenderer.Print(0xFFFF00FF, to_string(desc->numPages * 4096 / 1024));
|
||||||
newRenderer.Print(0xFFFFFF, to_hstring((uint32_t)0xF0));
|
newRenderer.Print(0xFFFF00FF, " KB");
|
||||||
newRenderer.cursorPosition = {0, 90};
|
newRenderer.cursorPosition = {0, newRenderer.cursorPosition.y + 18};
|
||||||
newRenderer.Print(0xFFFFFF, to_hstring((uint16_t)0xF0));
|
}
|
||||||
newRenderer.cursorPosition = {0, 108};
|
|
||||||
newRenderer.Print(0xFFFFFF, to_hstring((uint8_t)0xF0));
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user