Adds keyboard driver stub.
This commit is contained in:
parent
8cb13eb9df
commit
ec8eb4a7d8
4 changed files with 58 additions and 2 deletions
12
prototypes/base/include/driver/base.hpp
Normal file
12
prototypes/base/include/driver/base.hpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
namespace driver
|
||||
{
|
||||
class Driver
|
||||
{
|
||||
protected:
|
||||
Driver() = default;
|
||||
public:
|
||||
virtual void install() = 0;
|
||||
};
|
||||
}
|
18
prototypes/base/include/driver/keyboard.hpp
Normal file
18
prototypes/base/include/driver/keyboard.hpp
Normal 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;
|
||||
};
|
||||
}
|
|
@ -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,6 +94,7 @@ extern "C" void init(Structure const & data)
|
|||
IDT::initialize();
|
||||
|
||||
IDT::interrupt(0x20) = Interrupt(timer);
|
||||
keyboardDriver.install();
|
||||
|
||||
Console::main << "Interrupts set up.\n";
|
||||
|
||||
|
|
21
prototypes/base/src/keyboard.cpp
Normal file
21
prototypes/base/src/keyboard.cpp
Normal 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! ";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue