Adds keyboard driver stub.

This commit is contained in:
Felix Queißner 2016-05-06 09:44:02 +02:00
parent 8cb13eb9df
commit ec8eb4a7d8
4 changed files with 58 additions and 2 deletions

View file

@ -0,0 +1,12 @@
#pragma once
namespace driver
{
class Driver
{
protected:
Driver() = default;
public:
virtual void install() = 0;
};
}

View file

@ -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;
};
}

View file

@ -10,6 +10,8 @@
#include "compat.h" #include "compat.h"
#include "io.hpp" #include "io.hpp"
#include "driver/keyboard.hpp"
using namespace multiboot; using namespace multiboot;
using namespace console_tools; using namespace console_tools;
@ -19,9 +21,11 @@ struct dummy;
extern dummy kernelStartMarker; extern dummy kernelStartMarker;
extern dummy kernelEndMarker; extern dummy kernelEndMarker;
driver::Keyboard keyboardDriver;
void timer(CpuState *cpu) void timer(CpuState *cpu)
{ {
Console::main << "tick! "; // Console::main << "tick! ";
} }
extern "C" void init(Structure const & data) extern "C" void init(Structure const & data)
@ -90,7 +94,8 @@ extern "C" void init(Structure const & data)
IDT::initialize(); IDT::initialize();
IDT::interrupt(0x20) = Interrupt(timer); IDT::interrupt(0x20) = Interrupt(timer);
keyboardDriver.install();
Console::main << "Interrupts set up.\n"; Console::main << "Interrupts set up.\n";
asm volatile("sti"); asm volatile("sti");

View file

@ -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! ";
}
}