diff --git a/kernel/src/ACPI/AcpiSleep.cpp b/kernel/src/ACPI/AcpiSleep.cpp index c0d0550..1781f44 100644 --- a/kernel/src/ACPI/AcpiSleep.cpp +++ b/kernel/src/ACPI/AcpiSleep.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -401,8 +401,8 @@ namespace Hal { // Debug: green rectangle on framebuffer { - uint32_t* fb = ::Graphics::Cursor::GetFramebufferBase(); - uint64_t pitch = ::Graphics::Cursor::GetFramebufferPitch(); + uint32_t* fb = ::Graphics::Framebuffer::GetBase(); + uint64_t pitch = ::Graphics::Framebuffer::GetPitch(); if (fb && pitch > 0) { for (int y = 0; y < 32; y++) { uint32_t* row = (uint32_t*)((uint8_t*)fb + y * pitch); diff --git a/kernel/src/Api/BuildNo.hpp b/kernel/src/Api/BuildNo.hpp index 8812502..3ff69fa 100644 --- a/kernel/src/Api/BuildNo.hpp +++ b/kernel/src/Api/BuildNo.hpp @@ -12,4 +12,4 @@ #pragma once -#define MONTAUK_BUILD_NUMBER 132 +#define MONTAUK_BUILD_NUMBER 134 diff --git a/kernel/src/Api/Graphics.hpp b/kernel/src/Api/Graphics.hpp index 4556b62..cb6704c 100644 --- a/kernel/src/Api/Graphics.hpp +++ b/kernel/src/Api/Graphics.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include "Syscall.hpp" @@ -20,9 +20,9 @@ namespace montauk::abi { static void Sys_FbInfo(FbInfo* out) { if (out == nullptr) return; - out->width = Graphics::Cursor::GetFramebufferWidth(); - out->height = Graphics::Cursor::GetFramebufferHeight(); - out->pitch = Graphics::Cursor::GetFramebufferPitch(); + out->width = Graphics::Framebuffer::GetWidth(); + out->height = Graphics::Framebuffer::GetHeight(); + out->pitch = Graphics::Framebuffer::GetPitch(); out->bpp = 32; out->userAddr = 0; } @@ -31,20 +31,20 @@ namespace montauk::abi { auto* proc = Sched::GetCurrentProcessPtr(); if (proc == nullptr) return 0; - uint32_t* fbBase = Graphics::Cursor::GetFramebufferBase(); + uint32_t* fbBase = Graphics::Framebuffer::GetBase(); if (fbBase == nullptr) return 0; uint64_t fbPhys = Memory::SubHHDM((uint64_t)fbBase); - uint64_t fbSize = Graphics::Cursor::GetFramebufferHeight() - * Graphics::Cursor::GetFramebufferPitch(); + uint64_t fbSize = Graphics::Framebuffer::GetHeight() + * Graphics::Framebuffer::GetPitch(); uint64_t numPages = (fbSize + 0xFFF) / 0x1000; Kt::KernelLogStream(Kt::INFO, "FbMap") << "fbPhys=" << kcp::hex << fbPhys << " size=" << kcp::dec << fbSize << " pages=" << numPages - << " (" << Graphics::Cursor::GetFramebufferWidth() - << "x" << Graphics::Cursor::GetFramebufferHeight() - << " pitch=" << Graphics::Cursor::GetFramebufferPitch() << ")"; + << " (" << Graphics::Framebuffer::GetWidth() + << "x" << Graphics::Framebuffer::GetHeight() + << " pitch=" << Graphics::Framebuffer::GetPitch() << ")"; // Map at a fixed user VA constexpr uint64_t userVa = 0x50000000ULL; diff --git a/kernel/src/Api/Power.hpp b/kernel/src/Api/Power.hpp index b0c410f..6b4b227 100644 --- a/kernel/src/Api/Power.hpp +++ b/kernel/src/Api/Power.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include diff --git a/kernel/src/Drivers/Graphics/IntelGPU.cpp b/kernel/src/Drivers/Graphics/IntelGPU.cpp index 881ff18..a0da217 100644 --- a/kernel/src/Drivers/Graphics/IntelGPU.cpp +++ b/kernel/src/Drivers/Graphics/IntelGPU.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include using namespace Kt; @@ -266,9 +266,9 @@ namespace Drivers::Graphics::IntelGPU { // If we still don't have valid dimensions, fall back to the firmware framebuffer if (g_fbWidth == 0 || g_fbHeight == 0 || g_fbPitch == 0) { - g_fbWidth = ::Graphics::Cursor::GetFramebufferWidth(); - g_fbHeight = ::Graphics::Cursor::GetFramebufferHeight(); - g_fbPitch = ::Graphics::Cursor::GetFramebufferPitch(); + g_fbWidth = ::Graphics::Framebuffer::GetWidth(); + g_fbHeight = ::Graphics::Framebuffer::GetHeight(); + g_fbPitch = ::Graphics::Framebuffer::GetPitch(); KernelLogStream(INFO, "IntelGPU") << "Using firmware framebuffer dimensions: " << base::dec << g_fbWidth << "x" << g_fbHeight @@ -398,7 +398,7 @@ namespace Drivers::Graphics::IntelGPU { // This keeps the same physical memory that the firmware set up (contiguous // pages, already HHDM-mapped), so both kernel and userspace access continue // to work via the original virtual/physical addresses. No copy is needed. - uint32_t* fwFb = ::Graphics::Cursor::GetFramebufferBase(); + uint32_t* fwFb = ::Graphics::Framebuffer::GetBase(); if (fwFb == nullptr) { KernelLogStream(ERROR, "IntelGPU") << "No firmware framebuffer available"; return false; @@ -570,9 +570,9 @@ namespace Drivers::Graphics::IntelGPU { ProgramDisplayPlane(); g_initialized = true; - uint64_t fwWidth = ::Graphics::Cursor::GetFramebufferWidth(); - uint64_t fwHeight = ::Graphics::Cursor::GetFramebufferHeight(); - uint64_t fwPitch = ::Graphics::Cursor::GetFramebufferPitch(); + uint64_t fwWidth = ::Graphics::Framebuffer::GetWidth(); + uint64_t fwHeight = ::Graphics::Framebuffer::GetHeight(); + uint64_t fwPitch = ::Graphics::Framebuffer::GetPitch(); if (g_fbWidth != fwWidth || g_fbHeight != fwHeight || g_fbPitch != fwPitch) { KernelLogStream(WARNING, "IntelGPU") << "GPU dimensions differ from firmware!"; @@ -633,9 +633,9 @@ namespace Drivers::Graphics::IntelGPU { g_initialized = true; // Diagnostic: compare GPU-detected values with firmware/Limine values - uint64_t fwWidth = ::Graphics::Cursor::GetFramebufferWidth(); - uint64_t fwHeight = ::Graphics::Cursor::GetFramebufferHeight(); - uint64_t fwPitch = ::Graphics::Cursor::GetFramebufferPitch(); + uint64_t fwWidth = ::Graphics::Framebuffer::GetWidth(); + uint64_t fwHeight = ::Graphics::Framebuffer::GetHeight(); + uint64_t fwPitch = ::Graphics::Framebuffer::GetPitch(); if (g_fbWidth != fwWidth || g_fbHeight != fwHeight || g_fbPitch != fwPitch) { KernelLogStream(WARNING, "IntelGPU") << "GPU dimensions differ from firmware!"; diff --git a/kernel/src/Drivers/Init.cpp b/kernel/src/Drivers/Init.cpp index 55cafdf..5151e15 100644 --- a/kernel/src/Drivers/Init.cpp +++ b/kernel/src/Drivers/Init.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include @@ -176,7 +176,7 @@ namespace Drivers { void InitializeGraphics() { if (Graphics::IntelGPU::IsInitialized()) { - ::Graphics::Cursor::SetFramebuffer( + ::Graphics::Framebuffer::Set( Graphics::IntelGPU::GetFramebufferBase(), Graphics::IntelGPU::GetWidth(), Graphics::IntelGPU::GetHeight(), diff --git a/kernel/src/Graphics/Cursor.hpp b/kernel/src/Graphics/Cursor.hpp deleted file mode 100644 index 3183593..0000000 --- a/kernel/src/Graphics/Cursor.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Cursor.hpp - * Framebuffer information storage - * Copyright (c) 2025 Daniel Hammer -*/ - -#pragma once -#include -#include - -namespace Graphics::Cursor { - - void Initialize(const montauk::boot::Framebuffer& framebuffer); - - uint32_t* GetFramebufferBase(); - uint64_t GetFramebufferWidth(); - uint64_t GetFramebufferHeight(); - uint64_t GetFramebufferPitch(); - - void SetFramebuffer(uint32_t* base, uint64_t width, uint64_t height, uint64_t pitch); - uint64_t GetFramebufferPhysBase(); - - void MapWriteCombining(); - -}; diff --git a/kernel/src/Graphics/Cursor.cpp b/kernel/src/Graphics/Framebuffer.cpp similarity index 77% rename from kernel/src/Graphics/Cursor.cpp rename to kernel/src/Graphics/Framebuffer.cpp index 8926081..d896510 100644 --- a/kernel/src/Graphics/Cursor.cpp +++ b/kernel/src/Graphics/Framebuffer.cpp @@ -1,16 +1,16 @@ /* - * Cursor.cpp + * Framebuffer.cpp * Framebuffer information storage * Copyright (c) 2025 Daniel Hammer */ -#include "Cursor.hpp" +#include "Framebuffer.hpp" #include #include #include #include -namespace Graphics::Cursor { +namespace Graphics::Framebuffer { // Framebuffer state static uint32_t* g_FbBase = nullptr; @@ -28,12 +28,12 @@ namespace Graphics::Cursor { << (uint64_t)g_FbWidth << "x" << (uint64_t)g_FbHeight << ")"; } - uint32_t* GetFramebufferBase() { return g_FbBase; } - uint64_t GetFramebufferWidth() { return g_FbWidth; } - uint64_t GetFramebufferHeight() { return g_FbHeight; } - uint64_t GetFramebufferPitch() { return g_FbPitch; } + uint32_t* GetBase() { return g_FbBase; } + uint64_t GetWidth() { return g_FbWidth; } + uint64_t GetHeight() { return g_FbHeight; } + uint64_t GetPitch() { return g_FbPitch; } - void SetFramebuffer(uint32_t* base, uint64_t width, uint64_t height, uint64_t pitch) { + void Set(uint32_t* base, uint64_t width, uint64_t height, uint64_t pitch) { g_FbBase = base; g_FbWidth = width; g_FbHeight = height; @@ -42,12 +42,12 @@ namespace Graphics::Cursor { << (uint64_t)g_FbWidth << "x" << (uint64_t)g_FbHeight << ")"; } - uint64_t GetFramebufferPhysBase() { + uint64_t GetPhysBase() { return Memory::SubHHDM((uint64_t)g_FbBase); } void MapWriteCombining() { - uint64_t fbPhys = GetFramebufferPhysBase(); + uint64_t fbPhys = GetPhysBase(); uint64_t fbSize = g_FbHeight * g_FbPitch; uint64_t numPages = (fbSize + 0xFFF) / 0x1000; diff --git a/kernel/src/Graphics/Framebuffer.hpp b/kernel/src/Graphics/Framebuffer.hpp new file mode 100644 index 0000000..28dc238 --- /dev/null +++ b/kernel/src/Graphics/Framebuffer.hpp @@ -0,0 +1,25 @@ +/* + * Framebuffer.hpp + * Framebuffer information storage + * Copyright (c) 2025 Daniel Hammer +*/ + +#pragma once +#include +#include + +namespace Graphics::Framebuffer { + + void Initialize(const montauk::boot::Framebuffer& framebuffer); + + uint32_t* GetBase(); + uint64_t GetWidth(); + uint64_t GetHeight(); + uint64_t GetPitch(); + + void Set(uint32_t* base, uint64_t width, uint64_t height, uint64_t pitch); + uint64_t GetPhysBase(); + + void MapWriteCombining(); + +}; diff --git a/kernel/src/Main.cpp b/kernel/src/Main.cpp index fbed18c..a5ff48c 100644 --- a/kernel/src/Main.cpp +++ b/kernel/src/Main.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -125,14 +125,14 @@ extern "C" void kmain() { #endif - // Initialize Cursor early so we can WC-map the framebuffer before + // Initialize the framebuffer early so we can WC-map it before // the bulk of boot logging begins (ACPI, PCI, drivers, etc.) - Graphics::Cursor::Initialize(framebuffer); + Graphics::Framebuffer::Initialize(framebuffer); #if defined (__x86_64__) // Map framebuffer as Write-Combining immediately for faster screen writes. // All subsequent log output benefits from WC burst transfers. - Graphics::Cursor::MapWriteCombining(); + Graphics::Framebuffer::MapWriteCombining(); #endif Hal::ACPI g_acpi((Hal::ACPI::XSDP*)Memory::HHDM(boot.rsdpPhysical)); diff --git a/kernel/src/Memory/Paging.cpp b/kernel/src/Memory/Paging.cpp index b123b47..9f68626 100644 --- a/kernel/src/Memory/Paging.cpp +++ b/kernel/src/Memory/Paging.cpp @@ -69,9 +69,9 @@ namespace Memory::VMM { // just mapped (e.g. in the 32-bit MMIO hole), and it is not guaranteed // to appear as a memory-map region. It MUST be reachable through the // HHDM before we switch to these page tables, because the very next log - // line (and PAT setup, and Cursor init) renders to it via phys+hhdmBase. - // Map its pages explicitly (write-back for now; Cursor upgrades them to - // write-combining once PAT is reprogrammed). + // line (and PAT setup, and framebuffer init) renders to it via phys+hhdmBase. + // Map its pages explicitly (write-back for now; the framebuffer module + // upgrades them to write-combining once PAT is reprogrammed). if (framebuffer.address != 0) { uint64_t fbPhys = Memory::SubHHDM(framebuffer.address); uint64_t fbBytes = framebuffer.height * framebuffer.pitch; diff --git a/kernel/src/Terminal/Terminal.cpp b/kernel/src/Terminal/Terminal.cpp index 2cd6532..e147b57 100644 --- a/kernel/src/Terminal/Terminal.cpp +++ b/kernel/src/Terminal/Terminal.cpp @@ -201,8 +201,6 @@ namespace Kt { // Install our universal plot_char so rescaling works at any scale struct flanterm_fb_context *fbctx = (struct flanterm_fb_context *)ctx; fbctx->plot_char = plot_char_universal; - - kout << "\n\n\n"; } void Putchar(char c) {