From ae4265ea5d77b68757af39d73fe47df1a3563b42 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 28 Feb 2021 22:39:25 +0200 Subject: Add keyboard driver --- src/idt/interruptgate.cc | 10 ++++++++++ src/idt/interrupthandler.cc | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/idt/interruptgate.cc create mode 100644 src/idt/interrupthandler.cc (limited to 'src/idt') diff --git a/src/idt/interruptgate.cc b/src/idt/interruptgate.cc new file mode 100644 index 0000000..0dbcce2 --- /dev/null +++ b/src/idt/interruptgate.cc @@ -0,0 +1,10 @@ +#include "../idt.h" + +static_assert(sizeof(IDT::Entry) == 8); // size of IDT::Entry in protected mode is 64 bits + +IDT::Entry::Entry(void (*handler)(), uint16_t select, IDT::InterruptType t) { + offset_0_15 = reinterpret_cast(handler) & 0xffff; + offset_16_31 = (reinterpret_cast(handler) >> 16) & 0xffff; + selector = select; + type = t; +} diff --git a/src/idt/interrupthandler.cc b/src/idt/interrupthandler.cc new file mode 100644 index 0000000..7af830b --- /dev/null +++ b/src/idt/interrupthandler.cc @@ -0,0 +1,14 @@ +#include +#include "../idt.h" + +InterruptHandler::InterruptHandler(uint8_t irq) : m_irq(irq) { + IDT::install(m_irq, this); +} + +InterruptHandler::~InterruptHandler() { + IDT::uninstall(m_irq, this); +} + +void InterruptHandler::trigger() { + printk("Unhandled interrupt ", uhex{m_irq}, '\n'); +} -- cgit v1.2.1