aboutsummaryrefslogtreecommitdiff
path: root/include/kern/mem.h
blob: 832d31de1df07982f0898e3f3cebbd8bdfa16929 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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* kalloc(size_t n);

/* Frees the memory allocated by kalloc. */
void kfree(void* mem);

#ifdef FOR_TESTING

void* debug_kalloc_get_next_ptr(void* ptr);

void* debug_kalloc_get_prev_ptr(void* ptr);

int debug_kalloc_assert_consistency(char* error, size_t len);

void debug_print_blocks();

#endif


#endif