feat: completely functional PMM

This commit is contained in:
karina
2026-04-26 15:12:04 +04:00
parent 785a61b451
commit 55335013a9
4 changed files with 78 additions and 9 deletions
+11 -7
View File
@@ -1,3 +1,4 @@
#include "Types.h"
#include <Arch/DTB.h>
#include <OS/Panic.h>
#include <OS/Log.h>
@@ -12,6 +13,11 @@ void DTBParse(Pointer dtb, VMBootMemoryMap* bootMap) {
OSPanic("Invalid DTB magic");
}
UInt32 index = bootMap->reservedCount;
bootMap->reserved[index].base = (Address)dtb;
bootMap->reserved[index].size = BytesSwap32(header->totalSize);
bootMap->reservedCount++;
UInt32 offStruct = BytesSwap32(header->offDtStruct);
UInt32 offStrings = BytesSwap32(header->offDtStrings);
@@ -51,23 +57,21 @@ void DTBParse(Pointer dtb, VMBootMemoryMap* bootMap) {
if (StringCompare(propertyName, "reg") == 0) {
if (StringStartsWith(currentNode, "memory")) {
UInt32* cells = (UInt32*)structs;
UInt64 base = Merge32To64(BytesSwap32(cells[1]), BytesSwap32(cells[0]));
UInt64 size = Merge32To64(BytesSwap32(cells[3]), BytesSwap32(cells[2]));
OSLog("Main Memory: base=0x%x, size=0x%x\n", base, size);
Address base = Merge32To64(BytesSwap32(cells[1]), BytesSwap32(cells[0]));
Size size = Merge32To64(BytesSwap32(cells[3]), BytesSwap32(cells[2]));
bootMap->totalRAM.base = base;
bootMap->totalRAM.size = size;
}
else if (inReservedMemory && currentDepth > reservedMemoryDepth) {
UInt32* cells = (UInt32*)structs;
UInt64 base = Merge32To64(BytesSwap32(cells[1]), BytesSwap32(cells[0]));
UInt64 size = Merge32To64(BytesSwap32(cells[3]), BytesSwap32(cells[2]));
Address base = Merge32To64(BytesSwap32(cells[1]), BytesSwap32(cells[0]));
Size size = Merge32To64(BytesSwap32(cells[3]), BytesSwap32(cells[2]));
UInt32 index = bootMap->reservedCount;
bootMap->reserved[index].base = base;
bootMap->reserved[index].size = size;
bootMap->reservedCount++;
OSLog("Reserved Region (%s): base=0x%x, size=0x%x\n", currentNode, base, size);
}
}