Moves base.hpp to driver.hpp. Adds Timer driver.

This commit is contained in:
Felix Queißner 2016-05-06 19:37:43 +02:00
parent 29c4b6fc4c
commit 09cd19d3c7
6 changed files with 53 additions and 9 deletions

View file

@ -1,6 +1,6 @@
#pragma once
#include "base.hpp"
#include "driver.hpp"
#include "cpustate.hpp"
namespace driver

View file

@ -1,6 +1,6 @@
#pragma once
#include "base.hpp"
#include "driver.hpp"
#include "cpustate.hpp"
#include "pointer.hpp"

View file

@ -0,0 +1,20 @@
#pragma once
#include <inttypes.h>
#include "driver.hpp"
namespace driver
{
class Timer :
public Driver
{
public:
Timer();
void install() override;
void reset();
uint32_t count();
};
}

View file

@ -10,6 +10,7 @@
#include "compat.h"
#include "io.hpp"
#include "driver/timer.hpp"
#include "driver/keyboard.hpp"
#include "driver/scheduler.hpp"
@ -22,14 +23,10 @@ struct dummy;
extern dummy kernelStartMarker;
extern dummy kernelEndMarker;
driver::Timer timer;
driver::Keyboard keyboardDriver;
driver::Scheduler scheduler;
void timer(CpuState *cpu)
{
// Console::main << "tick! ";
}
extern "C" void init(Structure const & data)
{
Console::main
@ -95,8 +92,7 @@ extern "C" void init(Structure const & data)
IDT::initialize();
IDT::interrupt(0x20) = Interrupt(timer);
timer.install();
keyboardDriver.install();
scheduler.install();

View file

@ -0,0 +1,28 @@
#include "driver/timer.hpp"
#include "idt.hpp"
namespace driver
{
static volatile uint32_t counter = 0;
Timer::Timer()
{
}
void Timer::install()
{
IDT::interrupt(0x20) = Interrupt([](auto *) { counter++; });
}
void Timer::reset()
{
counter = 0;
}
uint32_t count()
{
return counter;
}
}