#include #include #include #include #include #include #include #include #include #include #include extern void switch_to_user(); void kernel_main(struct multiboot *mboot_ptr) { vga_log("Installing basic features of Melvix...", 0); // Install features timer_install(); gdt_install(); init_serial(); paging_install(); acpi_install(); idt_install(); isrs_install(); irq_install(); set_optimal_resolution(); // Install drivers asm volatile ("cli"); keyboard_install(); asm volatile ("sti"); // 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! syscalls_install(); switch_to_user(); syscall_serial_write("Hello, user world!\n"); // asm volatile ("div %0" :: "r"(0)); // Exception testing x/0 loop: asm volatile ("hlt"); goto loop; }