cleanup: move some logic out of kernel Main.cpp into separate files/functions

This commit is contained in:
2026-03-03 20:30:59 +01:00
parent 144ae2a843
commit b0e6dd040d
6 changed files with 110 additions and 53 deletions
+18
View File
@@ -7,6 +7,8 @@
#include "Cursor.hpp"
#include <Terminal/Terminal.hpp>
#include <Memory/HHDM.hpp>
#include <Memory/Paging.hpp>
#include <CppLib/Stream.hpp>
namespace Graphics::Cursor {
@@ -44,4 +46,20 @@ namespace Graphics::Cursor {
return Memory::SubHHDM((uint64_t)g_FbBase);
}
void MapWriteCombining() {
uint64_t fbPhys = GetFramebufferPhysBase();
uint64_t fbSize = g_FbHeight * g_FbPitch;
uint64_t numPages = (fbSize + 0xFFF) / 0x1000;
for (uint64_t i = 0; i < numPages; i++) {
uint64_t phys = fbPhys + i * 0x1000;
Memory::VMM::g_paging->MapWC(phys, Memory::HHDM(phys));
}
Memory::VMM::FlushTLB();
Kt::KernelLogStream(Kt::OK, "Graphics") << "Framebuffer mapped as Write-Combining ("
<< kcp::dec << numPages << " pages)";
}
};
+2
View File
@@ -20,4 +20,6 @@ namespace Graphics::Cursor {
void SetFramebuffer(uint32_t* base, uint64_t width, uint64_t height, uint64_t pitch);
uint64_t GetFramebufferPhysBase();
void MapWriteCombining();
};