aboutsummaryrefslogtreecommitdiff
path: root/src/idt.h
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-02-28 22:39:25 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2021-02-28 22:39:25 +0200
commitae4265ea5d77b68757af39d73fe47df1a3563b42 (patch)
tree7282e3d43c471b195bb5a4742ed911c7b7626dcb /src/idt.h
parentFix interrupts causing exception 0xd (diff)
downloadkernel.cpp-ae4265ea5d77b68757af39d73fe47df1a3563b42.tar.xz
Add keyboard driver
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*);
};