/* Check if the compiler thinks you are targeting the wrong operating system. */ #if defined(__linux__) #error "You are not using a cross-compiler, you will most certainly run into trouble" #endif /* This tutorial will only work for the 32-bit ix86 targets. */ #if !defined(__i386__) #error "This kernel needs to be compiled with a ix86-elf compiler" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include /*#include */ #include #include #include #include #include #include #include #include #include #include #define DEBUG extern void _hang_asm(void); extern void _sti_asm(void); char* espresso_str = "" "####### ##### ###### ###### ####### ##### ##### #######\n" "# # # # # # # # # # # # # #\n" "# # # # # # # # # # #\n" "##### ##### ###### ###### ##### ##### ##### # #\n" "# # # # # # # # # #\n" "# # # # # # # # # # # # #\n" "####### ##### # # # ####### ##### ##### #######\n"; char* kernel_version = "0.0.2a"; void kernel_main(multiboot_info_t* mbd, uint32_t magic) { /* --- BEGIN INITIALIZATION SECTION --- */ /* We need to initialize the terminal so that any error/debugging messages show. */ terminal_initialize(); printf("Loading Espresso %s... ", kernel_version); #ifdef _DEBUG printf("[ DEBUG BUILD ]"); #endif printf("\n"); terminal_setcolor(VGA_COLOR_RED); /* Make sure the magic number matches for memory mapping */ if(magic != MULTIBOOT_BOOTLOADER_MAGIC) { printf("[ ERROR ] invalid magic number!\n"); _hang_asm(); } /* Check bit 6 to see if we have a valid memory map */ if(!(mbd->flags >> 6 & 0x1)) { printf("[ ERROR ] invalid memory map given by GRUB bootloader\n"); _hang_asm(); } gdt_install(false); pic_remap(); idt_init(); _sti_asm(); irq_init(); /* MUST be done after pic_remap() and idt_init() */ terminal_setcolor(VGA_COLOR_GREEN); pmm_init(mbd); paging_init(); heap_init(0xC2000000, 0x80000); printd("Testing SSE...\n"); int32_t sse_test_result = test_sse(); if (sse_test_result != 0) { printf("[ DEBUG ] SSE test failed with RV %d\n", sse_test_result); } else { printd("SSE test passed\n"); } pit_init(); keyboard_init(); ide_initialize(); pci_init(); /* --- END INITIALIZATION SECTION --- */ terminal_setcolor(VGA_COLOR_LIGHT_GREEN); /*pit_sleep(4000); begin_anim(kernel_version);*/ printf("Guten tag and welcome to Espresso %s\n", kernel_version); sleep(1000); intro_begin(); /*extern void terminal_clear(void); terminal_clear(); kshell_start(1, NULL);*/ while (true) { /* Loop infinitely. We only do something when a syscall happens now. */ } }