[feat] Simple Filesystem

This commit is contained in:
2026-05-29 19:59:41 +08:00
Unverified
parent 7f4fb6473f
commit 45693c96b5
6 changed files with 741 additions and 5 deletions
+1 -1
View File
@@ -112,7 +112,7 @@ void* kmalloc(UINTN size) {
split->size = block_sz - alloc_size;
// Insert split into free list
split->next = block->next;
block->size = alloc_size;
block->size = alloc_size | 1;
*prev = split;
} else {
// Use the whole block
+10
View File
@@ -133,6 +133,15 @@ EFI_STATUS pmm_init() {
bitmap_set((UINTN)p);
}
// Reserve low memory (first 4 MB) — UEFI firmware may use it during BS calls
UINT64 low_reserve_pages = 0x400;
for (UINT64 p = 0; p < low_reserve_pages && p < g_pmm.total_pages; p++) {
if (!bitmap_test((UINTN)p)) {
bitmap_set((UINTN)p);
g_pmm.free_pages--;
}
}
// Build free list by linking free pages
g_pmm.free_list_head = NULL;
void* prev = NULL;
@@ -145,6 +154,7 @@ EFI_STATUS pmm_init() {
for (UINT64 p = start_page; p < end_page; p++) {
if (p >= bm_start_page && p < bm_end_page) continue;
if (p < low_reserve_pages) continue;
void* page = (void*)(UINTN)(p * PAGE_SIZE);
if (prev) {
*(void**)prev = page;