From cd8704eabcfbcdfc3e0d2cf964846c67d3513d26 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Sun, 12 Feb 2023 13:46:52 +0100 Subject: [PATCH] docs: documented the heap --- .wiki/Kernel-documentation.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.wiki/Kernel-documentation.md b/.wiki/Kernel-documentation.md index 8b18b4a..ebde07e 100644 --- a/.wiki/Kernel-documentation.md +++ b/.wiki/Kernel-documentation.md @@ -240,6 +240,37 @@ More information can be found on the limine project's [GitHub](https://github.co ## mm +### heap.h + +#### `heap_segment_T` - struct +This is the header for each heap segment. +It holds its status information and a pointer to the next and previous segments. +It lies in memory, directly before the accessible buffer of the segment. + +#### `heap_T` - struct +This struct describes a heap. +The area between **_start_** and **_end_** is filled with heap segments. + +#### `heap_create(base)` - function (void) +Creates a heap starting at **_base_** (virtual address). +It will automatically map some page frames to that address. + +#### `heap_memory_allocate(heap*, size)` - function (void) +Returns a pointer to a free usable memory location, that has at least the given **_size_**. +It will return `NULL` and log an error, if the heap is corrupted. +Because this function iterates over the complete heap to find a free segment, it is slow. + +#### `heap_memory_free(heap*, address)` - function (void) +Frees a with `heap_memory_allocate` created heap segment, and makes it usable again. +Does nothing, if the address doesn't point to a valid heap segment. + +#### `heap_dump_segments(heap*)` - function (void) +Logs a complete list, of all heap segments. +Useful, when debugging / testing the heap. + +#### `heap_destruct(heap*)` - function (void) +Invalidates all segments of a heap, frees all used page frames and unmaps them. + ### memory_map.h #### `memory_map_get_total_memory_size(boot_info*)` - function (uint64_t)