aboutsummaryrefslogtreecommitdiff
path: root/src/idt.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/idt.h')
-rw-r--r--src/idt.h27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/idt.h b/src/idt.h
index bc71f05..3a9848f 100644
--- a/src/idt.h
+++ b/src/idt.h
@@ -2,7 +2,21 @@
#include <types.h>
+class InterruptHandler {
+private:
+ const uint8_t m_irq;
+
+protected:
+ InterruptHandler(uint8_t irq);
+ ~InterruptHandler();
+
+public:
+ virtual void trigger();
+};
+
class IDT {
+ friend class InterruptHandler;
+
public:
struct Pointer {
uint16_t limit;
@@ -19,24 +33,23 @@ public:
class Entry {
public:
constexpr Entry() = default;
- Entry(void (*handler)(), uint16_t select, InterruptType t) {
- offset_0_15 = reinterpret_cast<uint32_t>(handler) & 0xffff;
- offset_16_31 = (reinterpret_cast<uint32_t>(handler) >> 16) & 0xffff;
- selector = select;
- type = t;
- }
+ Entry(void (*handler)(), uint16_t select, InterruptType t);
private:
uint16_t offset_0_15 = 0; // 0-15 offset in the segment
uint16_t selector = 0; // 16-31 selector of the code segment
[[maybe_unused]] uint8_t null = 0; // 32-39 unused in protected mode
InterruptType type = Null; // 40-43 type
- uint16_t offset_16_31 = 0; // 48-63 offset high
+ uint16_t offset_16_31 = 0; // 48-63 offset high
} __attribute__((packed));
IDT(const uint16_t selector);
+ void enable() { asm volatile("sti"); }
private:
Entry table[256];
+
+ static bool install(uint8_t, InterruptHandler*);
+ static bool uninstall(uint8_t, InterruptHandler*);
};