Mercurial > lcfOS
diff cos/kernel/kernel.c @ 20:b1fed2171e1a
Now working with 2 MB pages
author | windel |
---|---|
date | Mon, 28 Nov 2011 20:54:40 +0100 |
parents | f454e3c592dd |
children | 69bc6d477b38 |
line wrap: on
line diff
--- a/cos/kernel/kernel.c Sun Nov 27 21:38:38 2011 +0100 +++ b/cos/kernel/kernel.c Mon Nov 28 20:54:40 2011 +0100 @@ -131,16 +131,16 @@ of the kernel into smaller parts. The heap is located at: 0x */ -static void* kernel_heap = (void*) 0xD0000000; +static void* kernel_heap = (void*) 0x400000; // 4 MB - 6 MB is heap /* Allocates 'size' bytes and returns the pointer if succesfull. Kernelpanic in case of failure.. */ -void* malloc(uint64_t size) { +void* kmalloc(uint64_t size) { printf("Malloc %d bytes\n", size); return kernel_heap; } -void free(void* ptr) { +void kfree(void* ptr) { printf("Free address %x\n", ptr); } @@ -150,6 +150,19 @@ } +void testMalloc() +{ + char *a, *b; + a = kmalloc(100); + printf("Got a at %x\n", a); + a[0] = 'A'; + b = kmalloc(22); + printf("Got b at %x\n", b); + b[0] = 'B'; + kfree(a); + +} + void kmain() { init_screen(); @@ -157,6 +170,8 @@ printf("Enabling interrupts .. "); setupIDT(); + printf("Testing malloc"); + testMalloc(); printf("Entering mainloop!\n"); while (1==1)