System Calls cleanup, multiple Processes and context switch
[cortex-from-scratch] / heap.c
1 /* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
2  * 
3  * $LOG$
4  * 2019/10/20 - ROBIN KRENS     
5  * Initial version 
6  * 
7  * $DESCRIPTION$
8  *      
9  * kalloc();
10  * kfree(); 
11  *
12  */
13
14 #include <stdbool.h>
15 #include <stddef.h>
16 #include <stdint.h>
17
18 #include <lib/pool.h>
19
20 #define BLOCKSIZE       0x10
21 #define BLOCKS          10
22 /* #define KHEAP_SIZE   0x100 SEE LINK.LD */
23
24 static mem_pool_t kheap_pool;
25
26 void kheap_init() {
27         
28         extern unsigned char * _beginofheap;
29         pool_init(&kheap_pool, BLOCKSIZE, BLOCKS, (unsigned char *) &_beginofheap);
30         //kalloc = &alloc;
31 }
32
33 void * kalloc(void * s) {
34
35         return alloc(s);
36 }
37
38 void kfree(void * s, void * p) {
39
40         free(s, p);
41 }
42
43 void kheap_info(void *s) {
44
45         heap_info(s);
46 }
47
48 void * get_kheap() {
49
50         return (void *) &kheap_pool;
51 }
52
53
54