diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-07-10 11:31:46 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-07-10 11:31:46 +0800 |
| commit | e90b72ec3082588b296956730bd2930cf8d5d671 (patch) | |
| tree | 36ff6916af9b4176ea5a9662219d11e721f0b691 /include/kernel/pmm.h | |
| parent | 1767d390fbf3d0c65389de46caf0b6d43ef3b6ad (diff) | |
| download | lume-e90b72ec3082588b296956730bd2930cf8d5d671.tar.gz lume-e90b72ec3082588b296956730bd2930cf8d5d671.tar.xz | |
refactor: promote new architecture to repository root
Archive the deprecated implementation under lume-legacy, make the new kernel the default root-level build, and update repository entry points without changing kernel behavior.
Diffstat (limited to 'include/kernel/pmm.h')
| -rw-r--r-- | include/kernel/pmm.h | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/include/kernel/pmm.h b/include/kernel/pmm.h deleted file mode 100644 index 261786d..0000000 --- a/include/kernel/pmm.h +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2026 Richard Qin - */ - -#pragma once -#include "common/types.h" -#include "kernel/spinlock.h" -#include "kernel/fdt.h" // For g_devices - -// Physical Memory Layout Definition -#define KERNBASE 0x80000000 - -// Dynamic memory size from FDT -// Default to 128MB if FDT not present/parsed -extern uint64 g_phys_size; - -#define PHYSIZE (g_phys_size) -#define PHYSTOP (KERNBASE + PHYSIZE) - -// Buddy System Max Order -// Order 10 => 2^10 pages = 1024 * 4KB = 4MB contiguous block -// Order 11 => 2^11 pages = 8MB -#define MAX_ORDER 11 - -// Page flag -#define PG_used 0x01 // This page is occupied -#define PG_reserved 0x02 // This page is reserved (kernel code/data, DTB, MemMap) - -// Physical Page Metadata Structure -struct Page -{ - uint8 flags; // Page Status (PG_used, PG_reserved) - uint8 order; // If it is the first page of a free block, record the order of the current block - uint16 refcnt; // Reference Counting - struct Page *next; // Free list pointer (points to the next free block of the same size) - struct Page *prev; // Doubly linked list (easy to remove) -}; - -namespace PMM -{ - // Initialize physical memory management - void init(); - - // Core Allocation Interface (Buddy System) - // order: 0 ~ MAX_ORDER-1 - void *alloc_pages(int order); - void free_pages(void *pa, int order); - - // Compatible with old interface (allocate single page with order=0 and automatically reset to zero) - void *alloc_page(); - void free_page(void *pa); - - // Helper function - struct Page *pa_to_page(uint64 pa); - uint64 page_to_pa(struct Page *page); - - // Debug information - void print_free_lists(); -}
\ No newline at end of file |
