polka/src/Main.cc

51 lines
1.2 KiB
C++
Raw Normal View History

2016-02-26 22:31:34 -08:00
#include <stddef.h>
#include <stdint.h>
2016-02-27 13:50:51 -05:00
#include "Console.hh"
2016-02-28 23:26:42 -05:00
#include "Descriptors.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
2016-02-27 12:34:36 -05:00
/** Called very early, before global initialization. */
2016-02-26 22:31:34 -08:00
extern "C"
void
kearly()
2016-02-27 13:50:51 -05:00
{
2016-03-01 12:01:51 -05:00
using kernel::Console;
/*
* Create a console object for early use because global initialization
* hasn't happened yet.
*/
Console console;
2016-02-27 13:50:51 -05:00
console.clear(kernel::Console::Color::Blue);
console.writeString("Loading system ...\n");
2016-02-27 13:50:51 -05:00
}
/** The beginning of the world... */
extern "C"
void
kmain()
2016-03-01 12:01:51 -05:00
{
using kernel::Console;
using kernel::GDT;
// Reinitialize the system console now that we have global static objects.
auto console = Console::systemConsole();
console.clear(Console::Color::Blue);
auto gdt = GDT::systemGDT();
gdt.setNullDescriptor(0);
gdt.setDescriptor(1, GDT::DescriptorSpec::kernelSegment(0, 0x000FFFFF, GDT::Type::CodeEXR));
gdt.setDescriptor(2, GDT::DescriptorSpec::kernelSegment(0, 0x000FFFFF, GDT::Type::DataRW));
gdt.load();
console.writeString("GDT loaded\n");
}