157 lines
3.3 KiB
C
157 lines
3.3 KiB
C
/* 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 <types.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <kernel/boot.h>
|
|
#include <panic.h>
|
|
|
|
#include <gdt.h>
|
|
#include <drivers/idt.h>
|
|
#include <drivers/irq.h>
|
|
|
|
#include <multiboot.h>
|
|
|
|
#include <stdio.h>
|
|
#include <drivers/pci.h>
|
|
#include <drivers/ps2_keyboard.h>
|
|
#include <drivers/pit.h>
|
|
/*#include <drivers/ahci.h>*/
|
|
#include <drivers/ide.h>
|
|
#include <mm/mm.h>
|
|
#include <fs/fat32.h>
|
|
#include <fs/duckfs.h>
|
|
#include <fs/vfs.h>
|
|
#include <fs/sfs.h>
|
|
|
|
#include <vector_extensions/sse.h>
|
|
|
|
#include <kernel/intro.h>
|
|
|
|
#define DEBUG
|
|
|
|
|
|
extern void _hang_asm(void);
|
|
extern void _sti_asm(void);
|
|
|
|
|
|
void kernel_main(multiboot_info_t* mbd, unsigned int magic)
|
|
{
|
|
|
|
/* --- BEGIN INITIALIZATION SECTION --- */
|
|
|
|
const char* espresso_kernel_version = "0.0.0f";
|
|
|
|
/* We need to initialize the terminal so that any error/debugging messages show. */
|
|
terminal_initialize();
|
|
|
|
printf("Loading Espresso %s...\n", espresso_kernel_version);
|
|
|
|
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 pci_remap() and idt_init() */
|
|
|
|
terminal_setcolor(VGA_COLOR_GREEN);
|
|
|
|
printd("Initializing physical memory manager...\n");
|
|
pmm_init(mbd);
|
|
printd("Physical memory manager initialized\n");
|
|
|
|
printd("Initializing paging...\n");
|
|
paging_init();
|
|
printd("Paging initialized\n");
|
|
|
|
printd("Initializing heap allocator...\n");
|
|
heap_init();
|
|
printd("Heap allocator initialized\n");
|
|
|
|
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");
|
|
}
|
|
|
|
printd("Initializing the PIT...\n");
|
|
pit_init();
|
|
printd("PIT initialized\n");
|
|
|
|
printd("Initializing the PS/2 keyboard...\n");
|
|
keyboard_init();
|
|
printd("PS/2 Keyboard initialized\n");
|
|
|
|
/*
|
|
printd("Initalizing AHCI...\n");
|
|
ahci_init();
|
|
printd("AHCI initialized\n");
|
|
*/
|
|
|
|
printd("Initializing IDE system...\n");
|
|
ide_initialize();
|
|
printd("IDE initialized\n");
|
|
|
|
/*printd("Initializing DuckFS...\n");
|
|
duckfs_init();
|
|
printd("DuckFS initialized\n");*/
|
|
|
|
printd("Initializing PCI...\n");
|
|
pci_enumerate();
|
|
printd("PCI initialized\n");
|
|
|
|
|
|
|
|
/* --- END INITIALIZATION SECTION --- */
|
|
|
|
terminal_setcolor(VGA_COLOR_LIGHT_GREEN);
|
|
|
|
|
|
/*pit_sleep(4000);
|
|
begin_anim(espresso_kernel_version);*/
|
|
|
|
printf("Guten tag and welcome to Espresso\n");
|
|
|
|
/*printf("here\n");
|
|
|
|
printf("%i\n", sfs_init(false));
|
|
|
|
printf("here\n");*/
|
|
|
|
while (true)
|
|
{
|
|
|
|
}
|
|
}
|