Kernel: Start work on abstracting Timers
This commit is contained in:
23
kernel/include/kernel/Timer/PIT.h
Normal file
23
kernel/include/kernel/Timer/PIT.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <kernel/Timer/Timer.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define PIT_IRQ 0
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
class PIT final : public Timer
|
||||
{
|
||||
public:
|
||||
static BAN::ErrorOr<BAN::UniqPtr<PIT>> create();
|
||||
|
||||
virtual uint64_t ms_since_boot() const override;
|
||||
virtual void sleep(uint64_t) const override;
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
};
|
||||
|
||||
}
|
||||
36
kernel/include/kernel/Timer/Timer.h
Normal file
36
kernel/include/kernel/Timer/Timer.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <BAN/UniqPtr.h>
|
||||
#include <BAN/Vector.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
class Timer
|
||||
{
|
||||
public:
|
||||
virtual ~Timer() {};
|
||||
virtual uint64_t ms_since_boot() const = 0;
|
||||
virtual void sleep(uint64_t) const = 0;
|
||||
};
|
||||
|
||||
class TimerHandler
|
||||
{
|
||||
public:
|
||||
static void initialize();
|
||||
static TimerHandler& get();
|
||||
static bool is_initialized();
|
||||
|
||||
uint64_t ms_since_boot() const;
|
||||
void sleep(uint64_t) const;
|
||||
|
||||
private:
|
||||
TimerHandler() = default;
|
||||
|
||||
void initialize_timers();
|
||||
|
||||
private:
|
||||
BAN::Vector<BAN::UniqPtr<Timer>> m_timers;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user