#include "kernel.h" #include "log.h" #include "serial.h" #include "asm_pic.h" #include "multiboot.h" #include "acpi.h" #include "gdt.h" #include "interrupts.h" #include "mem.h" #include "vmem.h" //-- clean below headers --// #include "sysfs.h" #include "pci.h" #include "e1000.h" #include "pipe.h" #include "testing/testing.h" #include "ext2.h" #include "apic.h" #include "kernel/scheduler.h" #include "driver/timer.h" #include "driver/keyboard.h" #include "driver/mouse.h" #include "syscalls.h" #include "fifo.h" #include "asm_smp.h" #include "asm_x86.h" #include "ringbuffer.h" #include "driver/screen.h" #include "smp.h" #include "fs/elf.h" #include "kmalloc.h" #include "driver/vesa.h" #include "asm_pit.h" /* F00L 0S Entry point (called directly from asm/multiboot.asm */ void kernel_main(uint32_t eax,uint32_t ebx) { // -- COM1 -- // serial_init(); klog("Communication Port (COM1) initialized."); // -- PR & VERSION BANNER -- // klog("======================================"); klog("F00L- 0S / The Fool's Operating System"); klog("(C) 2018 / Michal Idziorek (m.i@gmx.at)"); klog("Compiled on: %s at %s",__DATE__,__TIME__); klog("Version: git-commit: %s",GIT_REVISION); klog("======================================"); // -- DISABLE LEGACY PIC -- // klog("Remapping & Disabling Programmable Interrupt Controller (PIC) ..."); fixme("io_wait & spurious interrupts"); asm_pic_setup(); // -- GET CONFIGS -- // klog("Read Multiboot Structures ..."); multiboot_information *cfg_multiboot; cfg_multiboot=multiboot_read(eax, ebx,true); // true for silent // elf_multiboot_read(cfg_multiboot); // just show kernel section headers klog("Read Advanced Power Configuration Interface (ACPI) Structures ..."); acpi_information cfg_acpi; bool acpi_found=acpi_fill(&cfg_acpi); fixme("Try to read (legacy) multiprocessor mp strucutres as well (see: xxx/mp.c)"); if(!acpi_found) kpanic("We Currently rely on ACPI Structures Sorry!"); // -- GDT -- // klog("Global Descriptor Table (GDT) init ..."); gdt_init(); // -- IVT -- // klog("Interrupt Vector Table (IVT) init ..."); interrupts_init(0x08); interrupts_install(); fixme("register interrupt callback funcs (instead hardcoded dispatcher)"); // -- PCI SCAN --/ klog("PCI init ..."); uint32_t e1000_addr=pci_init(); klog("E1000 addr=0x%08X",e1000_addr); // -- MEMORY MANAGEMENT -- // klog("Memory init ... "); mem_init(cfg_multiboot); klog("Vritual Memory / Paging init ... "); fixme("do not disable anymore on context switching!"); fixme("write convenneint management funcs as: mapCPU, mapKErnel, map USerspace.."); fixme("move stack and guard with empty pages!"); vmem_init(cfg_multiboot,&cfg_acpi,e1000_addr); struct pdirectory_struct *dir=vmem_kernel_dir(); x86_set_page_directory(dir); x86_paging_enable(); // -- MOUNTS -- // klog("Mounting ... "); ext2_dump_info(VMEM_EXT2_RAMIMAGE); ext2_mount("/"); sysfs_mount("/sys/"); // -- APIC -- // klog("Advanced Programmable Interrupt Controller (APIC) config ..."); apic_init(&cfg_acpi); ioapic_config(); // -- VESA -- // fixme("tell terminal syscall somehow if we are vga or textmode"); klog("Video Electronics Standards Association (VESA) init ... "); // binfont has to fit in ONE ext2 block // fixme("support binfonts spanning multiple blocks?"); uint32_t inode= ext2_filename_to_inode(VMEM_EXT2_RAMIMAGE,VESA_FONT_PATH); uint32_t addr= ext2_inode_blockstart( VMEM_EXT2_RAMIMAGE,inode,0); vesa_init(cfg_multiboot,addr); // -- STD STREAMS -- // klog("Standard Streams init ..."); fd_init_std_streams(0,cfg_multiboot->framebuffer_type!=2); // -- KB -- // klog("Keyboard init ..."); keyboard_init(0); // -- MOUSE -- // klog("Mouse init ..."); mouse_init(); // we wait till almost the end since the time will only start ticking after we // enable interrupts klog("Programmable Interval Timer (PIT) init ..."); uint64_t unixtime=timer_init(); klog("Unix Time = %u seconds",unixtime); // -- E1000 INIT (TODO: only if present!) --/ klog("E1000 init ..."); fixme("do not hardcode address and allow paging somehwere else"); e1000_init(e1000_addr); klog("Symmetric Multi Processing (SMP) start ... "); smp_start_aps(&cfg_acpi); }