polka/src/Interrupts.cc

63 lines
935 B
C++
Raw Normal View History

2016-03-09 01:17:13 -05:00
/* Interrupts.cc
* vim: set tw=80:
* Eryn Wells <eryn@erynwells.me>
*/
/**
* Implementation of interrupt handers and things.
*/
#include "Interrupts.hh"
#include "Console.hh"
2016-03-09 01:17:13 -05:00
namespace x86 {
/*
* Static
*/
InterruptHandler&
InterruptHandler::systemInterruptHandler()
{
static InterruptHandler sInterruptHandler;
return sInterruptHandler;
}
/*
* Public
*/
InterruptHandler::InterruptHandler()
: mPIC(),
mIDT()
{ }
void
InterruptHandler::initialize()
{
auto console = kernel::Console::systemConsole();
2016-03-09 01:17:13 -05:00
mIDT.load();
console.writeString("Interrupt table loaded\n");
2016-03-09 01:17:13 -05:00
mPIC.remap(0x20, 0x28, 2); // Map hardware IRQs to interrupt vectors 32 through 48.
console.writeString("Hardware interrupts initialized\n");
2016-03-09 01:17:13 -05:00
}
void
InterruptHandler::enableInterrupts()
const
{
asm("sti");
}
void
InterruptHandler::disableInterrupts()
const
{
asm("cli");
}
} /* namespace x86 */