#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 "interrupts.h" #include "multiboot.h" #include "console.h" #include // for built-in shell #include "lib/buffer/ringbuffer.h" #include "task.h" #include "video/vesa.h" void kernel_main(uint32_t eax,uint32_t ebx) { // // PR // log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%s",KERNEL_VERSION); // // Configuring the PIT timer. // timer_init(); // // Process Multiboot Header // if(eax!=0x2badb002)panic(FOOLOS_MODULE_NAME,"EAX was not set properly by your bootlaoder!"); multiboot_information *info; info=ebx; if(info->flags&&1<<9) { log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Loaded by: \"%s\"",info->boot_loader_name); } log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"multiboot flags: 0x%08X",info->flags); if(info->flags&&1<<0) { log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mem_lower: %d KB",info->mem_lower); log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mem_upper: %d KB",info->mem_upper); } if(info->flags&&1<<2) { log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"cmdline: \"%s\"",info->cmdline); } // // Memory Init // // after this is set up we will be able to allocate and deallocate // blocks of physical memory :) // // we know that here, the bootloader placed the memory map and // its length // if(info->flags&&1<<6) { log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"memory map of length %d provided by bootloader",info->mmap_length); mem_init(info->mmap_addr,info->mmap_length); } else panic(FOOLOS_MODULE_NAME,"Unable to continue without memory map, sorry!"); // // Modules // if(info->flags&&1<<3) { log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d modules loaded",info->mods_count); multiboot_mod *mod=info->mods_addr; for(int i=0;imods_count;i++) { log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mod at 0x%08X-0x%08X : %s", mod->mod_start,mod->mod_end, mod->string); mod++; } } // // Video // log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"VBE Info: 0x%04X (0x%08X 0x%08X)",info->vbe_mode,info->vbe_control_info, info->vbe_mode_info); vbeinfo *vbe=info->vbe_mode_info; //log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%c%c",'X',vbe->VbeSignature[0]); /* uint16_t VbeVersion; // == 0x0300 for VBE 3.0 uint16_t OemStringPtr[2]; // isa vbeFarPtr uint8_t Capabilities[4]; uint16_t VideoModePtr[2]; // isa vbeFarPtr uint16_t TotalMemory; // as # of 64KB blocks */ // // init output to screen // uint32_t physbase=console_init(info->vbe_mode_info,info->vbe_control_info); // // Activate Virtual Memory (paging) // pdirectory *dir=vmem_init(physbase); // log buffered messages to console log_log(); while(1); // // Setup Interrupts (code segment: 0x08) // int_init(0x08); // // 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(); // // Gather Info about other processors. (APs) // 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!"); */ // // Start the other Processors (also before paging for some reason!) // //smp_log_procdata(&procdata); //smp_start_aps(&procdata,0x80000); // starts at 0x80000 // but it will be copied over mbr // // Initialize Multitasking // task_init(dir); //; this will never return! // }