diff options
Diffstat (limited to '02-usart/include/kern/mem.h')
-rw-r--r-- | 02-usart/include/kern/mem.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/02-usart/include/kern/mem.h b/02-usart/include/kern/mem.h new file mode 100644 index 0000000..d150744 --- /dev/null +++ b/02-usart/include/kern/mem.h @@ -0,0 +1,30 @@ +#ifndef MEM_H_ +#define MEM_H_ + +#include "arch.h" +#include <stddef.h> + +#define DATA_SEGMENT_STOP_ADDR ((uint8_t*) &DATA_SEGMENT_STOP) +#define DATA_SEGMENT_START_ADDR ((uint8_t*) &DATA_SEGMENT_START) + +#define MAX_HEAP_SIZE \ + ((16384 - (DATA_SEGMENT_STOP_ADDR - DATA_SEGMENT_START_ADDR)) / 4 * 4) + +/* allocates memory on the head, which is stored in sram2 */ +void* halloc(size_t n); + +/* Frees the memory allocated by halloc. */ +void hfree(void* mem); + +#ifdef FOR_TESTING + +void* debug_halloc_get_next_ptr(void* ptr); + +void* debug_halloc_get_prev_ptr(void* ptr); + +int debug_halloc_assert_consistency(char* error, size_t len); + +#endif + + +#endif |