#define FOOLOS_MODULE_NAME "kernel" #ifdef __linux__ #error "Watchout! this is not Linux but FoolOS. Use a cross-compiler" #endif #include "kernel.h" #include #include "config.h" #include "types.h" #include "lib/logger/log.h" #include "timer.h" #include "mem.h" #include "vmem.h" #include "mp.h" #include "interrupts.h" #include "multiboot.h" #include // for built-in shell #include "task.h" #include "multiboot.h" #include "terminal/vt52.h" #include "driver/console.h" #include "fs/fifo.h" // // The Foolish structure of Fool OS! // static fool_os foolos; fool_os *get_fool() { return &foolos; } // // // // stdio init : TODO: move away! static vt52_tty tty1; static void put_kb(uint8_t c) { vt52_kb(&tty1,c); } static void stdin_put_char(uint8_t c) { vt52_kb(&tty1,c); } static void init_stdio() { fifo in=fifo_init(1); fifo out=fifo_init(1); // // Setup terminal output / input // term_out screen; screen.put_char=console_put_char; screen.update_cursor=update_cursor; term_in input; input.put_char=stdin_put_char; tty1=vt52_init(&screen,&input); keyboard_init(put_kb); } void kernel_main(uint32_t eax,uint32_t ebx) { init_stdio(); // // PR // log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%s - compiled on %s at %s",KERNEL_VERSION,__DATE__,__TIME__); // // Configuring the PIT timer. // timer_init(); // // GDT // gdt_setup(); // // Setup Interrupts (code segment: 0x08) // int_init(0x08); // // Process Multiboot Header // multiboot_information *info=get_multiboot(eax, ebx); // // Gather Info about other processors. (APs = application processors) // ACPI or MP // smp_processors procdata; if(!acpi_find(&procdata)) if(!mp_find(&procdata)) panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!"); // // Memory Init // // after this is set up we will be able to allocate and deallocate // blocks of physical memory :) // uint32_t kernel_blocks=mem_init(info); // // Mount Root EXT2 ramimage (needs to be done before other processors started, because of /boot/mp.bin) // fs_mount(info); // // Start the other Processors (before paging because apic addr etc..?) // //TODO: !!! Check commented out sleep ()!!! smp_log_procdata(&procdata); smp_start_aps(&procdata,"/boot/mp.bin"); //will be copied over mbr // // Activate Virtual Memory (paging) // pdirectory *dir=vmem_init(kernel_blocks); // // Scan the PCI Bus // // We are interested in the E1000 Network Adapter in particular // Its driver will be hopefully implemented one day ;) TODO // //pci_init(); // // Initialize Multitasking // task_init(dir); // // Abvoe should never returon // panic(FOOLOS_MODULE_NAME,"reached end of kernel.c !!"); }