#include #include #include bool volatile is_running = false; void init_vesa(struct multiboot_info *); struct multiboot_info *mbi; int init(struct multiboot_info *mbiL) { mbi = mbiL; clear_screen(); kprintf("Welcome to LF OS 1.0 Alpha 5 / Kernel 2!\n" "========================================\n\n" "Please wait, while LF OS is starting up.\n\n"); boot_gauge(1); kprintf("Initializing RS232 ... "); init_com(0x3F8, 115200, 0, 8); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; boot_gauge(2); kprintf("Initializing GDT ... "); load_gdt(); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; boot_gauge(3); kprintf("Initializing IDT ... "); idt_install(); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; boot_gauge(4); kprintf("Initializing Physical Memory Manager (PMM) ... "); pmm_init(mbi); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; boot_gauge(5); kprintf("Initializing Paging ... "); init_paging(); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; boot_gauge(6); kprintf("Commandline: %s\n", mbi->mbs_cmdline); kprintf("Initializing Commandline ... "); init_cmdline(); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; if(cmdline_debug) { color = 0x04; kprintf("Warning! Debugmode enabled. LF OS might not run on a real Computer!\n\n"); color = 0x07; } boot_gauge(7); kprintf("Initializing IRQs ... "); irq_init(); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; boot_gauge(8); kprintf("Initializing Keyboard ... "); if(install_keyboard() == 2) { color = 0x0E; posX-=3; kprintf("[ Warning ]\n"); color = 0x07; } else if(install_keyboard()) { color = 0x02; kprintf("[ Done ]\n"); color = 0x07; } boot_gauge(9); kprintf("Initializing Multitasking ... "); init_multitasking(mbiL); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; boot_gauge(10); kprintf("Initializing RealTime Clock ... "); init_time(); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; kprintf(" Now it's the %d.%d.%d at %d:%d\n Timestamp: %d\n", system_time.tm_mday, system_time.tm_mon, system_time.tm_year, system_time.tm_hour, system_time.tm_min, time_t_to_unix(system_time)); boot_gauge(11); kprintf("Installing the Timer ... "); install_timer(); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; boot_gauge(12); kprintf("Initializing Mouse ... "); init_mouse(); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; boot_gauge(13); kprintf("Initializing VESA ... "); init_vesa(mbi); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; boot_gauge(14); kprintf("Enabling IRQs ... "); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; asm volatile("sti"); boot_gauge(15); list_pci_devices(); kprintf("Initializing Floppy Driver ... "); init_floppy(); color = 0x02; kprintf("[ Done ]\n"); color = 0x07; boot_gauge(15); is_running = true; while(is_running); return 0; } void shutdown() { color = 0x07; clear_screen(); color = 0x04; kprintf("The system is shutting down NOW!\n\n"); color = 0x07; struct task *task = first_task; kprintf("Sending all processes the QUIT Signal ...\n"); boot_gauge(14); while(task->next != NULL) { send_message(task, MESSAGE_QUIT, 0); kprintf(" %s\n", task->executableName); task = task->next; } kprintf("Tasks are ready to be closed.\nGoing to kill them.\n"); boot_gauge(13); task = first_task; while(task->next != NULL) { kprintf(" Closing Task '%s'\n", task->executableName); task->running = false; task = task->next; } kprintf("All Tasks closed.\nUninstalling IRQ Handlers ...\n"); boot_gauge(12); int i; for(i = 0; i < 16; i++) { irq_uninstall_handler(i); kprintf("#"); boot_gauge(11-(i/2)); } kprintf("\n\nIt's safe to turn of your computer now.\n\nGoodbye!"); boot_gauge(0); asm("cli;hlt"); } void* memset(void* buf, int c, int n) { unsigned char* p = buf; while (n--) { *p++ = c; } return buf; } void* memcpy(void* dest, const void* src, size_t n) { unsigned char* d = dest; const unsigned char* s = src; while (n--) { *d++ = *s++; } return dest; }