|
PatchworkOS
|
#include "heap.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/bitmap.h>#include <sys/io.h>#include <sys/math.h>#include <sys/proc.h>#include <threads.h>Go to the source code of this file.
Functions | |
| void * | _heap_map_memory (uint64_t size) |
| Directly maps memory of the given size. | |
| void | _heap_unmap_memory (void *addr, uint64_t size) |
| Unmaps previously mapped memory. | |
| void | _heap_init (void) |
| Initialize the heap. | |
| void | _heap_acquire (void) |
| Acquire the heap lock. | |
| void | _heap_release (void) |
| Release the heap lock. | |
| uint64_t | _heap_get_bin_index (uint64_t size) |
| Get the bin index for a given size. | |
| _heap_header_t * | _heap_block_new (uint64_t minSize) |
Directly maps a new heap block of at least minSize bytes. | |
| void | _heap_block_split (_heap_header_t *block, uint64_t newSize) |
Splits a heap block into two blocks, the first of size bytes and the second with the remaining bytes. | |
| void | _heap_add_to_free_list (_heap_header_t *block) |
| Adds a block to the appropriate free list. | |
| void | _heap_remove_from_free_list (_heap_header_t *block) |
| Removes a block from its free list. | |
| _heap_header_t * | _heap_alloc (uint64_t size) |
| Allocates a block of memory of given size. | |
| void | _heap_free (_heap_header_t *block) |
| Frees a previously allocated heap block. | |
Variables | |
| static mtx_t | mutex |
| static fd_t | zeroDev = ERR |
| static list_t | freeLists [_HEAP_NUM_BINS] = {0} |
| static bitmap_t | freeBitmap = {0} |
| static uint64_t | freeBitmapBuffer [BITMAP_BITS_TO_QWORDS(_HEAP_NUM_BINS)] = {0} |
| list_t | _heapList = LIST_CREATE(_heapList) |
| A list of all blocks sorted by address. | |
|
static |
Definition at line 57 of file heap.c.
Referenced by _heap_add_to_free_list(), _heap_alloc(), _heap_init(), and _heap_remove_from_free_list().
|
static |
Definition at line 58 of file heap.c.
Referenced by _heap_init().
|
static |
Definition at line 56 of file heap.c.
Referenced by _heap_add_to_free_list(), _heap_alloc(), _heap_init(), and _heap_remove_from_free_list().
|
static |
Definition at line 35 of file heap.c.
Referenced by _heap_acquire(), _heap_init(), _heap_release(), aml_def_acquire_read(), aml_mutex_acquire(), aml_mutex_id_deinit(), aml_mutex_id_init(), aml_mutex_release(), mtx_destroy(), mtx_init(), mtx_lock(), mtx_unlock(), rwmutex_read_cleanup(), and rwmutex_write_cleanup().
Definition at line 37 of file heap.c.
Referenced by _heap_init(), and _heap_map_memory().