The Pedigree Project 0.1
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
VirtTimer Class Reference

#include <Timer.h>

+ Inheritance diagram for VirtTimer:
+ Collaboration diagram for VirtTimer:

Classes

struct  Alarm
 

Public Member Functions

bool initialise1 ()
 
bool initialise3 ()
 
void uninitialise ()
 
size_t getYear () override
 
uint8_t getMonth () override
 
uint8_t getDayOfMonth () override
 
uint8_t getDayOfWeek () override
 
uint8_t getHour () override
 
uint8_t getMinute () override
 
uint8_t getSecond () override
 
uint64_t getNanosecond () override
 
uint64_t getTickCount () override
 
uint64_t getTickCountNano () override
 
uint64_t getTickCountNanoFast () override
 
Time::Timestamp getUnixTimestamp () override
 
void synchronise (bool tohw=false) override
 Synchronises the timer with the hardware. Useful for updating the fields returned by get*, especially if IRQs are not enabled.
 
bool registerHandler (TimerHandler *handler) override
 
bool unregisterHandler (TimerHandler *handler) override
 
void addAlarm (Event *event, size_t seconds, size_t microseconds=0) override
 
void removeAlarm (Event *event) override
 
size_t removeAlarm (Event *event, bool returnZero) override
 
- Public Member Functions inherited from Timer
virtual Time::CpuTimeSample sampleCpuTime ()
 
virtual bool armHandler (TimerHandler *, uint64_t)
 
virtual bool supportsDeadlines () const
 
virtual void deadlineInterrupt ()
 

Static Public Member Functions

static VirtTimer & instance ()
 

Private Member Functions

HardStageDisposition hardIrq (irq_id_t number, InterruptState &state, size_t &work) override
 
void threadedIrq (size_t work) override
 
bool quiesceIrqSources () override
 
void rearmIrqSources (size_t work) override
 
uint64_t ticksToNanoseconds (uint64_t ticks) const
 
void processElapsed (uint64_t nanoseconds)
 
void updateCivilTime (uint64_t seconds)
 
- Private Member Functions inherited from SplitIrqHandler
 SplitIrqHandler (const String &name)
 
bool initialiseSplitIrq ()
 
irq_id_t registerIsaSplitIrq (IrqManager &manager, uint8_t irq, const IrqPolicy &policy)
 
irq_id_t registerPciSplitIrq (IrqManager &manager, Device &device, const IrqPolicy &policy)
 
bool shutdownSplitIrq ()
 

Static Private Member Functions

static uint64_t counter ()
 

Private Attributes

uint64_t m_Frequency
 
uint64_t m_BootCount
 
uint64_t m_LastCount
 
uint64_t m_RtcBaseCount
 
uint64_t m_RtcBaseSeconds
 
uint64_t m_ElapsedSinceSync
 
uint32_t m_IntervalTicks
 
irq_id_t m_IrqId
 
size_t m_Year
 
uint8_t m_Month
 
uint8_t m_Day
 
uint8_t m_DayOfWeek
 
uint8_t m_Hour
 
uint8_t m_Minute
 
uint8_t m_Second
 
bool m_Prepared
 
bool m_Initialised
 
TimerHandlerRegistry m_Handlers
 
List< Alarm * > m_Alarms
 
Spinlock m_AlarmLock
 

Static Private Attributes

static VirtTimer m_Instance
 

Additional Inherited Members

- Protected Member Functions inherited from Timer
 Timer ()
 
virtual ~Timer ()
 
- Private Types inherited from SplitIrqHandler
enum class  HardStageDisposition : size_t { NotHandled , Handled , Deferred }
 

Detailed Description

Monotonic architectural counter, PL031 wall clock, and 1 ms timer worker.

Definition at line 20 of file kernel/machine/mach_virt/Timer.h.

Constructor & Destructor Documentation

◆ VirtTimer()

VirtTimer::VirtTimer ( )
private

Definition at line 46 of file mach_virt/Timer.cc.

◆ ~VirtTimer()

VirtTimer::~VirtTimer ( )
overrideprivate

Definition at line 69 of file mach_virt/Timer.cc.

Member Function Documentation

◆ addAlarm()

void VirtTimer::addAlarm ( Event *  pEvent,
size_t  alarmSecs,
size_t  alarmUsecs = 0 
)
overridevirtual

Dispatches the Event pEvent to the current thread in alarmSecs time.

Parameters
pEventEvent to dispatch.
alarmSecsNumber of seconds to wait.

Implements Timer.

Definition at line 260 of file mach_virt/Timer.cc.

References getTickCountNano(), and ProcessorBase::information().

◆ counter()

uint64_t VirtTimer::counter ( )
staticprivate

Definition at line 73 of file mach_virt/Timer.cc.

◆ getDayOfMonth()

uint8_t VirtTimer::getDayOfMonth ( )
overridevirtual

Get the current day of month

Returns
the current day of month

Implements Timer.

Definition at line 232 of file mach_virt/Timer.cc.

◆ getDayOfWeek()

uint8_t VirtTimer::getDayOfWeek ( )
overridevirtual

Get the current day of week

Returns
the current day of week

Implements Timer.

Definition at line 236 of file mach_virt/Timer.cc.

◆ getHour()

uint8_t VirtTimer::getHour ( )
overridevirtual

Get the current hour

Returns
the current hour

Implements Timer.

Definition at line 240 of file mach_virt/Timer.cc.

◆ getMinute()

uint8_t VirtTimer::getMinute ( )
overridevirtual

Get the current minute

Returns
the current minute

Implements Timer.

Definition at line 244 of file mach_virt/Timer.cc.

◆ getMonth()

uint8_t VirtTimer::getMonth ( )
overridevirtual

Get the current month

Returns
the current month

Implements Timer.

Definition at line 228 of file mach_virt/Timer.cc.

◆ getNanosecond()

uint64_t VirtTimer::getNanosecond ( )
overridevirtual

Get the current nanosecond

Returns
the current nanosecond

Implements Timer.

Definition at line 188 of file mach_virt/Timer.cc.

◆ getSecond()

uint8_t VirtTimer::getSecond ( )
overridevirtual

Get the current second

Returns
the current second

Implements Timer.

Definition at line 248 of file mach_virt/Timer.cc.

◆ getTickCount()

uint64_t VirtTimer::getTickCount ( )
overridevirtual

Get the Tick count (time elapsed since system bootup)

Returns
the tick count in milliseconds

Implements Timer.

Definition at line 172 of file mach_virt/Timer.cc.

References getTickCountNano().

◆ getTickCountNano()

uint64_t VirtTimer::getTickCountNano ( )
overridevirtual

Get the Tick count (time elapsed since system bootup) in nanosconds.

Returns
the tick count in nanoseconds

Reimplemented from Timer.

Definition at line 176 of file mach_virt/Timer.cc.

Referenced by addAlarm(), getTickCount(), getTickCountNanoFast(), and removeAlarm().

+ Here is the caller graph for this function:

◆ getTickCountNanoFast()

uint64_t VirtTimer::getTickCountNanoFast ( )
overridevirtual

Get the tick count while the caller already owns the IRQ-disabled window.

Reimplemented from Timer.

Definition at line 180 of file mach_virt/Timer.cc.

References getTickCountNano().

◆ getUnixTimestamp()

Time::Timestamp VirtTimer::getUnixTimestamp ( )
overridevirtual

Get the time in UNIX timestamp form (seconds since Jan 1st, 1970).

Reimplemented from Timer.

Definition at line 184 of file mach_virt/Timer.cc.

◆ getYear()

size_t VirtTimer::getYear ( )
overridevirtual

Get the current year

Returns
the current year

Implements Timer.

Definition at line 224 of file mach_virt/Timer.cc.

◆ hardIrq()

VirtTimer::HardStageDisposition VirtTimer::hardIrq ( irq_id_t  number,
InterruptState &  state,
size_t &  work 
)
overrideprivatevirtual

Runs in hard IRQ context and must be bounded and nonblocking.

Implements SplitIrqHandler.

Definition at line 144 of file mach_virt/Timer.cc.

◆ initialise1()

bool VirtTimer::initialise1 ( )

Definition at line 85 of file mach_virt/Timer.cc.

◆ initialise3()

bool VirtTimer::initialise3 ( )

Definition at line 105 of file mach_virt/Timer.cc.

◆ instance()

VirtTimer & VirtTimer::instance ( )
static

Definition at line 42 of file mach_virt/Timer.cc.

◆ processElapsed()

void VirtTimer::processElapsed ( uint64_t  nanoseconds)
private

Definition at line 291 of file mach_virt/Timer.cc.

◆ quiesceIrqSources()

bool VirtTimer::quiesceIrqSources ( )
overrideprivatevirtual

Prevents new device interrupts before registry admission is closed. This runs in thread context and must be idempotent across failed retries.

Implements SplitIrqHandler.

Definition at line 163 of file mach_virt/Timer.cc.

◆ rearmIrqSources()

void VirtTimer::rearmIrqSources ( size_t  work)
overrideprivatevirtual

Rearms drained device sources unless shutdown has begun.

This runs in thread context with interrupts disabled and is serialised against quiesceIrqSources(). It must be bounded and nonblocking.

Implements SplitIrqHandler.

Definition at line 168 of file mach_virt/Timer.cc.

◆ registerHandler()

bool VirtTimer::registerHandler ( TimerHandler *  handler)
overridevirtual

Implements Timer.

Definition at line 252 of file mach_virt/Timer.cc.

◆ removeAlarm() [1/2]

void VirtTimer::removeAlarm ( Event *  pEvent)
overridevirtual

Removes the event pEvent from the alarm queue. Once this returns, the timer will not begin another delivery of this event.

Parameters
pEventEvent to remove alarm for.

Implements Timer.

Definition at line 268 of file mach_virt/Timer.cc.

References removeAlarm().

Referenced by removeAlarm().

+ Here is the caller graph for this function:

◆ removeAlarm() [2/2]

size_t VirtTimer::removeAlarm ( Event *  pEvent,
bool  bRetZero 
)
overridevirtual

Removes the event pEvent from the alarm queue. Once this returns, the timer will not begin another delivery of this event.

Parameters
pEventEvent to remove alarm for.
bRetZeroIf true, returns zero rather the time until firing
Returns
The number of seconds before the event would have fired, or zero if bRetZero is true.

Implements Timer.

Definition at line 272 of file mach_virt/Timer.cc.

References getTickCountNano().

◆ synchronise()

void VirtTimer::synchronise ( bool  tohw = false)
overridevirtual

Synchronises the timer with the hardware. Useful for updating the fields returned by get*, especially if IRQs are not enabled.

Parameters
tohwIf true, syncs back to the hardware, instead of from it.

Reimplemented from Timer.

Definition at line 213 of file mach_virt/Timer.cc.

◆ threadedIrq()

void VirtTimer::threadedIrq ( size_t  work)
overrideprivatevirtual

Runs in ordinary thread context and may use blocking APIs. The owned worker normally calls it; teardown may call it synchronously after the worker is joined to drain a rejected publication. It must not re-enable an interrupt source.

Implements SplitIrqHandler.

Definition at line 153 of file mach_virt/Timer.cc.

◆ ticksToNanoseconds()

uint64_t VirtTimer::ticksToNanoseconds ( uint64_t  ticks) const
private

Definition at line 77 of file mach_virt/Timer.cc.

◆ uninitialise()

void VirtTimer::uninitialise ( )

Definition at line 122 of file mach_virt/Timer.cc.

◆ unregisterHandler()

bool VirtTimer::unregisterHandler ( TimerHandler *  handler)
overridevirtual

Implements Timer.

Definition at line 256 of file mach_virt/Timer.cc.

◆ updateCivilTime()

void VirtTimer::updateCivilTime ( uint64_t  seconds)
private

Definition at line 192 of file mach_virt/Timer.cc.

Member Data Documentation

◆ m_AlarmLock

Spinlock VirtTimer::m_AlarmLock
private

Definition at line 87 of file kernel/machine/mach_virt/Timer.h.

◆ m_Alarms

List<Alarm*> VirtTimer::m_Alarms
private

Definition at line 86 of file kernel/machine/mach_virt/Timer.h.

◆ m_BootCount

uint64_t VirtTimer::m_BootCount
private

Definition at line 69 of file kernel/machine/mach_virt/Timer.h.

◆ m_Day

uint8_t VirtTimer::m_Day
private

Definition at line 78 of file kernel/machine/mach_virt/Timer.h.

◆ m_DayOfWeek

uint8_t VirtTimer::m_DayOfWeek
private

Definition at line 79 of file kernel/machine/mach_virt/Timer.h.

◆ m_ElapsedSinceSync

uint64_t VirtTimer::m_ElapsedSinceSync
private

Definition at line 73 of file kernel/machine/mach_virt/Timer.h.

◆ m_Frequency

uint64_t VirtTimer::m_Frequency
private

Definition at line 68 of file kernel/machine/mach_virt/Timer.h.

◆ m_Handlers

TimerHandlerRegistry VirtTimer::m_Handlers
private

Definition at line 85 of file kernel/machine/mach_virt/Timer.h.

◆ m_Hour

uint8_t VirtTimer::m_Hour
private

Definition at line 80 of file kernel/machine/mach_virt/Timer.h.

◆ m_Initialised

bool VirtTimer::m_Initialised
private

Definition at line 84 of file kernel/machine/mach_virt/Timer.h.

◆ m_Instance

VirtTimer VirtTimer::m_Instance
staticprivate

Definition at line 89 of file kernel/machine/mach_virt/Timer.h.

◆ m_IntervalTicks

uint32_t VirtTimer::m_IntervalTicks
private

Definition at line 74 of file kernel/machine/mach_virt/Timer.h.

◆ m_IrqId

irq_id_t VirtTimer::m_IrqId
private

Definition at line 75 of file kernel/machine/mach_virt/Timer.h.

◆ m_LastCount

uint64_t VirtTimer::m_LastCount
private

Definition at line 70 of file kernel/machine/mach_virt/Timer.h.

◆ m_Minute

uint8_t VirtTimer::m_Minute
private

Definition at line 81 of file kernel/machine/mach_virt/Timer.h.

◆ m_Month

uint8_t VirtTimer::m_Month
private

Definition at line 77 of file kernel/machine/mach_virt/Timer.h.

◆ m_Prepared

bool VirtTimer::m_Prepared
private

Definition at line 83 of file kernel/machine/mach_virt/Timer.h.

◆ m_RtcBaseCount

uint64_t VirtTimer::m_RtcBaseCount
private

Definition at line 71 of file kernel/machine/mach_virt/Timer.h.

◆ m_RtcBaseSeconds

uint64_t VirtTimer::m_RtcBaseSeconds
private

Definition at line 72 of file kernel/machine/mach_virt/Timer.h.

◆ m_Second

uint8_t VirtTimer::m_Second
private

Definition at line 82 of file kernel/machine/mach_virt/Timer.h.

◆ m_Year

size_t VirtTimer::m_Year
private

Definition at line 76 of file kernel/machine/mach_virt/Timer.h.


The documentation for this class was generated from the following files: