#include #include "paging.h" #include "serial.h" #include "window.h" #include "panic.h" #include "boot.h" #include "util.h" #include "fat.h" #include "ide.h" #include "idt.h" #include "pmap.h" #include "task.h" #include "pci.h" #include "elf.h" #include "log.h" #include "kbd.h" void _start_user_mode() __attribute__ ((noreturn)); __attribute__ ((noreturn)) void main() { init_pagemap(); init_paging(); init_tasks(); init_serial(); pci_init(); init_fat(); //other fs drivers init_drives(); init_ide(); //other drive drivers init_log(); init_kbd(); init_idt(); paint_bg(); logf(LOG_INFO, "Kernel initialization done."); logf(LOG_INFO, "Available kernel memory: %dk", kernel_pages_left * 4); logf(LOG_INFO, "Available user memory: %dk", user_pages_left * 4); logf(LOG_INFO, "PCI devices:"); for (uint16_t i = 0; i < n_pci_devices; ++i) { const struct pci_device *dev = nth_pci_device(i); logf(LOG_INFO, " %hw:%hw (%hb:%hb)", dev->id_vendor, dev->id_device, dev->class, dev->subclass); } logf(LOG_INFO, "Drives:"); for (uint8_t i = 0; i < n_drives; ++i) { const struct drive *d = &drives[i]; const uint32_t free = d->get_free_sectors(d); logf(LOG_INFO, " %s: %d%sk, %s (%d%sk free)", d->drive_type, d->n_sectors / 2, d->n_sectors % 2 ? ".5" : "", d->fs_type, free / 2, free % 2 ? ".5" : ""); } logf(LOG_INFO, "Loading init program."); if (!try_elf_run(drives, "bin/init", "", 0)) PANIC("Failed to load init program."); logf(LOG_INFO, "Switching to init task."); _start_user_mode(); }