Rough outline of InterruptHandler
This commit is contained in:
parent
3879b3c324
commit
6677af27f6
3 changed files with 85 additions and 1 deletions
57
src/Interrupts.cc
Normal file
57
src/Interrupts.cc
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/* Interrupts.cc
|
||||||
|
* vim: set tw=80:
|
||||||
|
* Eryn Wells <eryn@erynwells.me>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Implementation of interrupt handers and things.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Interrupts.hh"
|
||||||
|
|
||||||
|
namespace x86 {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Static
|
||||||
|
*/
|
||||||
|
|
||||||
|
InterruptHandler&
|
||||||
|
InterruptHandler::systemInterruptHandler()
|
||||||
|
{
|
||||||
|
static InterruptHandler sInterruptHandler;
|
||||||
|
return sInterruptHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Public
|
||||||
|
*/
|
||||||
|
|
||||||
|
InterruptHandler::InterruptHandler()
|
||||||
|
: mPIC(),
|
||||||
|
mIDT()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InterruptHandler::initialize()
|
||||||
|
{
|
||||||
|
mIDT.load();
|
||||||
|
mPIC.remap(0x20, 0x28, 2); // Map hardware IRQs to interrupt vectors 32 through 48.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InterruptHandler::enableInterrupts()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
asm("sti");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InterruptHandler::disableInterrupts()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
asm("cli");
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace x86 */
|
|
@ -6,10 +6,18 @@
|
||||||
* Interrupts, exceptions. Spooky scary...
|
* Interrupts, exceptions. Spooky scary...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef __INTERRUPTS_HH__
|
||||||
|
#define __INTERRUPTS_HH__
|
||||||
|
|
||||||
|
#include "Descriptors.hh"
|
||||||
|
#include "PIC.hh"
|
||||||
|
|
||||||
|
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
|
||||||
} /* namespace kernel */
|
} /* namespace kernel */
|
||||||
|
|
||||||
|
|
||||||
namespace x86 {
|
namespace x86 {
|
||||||
|
|
||||||
enum class Interrupt {
|
enum class Interrupt {
|
||||||
|
@ -34,6 +42,24 @@ enum class Interrupt {
|
||||||
XM = 19, // SIMD floating-point exception
|
XM = 19, // SIMD floating-point exception
|
||||||
VE = 20, // Virtualization exception
|
VE = 20, // Virtualization exception
|
||||||
// Interrupts 21 through 31 reserved
|
// Interrupts 21 through 31 reserved
|
||||||
}
|
};
|
||||||
|
|
||||||
|
struct InterruptHandler
|
||||||
|
{
|
||||||
|
static InterruptHandler& systemInterruptHandler();
|
||||||
|
|
||||||
|
InterruptHandler();
|
||||||
|
|
||||||
|
void initialize();
|
||||||
|
|
||||||
|
void enableInterrupts() const;
|
||||||
|
void disableInterrupts() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
PIC mPIC;
|
||||||
|
IDT mIDT;
|
||||||
|
};
|
||||||
|
|
||||||
} /* namespace x86 */
|
} /* namespace x86 */
|
||||||
|
|
||||||
|
#endif /* __INTERRUPTS_HH__ */
|
||||||
|
|
|
@ -12,6 +12,7 @@ files = [
|
||||||
'Main.cc',
|
'Main.cc',
|
||||||
'Console.cc',
|
'Console.cc',
|
||||||
'Descriptors.cc',
|
'Descriptors.cc',
|
||||||
|
'Interrupts.cc',
|
||||||
'PIC.cc',
|
'PIC.cc',
|
||||||
'cxa.cc',
|
'cxa.cc',
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue