diff --git a/prototypes/base/include/driver/base.hpp b/prototypes/base/include/driver/base.hpp new file mode 100644 index 0000000..c7b625e --- /dev/null +++ b/prototypes/base/include/driver/base.hpp @@ -0,0 +1,12 @@ +#pragma once + +namespace driver +{ + class Driver + { + protected: + Driver() = default; + public: + virtual void install() = 0; + }; +} \ No newline at end of file diff --git a/prototypes/base/include/driver/keyboard.hpp b/prototypes/base/include/driver/keyboard.hpp new file mode 100644 index 0000000..474f132 --- /dev/null +++ b/prototypes/base/include/driver/keyboard.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "base.hpp" +#include "cpustate.hpp" + +namespace driver +{ + class Keyboard : + public Driver + { + private: + static void dispatchIRQ(CpuState *cpu); + public: + Keyboard(); + + void install() override; + }; +} \ No newline at end of file diff --git a/prototypes/base/init.cpp b/prototypes/base/init.cpp index bfbd422..e088e8a 100644 --- a/prototypes/base/init.cpp +++ b/prototypes/base/init.cpp @@ -10,6 +10,8 @@ #include "compat.h" #include "io.hpp" +#include "driver/keyboard.hpp" + using namespace multiboot; using namespace console_tools; @@ -19,9 +21,11 @@ struct dummy; extern dummy kernelStartMarker; extern dummy kernelEndMarker; +driver::Keyboard keyboardDriver; + void timer(CpuState *cpu) { - Console::main << "tick! "; + // Console::main << "tick! "; } extern "C" void init(Structure const & data) @@ -90,7 +94,8 @@ extern "C" void init(Structure const & data) IDT::initialize(); IDT::interrupt(0x20) = Interrupt(timer); - + keyboardDriver.install(); + Console::main << "Interrupts set up.\n"; asm volatile("sti"); diff --git a/prototypes/base/src/keyboard.cpp b/prototypes/base/src/keyboard.cpp new file mode 100644 index 0000000..a42c0b6 --- /dev/null +++ b/prototypes/base/src/keyboard.cpp @@ -0,0 +1,21 @@ +#include "driver/keyboard.hpp" +#include "idt.hpp" +#include "console.hpp" + +namespace driver +{ + Keyboard::Keyboard() + { + + } + + void Keyboard::install() + { + IDT::interrupt(0x21) = Interrupt(Keyboard::dispatchIRQ); + } + + void Keyboard::dispatchIRQ(CpuState *cpu) + { + Console::main << "keyboard! "; + } +} \ No newline at end of file