From 38883485c80841f15365d0502418dcc224f01d45 Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Wed, 5 Jun 2024 23:01:19 +0200 Subject: mm: use linked-list-allocator as kmalloc I'll implement my own allocator later. Currently using linked-list allocator [1] to manage the kernel heap (as in kmalloc, not vmalloc). It manages the ID-mapped region (from VA 0xffff_8000_0000_0000). This allocator is initialized to use the _largest_ physical memory block. If the kernel image (text and data) live in this zone then skip the occupied part. Key difference between kmalloc and vmalloc: - kmalloc pretty much manages the physical memory: the allocated address are within the id-mapped region (see above) therefore the allocated memory must also be contigous in physical memory. Such memory MUST NOT page fault. This is prone to fragmentation, so do not use kmalloc to allocate big objects (e.g. bigger than one 4k page). - vmalloc manages kernel heap memory and the mapping is managed by paging. Such memory could trigger pagefault in kernel mode. Note that the kmalloc conflicts with the previous used stack based PMA as they operates on the same VM zone. References: [1] https://github.com/rust-osdev/linked-list-allocator Signed-off-by: Tianhao Wang --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 60f4228..c1daa86 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,10 @@ shitty code, I'm a rust beginner. - [X] Setting up CGA display, print something (hello world) - [X] Intigrate print into rust println! etc. - [X] Keyboard controller and input handler -- [?] Interrupt handler (WIP) -- [ ] intrrupt sync (pro-/epilogue model) +- [X] Interrupt handler +- [X] kmalloc (using the [linked-list-allocator ](https://github.com/rust-osdev/linked-list-allocator)) + TODO: implement my own +- [?] intrrupt sync (pro-/epilogue model) - [?] Threading (WIP) - [ ] Scheduler (single CPU) - [ ] Timer Interrupt -- cgit v1.2.3-70-g09d2