21#include "pedigree/kernel/Log.h"
22#include "pedigree/kernel/compiler.h"
23#include "pedigree/kernel/machine/IrqManager.h"
24#include "pedigree/kernel/machine/Machine.h"
25#include "pedigree/kernel/machine/SchedulerTimerDispatchCleanup.h"
26#include "pedigree/kernel/machine/SchedulerTimerHandler.h"
27#include "pedigree/kernel/processor/Processor.h"
28#include "pedigree/kernel/processor/types.h"
32#define PIT_FREQUENCY 10
34#define PIT_FREQUENCY 100
39uint64_t Pit::nominalQuantumNs()
const {
40 return uint64_t(1000000000) / PIT_FREQUENCY;
57 IrqManager& irqManager = *Machine::instance().getIrqManager();
66 size_t divisor = 1193180 / PIT_FREQUENCY;
72 uint8_t l = divisor & 0xFF;
73 uint8_t h = (divisor >> 8) & 0xFF;
86 IrqManager& irqManager = *Machine::instance().getIrqManager();
88 FATAL(
"PIT teardown could not remove its direct IRQ route");
100Pit::Pit() : m_IoPort(
"PIT"), m_IrqId(0), m_Handler() {}
102void Pit::schedulerIrq(irq_id_t number, InterruptState& state) {
107 dispatch.handler()->
timer(nominalQuantumNs(), state);
bool allocate(io_port_t ioPort, size_t size)
virtual void write8(uint8_t value, size_t offset=0)
virtual irq_id_t registerSchedulerIrqHandler(uint8_t irq, SchedulerIrqHandler *handler, const IrqPolicy &policy)
virtual bool unregisterSchedulerIrqHandler(irq_id_t Id, SchedulerIrqHandler *handler)
virtual bool removeHandler(SchedulerTimerHandler *handler)
virtual bool registerHandler(SchedulerTimerHandler *handler)
bool initialise() INITIALISATION_ONLY
Pit() INITIALISATION_ONLY
SchedulerTimerHandlerSlot m_Handler
bool beginDispatch(size_t owner, DispatchGuard &guard)
bool publish(size_t owner, SchedulerTimerHandler *handler)
bool unpublish(size_t owner, SchedulerTimerHandler *handler)
virtual void timer(uint64_t delta, InterruptState &state)=0
static bool canRemoveHandlerInCurrentContext()