polka/src/Main.cc

56 lines
1.4 KiB
C++
Raw Permalink Normal View History

/* Main.cc
* vim: set tw=80:
* Eryn Wells <eryn@erynwells.me>
*/
/**
* Entry point for the kernel in C/C++.
*/
2016-02-26 22:31:34 -08:00
#include <stddef.h>
2016-02-27 13:50:51 -05:00
#include "Console.hh"
2016-02-28 23:26:42 -05:00
#include "Descriptors.hh"
#include "Interrupts.hh"
#include "Kernel.hh"
#include "Multiboot.hh"
2016-03-20 12:56:43 -04:00
#include "kstd/Types.hh"
2016-02-26 22:31:34 -08:00
#if defined(__linux__)
#error "This file should be compiled with a cross-compiler, not the Linux system compiler!"
#endif
#if !defined(__i386__)
#error "This file should be compiled with an ix86-elf compiler!"
#endif
// Linker script defined symbols. See linker.ld.
extern u32 kernelStart;
extern u32 kernelEnd;
/** The beginning of the world... */
extern "C"
void
2016-03-23 01:01:16 -04:00
kmain(multiboot::Information *information,
u32 magic)
2016-03-01 12:01:51 -05:00
{
auto& kernel = kernel::Kernel::systemKernel();
kernel::StartupInformation startupInformation;
startupInformation.kernelStart = u32(&kernelStart);
startupInformation.kernelEnd = u32(&kernelEnd);
2016-04-09 15:22:23 -04:00
// TODO: Define this somewhere else.
startupInformation.multibootMagic = magic;
startupInformation.multibootInformation = information;
kernel.initialize(startupInformation);
2016-03-20 00:43:26 -04:00
auto& console = kernel.console();
2016-03-02 02:57:35 -05:00
auto& interruptHandler = x86::InterruptHandler::systemInterruptHandler();
interruptHandler.initialize();
2016-03-13 12:52:47 -04:00
interruptHandler.enableInterrupts();
console.printString("Interrupts enabled\n");
2016-03-13 12:52:47 -04:00
kernel::Kernel::systemKernel().halt();
2016-03-01 12:01:51 -05:00
}