vulcanos/kernel/kernel_main.c

62 lines
2.0 KiB
C
Raw Normal View History

2019-07-08 12:56:36 +02:00
/**************************************
* iceOS Kernel *
* Developed by Marco 'icebit' Cetica *
* (c) 2019 *
* Released under GPLv3 *
* https://github.com/ice-bit/iceOS *
***************************************/
#include "drivers/tty.h"
#include "drivers/gdt.h"
#include "drivers/idt.h"
#include "drivers/timer.h"
#include "drivers/keyboard.h"
2019-09-28 12:11:43 +02:00
#include "mem/paging.h"
#include "mem/kheap.h"
#include "shell/shell.h"
2019-07-08 20:36:53 +02:00
#include "libc/stdio.h"
2019-09-28 12:11:43 +02:00
#include "libc/multiboot.h"
#include "libc/assert.h"
#include <stdint.h>
void kernel_main() {
2019-07-08 20:36:53 +02:00
printf_color("\n[STATUS]", LIGHT_GREEN, BLACK);
printf_color(" - Loading kernel, wait please...", WHITE, BLACK);
gdt_setup(); // Setup Global Descriptor Table
2019-07-08 20:36:53 +02:00
printf_color("\n[INFO]", LIGHT_CYAN, BLACK);
printf_color(" - Loaded GDT", WHITE, BLACK);
idt_setup(); // Setup Interrupt Descriptor Table
2019-07-08 20:36:53 +02:00
printf_color("\n[INFO]", LIGHT_CYAN, BLACK);
printf_color(" - Loaded IDT", WHITE, BLACK);
init_timer(1); // Initialize PIT driver
printf_color("\n[INFO]", LIGHT_CYAN, BLACK);
printf_color(" - Loaded PIT", WHITE, BLACK);
2019-07-08 20:36:53 +02:00
init_keyboard(); // Initialize keyboard driver
printf_color("\n[INFO]", LIGHT_CYAN, BLACK);
printf_color(" - Loaded PS/2 driver", WHITE, BLACK);
2019-09-28 12:11:43 +02:00
init_paging(); // Initialize paging
2019-09-28 12:11:43 +02:00
printf_color("\n[INFO]", LIGHT_CYAN, BLACK);
printf_color(" - Loaded Paging", WHITE, BLACK);
2019-07-08 20:36:53 +02:00
printf_color("\n[TEST]", LIGHT_BROWN, BLACK); // Testing heap
printf_color(" - Testing heap..\n", LIGHT_BROWN, BLACK);
uint32_t x = kmalloc(32), y = kmalloc(32);
printf("x: %x, y: %x", x, y);
kfree((void*)y);
uint32_t z = kmalloc(8);
printf(", z: %x\n", z); // If z is equal to y, heap's anti-fragmentation algorithm works
ASSERT(z == y);
kfree((void*)z), kfree((void*)x);
printf_color("[STATUS]", LIGHT_GREEN, BLACK);
printf_color(" - Heap works!", WHITE, BLACK);
iceos_ascii_logo();
init_prompt(); // Initialize frame buffer
}