Implement paging subsystem with identity mapping and kernel heap (AI)

- Created two-level x86 paging (page directory + page tables) with 4 KiB pages.
- Identity maps all detected physical memory in two phases:
  1) Static: first 16 MiB using 4 BSS-allocated page tables (avoids
     chicken-and-egg with PMM bitmap in BSS).
  2) Dynamic: memory above 16 MiB using PMM-allocated page tables,
     created before paging is enabled so physical addresses still work.
- Provides kernel heap at 0xD0000000–0xF0000000 for virtual page allocation.
- API: paging_map_page, paging_unmap_page, paging_alloc_page, paging_free_page,
  paging_get_physical.
- Added pmm_get_memory_size() to expose detected RAM for paging init.
- Kernel tests paging by allocating a virtual page, writing 0xDEADBEEF, and
  reading it back, then freeing it.
- Added documentation in docs/paging.md.

Tested: boots and passes paging test with both 4 MiB and 128 MiB RAM in QEMU.
This commit is contained in:
AI
2026-02-23 11:03:27 +00:00
parent f2e7d6c5d7
commit fb61ab7c15
8 changed files with 467 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ add_executable(kernel
isr.c
pic.c
pmm.c
paging.c
interrupts.S
kernel.c
)