diff options
Diffstat (limited to 'src/kernel/kernel.c')
-rw-r--r-- | src/kernel/kernel.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 75867a8..b133a0c 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -6,8 +6,13 @@ #include <kernel/paging/paging.h> #include <kernel/input/input.h> #include <kernel/acpi/acpi.h> +#include <kernel/mutliboot.h> +#include <kernel/fs/initrd.h> +#include <kernel/syscall/syscall.h> -void init() { +extern void switch_to_user(); + +void kernel_main(struct multiboot *mboot_ptr) { vga_log("Installing basic features of Melvix...", 0); // Install features timer_install(); @@ -19,14 +24,26 @@ void init() { isrs_install(); irq_install(); set_optimal_resolution(); + // Install drivers asm volatile ("cli"); keyboard_install(); asm volatile ("sti"); -} -void kernel_main(void) { - init(); + // Setup initial ramdisk + assert(mboot_ptr->mods_count > 0); + uint32_t initrd_location = *((uint32_t *) mboot_ptr->mods_addr); + uint32_t initrd_end = *(uint32_t *) (mboot_ptr->mods_addr + 4); + paging_set_used(0, (initrd_end >> 12) + 1); + fs_root = initialise_initrd(initrd_location); + initrd_test(); + + // User mode! + info("Switching to user mode..."); + syscalls_install(); + switch_to_user(); + + panic("This should NOT happen!"); // asm volatile ("div %0" :: "r"(0)); // Exception testing x/0 loop: |