/* SPDX-License-Identifier: GPL-2.0-only */ /* vbos main entry point: * VERY BAD OS: a hobby operating system * * Copyright 2023-2026 Michael Shaw */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define P_STACK_SIZE 0x8000 typedef void (*initcall_t)(void); extern initcall_t __initcall_start, __initcall_end; struct tty *tty_printf = NULL; static void do_initcalls() { for (initcall_t *fn = &__initcall_start; fn < &__initcall_end; fn++) (*fn)(); } static void kmain() { /* data types */ rbt_init(); list_init(); kalloc_init(); vfs_init(); arch_init(); page_init(); ramfs_init(); struct limine_file *file = module_res->modules[0]; fs_t *initramfs; int res = cpio_read_and_init(file->address, file->size, &initramfs); if (res < 0) panic("failed to load initramfs: %s\n", strerror(-res)); /* start the kernel */ devfs_init(); device_layer_init(); do_initcalls(); /* do nothing, for now :) */ 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. */ arch_early_init(); requests_init(); mem_init(); buddy_init(); void *bsp_stack = buddy_alloc(buddy_order(P_STACK_SIZE)); arch_stack_init(bsp_stack, P_STACK_SIZE); /* end previous note */ kmain(); }