aboutsummaryrefslogtreecommitdiff
path: root/include/kern/mem.h
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2020-11-24 13:46:41 -0700
committerJosh Rahm <joshuarahm@gmail.com>2020-11-24 13:46:41 -0700
commit93b063fedfcf7409a67df035170ea5670cad22e1 (patch)
treea23321a7465d966b1ccf196ca00e65a70c9f9110 /include/kern/mem.h
parentb040195d31df6ad759f16ea3456471897f55daa1 (diff)
downloadstm32l4-93b063fedfcf7409a67df035170ea5670cad22e1.tar.gz
stm32l4-93b063fedfcf7409a67df035170ea5670cad22e1.tar.bz2
stm32l4-93b063fedfcf7409a67df035170ea5670cad22e1.zip
Moved action to top level.
Removed old iterations of the project and moved the files from 02-usart to the root directory since that's the sole place where the action is and that subproject has outgrown its initial title.
Diffstat (limited to 'include/kern/mem.h')
-rw-r--r--include/kern/mem.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/kern/mem.h b/include/kern/mem.h
new file mode 100644
index 0000000..c0999f5
--- /dev/null
+++ b/include/kern/mem.h
@@ -0,0 +1,32 @@
+#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);
+
+void debug_print_blocks();
+
+#endif
+
+
+#endif