Mercurial > lcfOS
diff kernel/src/memory.c3 @ 393:6ae782a085e0
Added init program
author | Windel Bouwman |
---|---|
date | Sat, 17 May 2014 21:17:40 +0200 |
parents | 2ec730e45ea1 |
children |
line wrap: on
line diff
--- a/kernel/src/memory.c3 Fri May 16 13:05:10 2014 +0200 +++ b/kernel/src/memory.c3 Sat May 17 21:17:40 2014 +0200 @@ -5,17 +5,33 @@ var int ptr; +// Let the heap grow upwards.. + function void init() { - ptr = 0; - // io.print2("ptr = ", ptr); - // TODO + ptr = 0x80000; } -function u8* Alloc(int size) +function u8* alloc(int size) { + var int ptr2; + ptr2 = ptr; + + io.print2("alloc size ", size); + io.print2("alloc address ", ptr); + + // Increment new free point: ptr = ptr + size; - return cast<u8*>(ptr); + return cast<u8*>(ptr2); } +function void memcpy(u8* dst, u8* src, int size) +{ + // + var int i; + for (i = 0; i < size; i = i + 1) + { + *(dst + i) = *(src + i); + } +}