#include "Memmap.hpp" #include #include #include "Heap.hpp" using namespace Kt; namespace Memory { LargestSection Scan(const montauk::boot::MemoryMap& mmap) { LargestSection currentLargestSection{}; for (size_t i = 0; i < mmap.count; i++) { const auto& entry = mmap.regions[i]; if (entry.base == 0) { continue; } if (entry.kind == montauk::boot::MemoryKind::Usable) { if (entry.length > currentLargestSection.size) { currentLargestSection = { .address = entry.base, .size = entry.length }; } } } [[unlikely]] if (currentLargestSection.address == 0) { Panic("Couldn't find a usable memory section.", nullptr); } return currentLargestSection; } };