Implement kernel memory allocator (kmalloc/kfree) and freestanding string library (AI)
- Added first-fit free-list allocator with block splitting and coalescing. Provides kmalloc(), kfree(), and kcalloc() for kernel-space dynamic memory. - Each block carries an inline header with a magic value (0xCAFEBABE) for heap corruption detection, plus double-free checking. - Memory is obtained from the paging subsystem in 4 KiB page increments. All allocations are 8-byte aligned with a 16-byte minimum block size. - Created freestanding string.c with memset, memcpy, memmove, memcmp, strlen, strcmp, strncmp, strcpy, strncpy — replacing the unavailable libc implementations. - Added documentation in docs/kmalloc.md. Tested: kmalloc(64) returns 0xD0001010 (in kernel heap) and kfree succeeds. Works with both 4 MiB and 128 MiB RAM.
This commit is contained in:
@@ -46,7 +46,7 @@ Once a task is completed, it should be checked off.
|
||||
- [x] Implement a PIC handler
|
||||
- [x] Create a physical memory allocator and mapper. The kernel should live in the upper last gigabyte of virtual memory. It should support different zones (e.g.: `SUB_16M`, `DEFAULT`, ...) These zones describe the region of memory that memory should be allocated in. If it is not possible to allocate in that region (because it is full, or has 0 capacity to begin with), it should fallback to another zone.
|
||||
- [x] Create a paging subsystem. It should allow drivers to allocate and deallocate pages at will.
|
||||
- [ ] Create a memory allocator. This should provide the kernel with `malloc` and `free`. Internally, it should use the paging subsystem to ensure that the address it returns have actual RAM paged to them.
|
||||
- [x] Create a memory allocator. This should provide the kernel with `malloc` and `free`. Internally, it should use the paging subsystem to ensure that the address it returns have actual RAM paged to them.
|
||||
- [ ] Create an initial driver architecture, allowing different drivers included in the kernel to test whether they should load or not.
|
||||
- [ ] Create a VGA driver. On startup, some memory statistics should be displayed, as well as boot progress.
|
||||
- [ ] Create subsystem for loading new processes in Ring 3.
|
||||
|
||||
Reference in New Issue
Block a user