blob: 9485def1765c0dd095b395e687c6b865ba7f6978 [file] [log] [blame]
swissChilie4f01992021-02-25 15:38:12 -08001#include "alloc.h"
swissChilid8137922021-02-17 15:34:07 -08002#include "descriptor_tables.h"
swissChili825d46b2021-02-21 10:14:16 -08003#include "io.h"
4#include "log.h"
swissChilie4f01992021-02-25 15:38:12 -08005#include "paging.h"
swissChilidefeb0d2021-02-18 15:28:36 -08006#include "timer.h"
swissChili825d46b2021-02-21 10:14:16 -08007#include "vga.h"
swissChilid8137922021-02-17 15:34:07 -08008
swissChili0b35bf22021-02-18 12:49:40 -08009int kmain(void *mboot)
swissChilid8137922021-02-17 15:34:07 -080010{
swissChilie0a79bb2021-02-22 19:54:48 -080011 init_paging();
swissChilidc25b2b2021-02-23 17:07:13 -080012 init_vga();
swissChilid3a652e2021-02-21 22:16:06 -080013
swissChilid8137922021-02-17 15:34:07 -080014 vga_clear();
15 vga_set_color(LIGHT_BLUE, BLACK);
16 vga_write("Hello!\nWelcome to Bluejay OS\n");
swissChilid8137922021-02-17 15:34:07 -080017 vga_set_color(WHITE, BLACK);
18
swissChili0b35bf22021-02-18 12:49:40 -080019 init_descriptor_tables();
swissChilid8137922021-02-17 15:34:07 -080020
swissChili0b35bf22021-02-18 12:49:40 -080021 vga_set_color(LIGHT_GREEN, BLACK);
22 vga_write("Setup complete!\n");
23 vga_set_color(WHITE, BLACK);
swissChilid8137922021-02-17 15:34:07 -080024
swissChili825d46b2021-02-21 10:14:16 -080025 init_timer(20);
swissChilie4f01992021-02-25 15:38:12 -080026 init_allocator();
swissChili19ef4182021-02-21 17:45:51 -080027 init_kbd();
swissChilie4f01992021-02-25 15:38:12 -080028
29 // Test allocator
30
31 int *one = malloc(sizeof(int));
32 int *two = malloc(sizeof(int));
33
34 *one = 1;
35 *two = 2;
36
37 int *array = malloc(sizeof(int[12]));
38
39 for (int i = 0; i < 12; i++)
40 array[i] = i;
41
42 kprintf("Allocated one, two, array[3] = %d, %d, %d\n", *one, *two,
43 array[3]);
44 kprintf("[%x, %x, %x]\n", one, two, array);
45
46 kprintf("Freeing two\n");
47 free(two);
48 int *four = malloc(sizeof(int));
49 *four = 4;
50 kprintf("Allocated four = %d (%x)\n", *four, four);
51
swissChilidefeb0d2021-02-18 15:28:36 -080052 asm volatile("sti");
53
swissChili825d46b2021-02-21 10:14:16 -080054 while (true)
55 asm volatile("hlt");
56
swissChilid8137922021-02-17 15:34:07 -080057 return 0xCAFEBABE;
58}