diff --git a/docs/IMPLEMENTATION_SUMMARY.md b/docs/IMPLEMENTATION_SUMMARY.md index c355d8b..b5a16da 100644 --- a/docs/IMPLEMENTATION_SUMMARY.md +++ b/docs/IMPLEMENTATION_SUMMARY.md @@ -35,7 +35,7 @@ - Bitmap-based physical page allocator - Bump allocator for kernel heap (1MB) - Memory utilities (memset, memcpy, memcmp) - - Support for up to 128MB RAM + - Support for up to 64GB RAM #### PCI Bus Support - Files: `kernel/src/pci.c`, `kernel/include/kernel/pci.h` diff --git a/docs/KERNEL_REFERENCE.md b/docs/KERNEL_REFERENCE.md index eeeb527..3b966e6 100644 --- a/docs/KERNEL_REFERENCE.md +++ b/docs/KERNEL_REFERENCE.md @@ -158,7 +158,7 @@ if (gpu) { - **No Console Module**: As requested, no console.c/h files are created - **Minimal Design**: Only essential features for QT6 Hello World - **Bump Allocator**: Current heap doesn't support freeing (upgrade later if needed) -- **Physical Memory**: Simple bitmap allocator (32768 pages max in current impl) +- **Physical Memory**: Simple bitmap allocator (supports up to 64GB with 2MB bitmap) - **PCI Scan**: Scans all 256 buses, 32 devices per bus - **Timer**: Uses PIT in rate generator mode diff --git a/kernel/include/kernel/memory.h b/kernel/include/kernel/memory.h index 209760c..551ba33 100644 --- a/kernel/include/kernel/memory.h +++ b/kernel/include/kernel/memory.h @@ -18,8 +18,8 @@ * - 0 = page is free and available for allocation * - 1 = page is in use * - * The bitmap supports up to 128MB of physical memory (32768 bytes * 8 bits/byte - * * 4KB per page = 128MB). Memory is assumed to start at physical address 0x01000000 + * The bitmap supports up to 64GB of physical memory (2097152 bytes * 8 bits/byte + * * 4KB per page = 64GB). Memory is assumed to start at physical address 0x01000000 * (16MB) to avoid conflicts with legacy hardware and the kernel itself. * * This is a very simple allocator suitable for a minimal kernel. It does not: @@ -29,7 +29,7 @@ */ class PhysicalMemoryManager { private: - uint8_t pageBitmap[32768]; ///< Bitmap tracking page allocation (128MB / 4KB pages) + uint8_t pageBitmap[2097152]; ///< Bitmap tracking page allocation (64GB / 4KB pages = 16M pages = 2MB bitmap) uint64_t totalPages; ///< Total number of pages managed uint64_t usedPages; ///< Number of pages currently allocated @@ -39,8 +39,8 @@ public: /** * @brief Initialize the physical memory manager with boot information - * @param bootInfo Boot information from bootloader (currently unused, assumes 128MB) - * @note Currently hardcoded to manage 128MB starting at 16MB physical address + * @param bootInfo Boot information from bootloader (currently unused, assumes up to 64GB) + * @note Currently hardcoded to manage up to 64GB starting at 16MB physical address */ void init(BootInfo* bootInfo); diff --git a/kernel/src/memory.cpp b/kernel/src/memory.cpp index de8aa27..8010cc9 100644 --- a/kernel/src/memory.cpp +++ b/kernel/src/memory.cpp @@ -10,7 +10,7 @@ #include "kernel/memory.h" // Physical memory bitmap constants -#define BITMAP_SIZE 32768 // Supports up to 128MB with 4KB pages +#define BITMAP_SIZE 2097152 // Supports up to 64GB with 4KB pages (64GB / 4KB = 16M pages, 16M bits = 2MB bitmap) /* PhysicalMemoryManager class implementation */ @@ -28,7 +28,7 @@ PhysicalMemoryManager::PhysicalMemoryManager() * @brief Initialize the physical memory manager * * Currently uses a simplified approach: - * - Assumes 128MB of usable RAM starting at physical address 16MB (0x01000000) + * - Assumes up to 64GB of usable RAM starting at physical address 16MB (0x01000000) * - Clears the entire page bitmap to mark all pages as free * - TODO: Parse the UEFI memory map from bootInfo to properly detect available memory * @@ -41,8 +41,9 @@ PhysicalMemoryManager::PhysicalMemoryManager() void PhysicalMemoryManager::init(BootInfo* bootInfo) { (void)bootInfo; // TODO: Parse UEFI memory map - // For now, assume 128MB of usable memory starting at 16MB - totalPages = (128 * 1024 * 1024) / PAGE_SIZE; + // For now, assume 64GB of usable memory starting at 16MB + // This supports any amount up to 64GB + totalPages = (64ULL * 1024 * 1024 * 1024) / PAGE_SIZE; // Clear bitmap for (uint64_t i = 0; i < BITMAP_SIZE; i++) {