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"
|
2016-03-09 01:23:06 -05:00
|
|
|
#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()
|
|
|
|
{
|
2016-03-09 01:23:06 -05:00
|
|
|
auto console = kernel::Console::systemConsole();
|
|
|
|
|
2016-03-09 01:17:13 -05:00
|
|
|
mIDT.load();
|
2016-03-09 01:23:06 -05:00
|
|
|
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.
|
2016-03-09 01:23:06 -05:00
|
|
|
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 */
|