Add allocator
diff --git a/src/kernel/main.c b/src/kernel/main.c
index a866852..9485def 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -1,9 +1,10 @@
+#include "alloc.h"
#include "descriptor_tables.h"
#include "io.h"
#include "log.h"
+#include "paging.h"
#include "timer.h"
#include "vga.h"
-#include "paging.h"
int kmain(void *mboot)
{
@@ -22,20 +23,34 @@
vga_set_color(WHITE, BLACK);
init_timer(20);
-
+ init_allocator();
init_kbd();
+
+ // Test allocator
+
+ int *one = malloc(sizeof(int));
+ int *two = malloc(sizeof(int));
+
+ *one = 1;
+ *two = 2;
+
+ int *array = malloc(sizeof(int[12]));
+
+ for (int i = 0; i < 12; i++)
+ array[i] = i;
+
+ kprintf("Allocated one, two, array[3] = %d, %d, %d\n", *one, *two,
+ array[3]);
+ kprintf("[%x, %x, %x]\n", one, two, array);
+
+ kprintf("Freeing two\n");
+ free(two);
+ int *four = malloc(sizeof(int));
+ *four = 4;
+ kprintf("Allocated four = %d (%x)\n", *four, four);
+
asm volatile("sti");
-
-#ifdef TEST_PAGE_FAULT
- kprintf("Causing page fault:\n");
-
- volatile uint *ptr = (uint *) 0xa0000000;
- volatile uint cause_page_fault = *ptr;
-
- kprintf("Should have caused page fault: %d...\n", cause_page_fault);
-#endif
-
while (true)
asm volatile("hlt");