vbos/init/main.c
Michael Shaw e5b55a6ba5 x86: add GDT and IDT
Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
2026-04-13 04:23:14 -04:00

72 lines
1.4 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
#include <kernel/common.h>
#include <kernel/buddy.h>
#include <kernel/mem.h>
#include <kernel/device.h>
#include <kernel/requests.h>
#include <arch/init.h>
#include <kernel/page.h>
#include <drivers/tty.h>
#include <drivers/serial.h>
#include <drivers/acpi.h>
#include <drivers/apic.h>
#include <lib/stdio.h>
#include <lib/rbtree.h>
#define P_STACK_SIZE 0x8000
struct tty *tty_printf = NULL;
static void requires_bootloader_mem()
{
acpi_init();
}
static void kmain()
{
rbt_slab_init();
device_layer_init();
tty_layer_init();
dev_t serial_port = arch_serial_init();
tty_printf = tty_create("ttyS0", serial_port);
int rows;
int cols;
tty_get_size(tty_printf, &rows, &cols);
tty_setlf(tty_printf);
tty_clear_screen(tty_printf);
tty_set_cursor_pos(tty_printf, 0, 0);
/* start the kernel */
arch_init();
requires_bootloader_mem();
page_init();
kprintf(COL_CYAN_BLACK "Welcome to vbos!\n" COL_RESET);
yield();
}
void _before_stack()
{
/* these first few functions must be called in this order
*
* after calling arch_stack_init, we will lose all of our stack
* variables. only the most minimum things needed to init the stack
* here.
*/
requests_init();
mem_init();
buddy_init();
void *ap_stack = buddy_alloc(P_STACK_SIZE);
arch_stack_init(ap_stack, P_STACK_SIZE);
/* end previous note */
kmain();
}