Moves base.hpp to driver.hpp. Adds Timer driver.
This commit is contained in:
parent
29c4b6fc4c
commit
09cd19d3c7
6 changed files with 53 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "base.hpp"
|
||||
#include "driver.hpp"
|
||||
#include "cpustate.hpp"
|
||||
|
||||
namespace driver
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "base.hpp"
|
||||
#include "driver.hpp"
|
||||
#include "cpustate.hpp"
|
||||
#include "pointer.hpp"
|
||||
|
||||
|
|
20
prototypes/base/include/driver/timer.hpp
Normal file
20
prototypes/base/include/driver/timer.hpp
Normal 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();
|
||||
};
|
||||
}
|
|
@ -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();
|
||||
|
||||
|
|
28
prototypes/base/src/timer.cpp
Normal file
28
prototypes/base/src/timer.cpp
Normal 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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue