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:
@@ -9,6 +9,8 @@ add_executable(kernel
|
||||
pic.c
|
||||
pmm.c
|
||||
paging.c
|
||||
kmalloc.c
|
||||
string.c
|
||||
interrupts.S
|
||||
kernel.c
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user