#define FOOLOS_MODULE_NAME "kernel" #include "lib/logger/log.h" #include "lib/int/stdint.h" #include "lib/bool/bool.h" #include "smp.h" #include "time.h" /////// // interrupt handler prototypes // todo: move somewhere else!? void int_clock_handler(); void int_kb_handler(); void int_floppy_handler(); uint32_t read_eip(); uint32_t c1,c2,c3; volatile uint8_t proc; uint32_t cpu_counter[SMP_MAX_PROC]; void kernel_ap() { proc++; uint8_t p=proc; while(1)cpu_counter[p]++; } // // KERNEL MAIN // this is the very heart of our operating system! // void kernel_main(uint32_t initial_stack, int mp) { // catch the APs (Application Processors) if(mp==1) { uint32_t ebp=pmmngr_alloc_block()+4095; asm volatile("mov %0, %%ebp"::"r"(ebp)); asm volatile("mov %ebp, %esp"); asm volatile("jmp kernel_ap"); } proc=c1=c2=c3=0; for(int i=0;i 32) int_install_ir(32, 0b10001110, 0x08,&int_clock_handler); // install keyboard interrupt handler (irq 1 => 33) int_install_ir(33, 0b10001110, 0x08,&int_kb_handler); // install floppy interrupt handler (irq 6 => 38) int_install_ir(38, 0b10001110, 0x08,&int_floppy_handler); // now we can enable interrupts back again x86_int_enable(); // // Memory Init // // we know that here, the bootloader placed the mamory map! mem_init(0x7c00+0x400,*((uint16_t *)(0x7c00+0x600))); // // Gather Info about other processors. // ACPI or MP // smp_processors procdata; // try to find acpi tables if(!acpi_find(&procdata)) if(!mp_find(&procdata)) panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!"); // Start the other Processors (also before paging !) smp_start_aps(&procdata); ///////////////////// // paging (pass the vesa physbase address for identity mapping) //vmem_init(vesa_physbase); ////////////////////// // // Scan the PCI Bus // // We are interested in the E1000 Network Adapter in particular // Its driver will be hopefully implemented one day ;) // pci_init(); // // Initialize Floppy Disk // floppy_init(); // // "Shell" // // Will process input from the keyboard but will be completely // redesigned soon. // shell_init(); // // Initialize Multitasking // // For now this starts two tasks which are scheduled // round robin style. // task_init(); // // Just hang here. // while(1)asm("hlt"); }