|
The Pedigree Project 0.1
|
#include <Rtc.h>
Inheritance diagram for Rtc:
Collaboration diagram for Rtc:Classes | |
| class | CmosTransactionGuard |
| struct | periodicIrqInfo_t |
Public Member Functions | |
| virtual bool | registerHandler (TimerHandler *handler) |
| virtual bool | unregisterHandler (TimerHandler *handler) |
| virtual void | addAlarm (class Event *pEvent, size_t alarmSecs, size_t alarmUsecs=0) |
| virtual void | removeAlarm (class Event *pEvent) |
| virtual size_t | removeAlarm (class Event *pEvent, bool bRetZero) |
| virtual size_t | getYear () |
| virtual uint8_t | getMonth () |
| virtual uint8_t | getDayOfMonth () |
| virtual uint8_t | getDayOfWeek () |
| virtual uint8_t | getHour () |
| virtual uint8_t | getMinute () |
| virtual uint8_t | getSecond () |
| virtual uint64_t | getNanosecond () |
| virtual uint64_t | getTickCount () |
| virtual uint64_t | getTickCountNano () |
| virtual uint64_t | getTickCountNanoFast () |
| Time::CpuTimeSample | sampleCpuTime () override |
| bool | initialise1 (uint8_t centuryIndex) INITIALISATION_ONLY |
| bool | initialise2 () INITIALISATION_ONLY |
| void | initialiseProcessorClock () INITIALISATION_ONLY |
| bool | initialise3 () |
| virtual void | synchronise (bool tohw=false) |
| void | uninitialise () |
Public Member Functions inherited from Timer | |
| virtual Time::Timestamp | getUnixTimestamp () |
Static Public Member Functions | |
| static Rtc & | instance () |
| static EXPORTED_PUBLIC uint8_t | readCmos (uint8_t index) |
| static EXPORTED_PUBLIC void | writeCmos (uint8_t index, uint8_t value) |
Protected Member Functions | |
| Rtc () INITIALISATION_ONLY | |
| virtual | ~Rtc () |
Protected Member Functions inherited from Timer | |
| Timer () | |
| virtual | ~Timer () |
Private Types | |
| using | Alarm = RtcAlarmQueue::Record |
Private Member Functions | |
| Rtc (const Rtc &) | |
| Rtc & | operator= (const Rtc &) |
| IrqDisposition | irq (irq_id_t number) override |
| void | processElapsedTime (uint64_t observed) |
| void | setPeriodicInterruptEnabled (bool enabled) |
| void | setIndexLocked (uint8_t index) |
| bool | waitForUpdateCompletion (uint8_t index) |
| bool | read (uint8_t index, uint8_t &value) |
| uint8_t | readLocked (uint8_t index) |
| void | writeLocked (uint8_t index, uint8_t value) |
| uint8_t | read (uint8_t index) |
| bool | write (uint8_t index, uint8_t value) |
| bool | readHardwareClock () |
| bool | writeHardwareClock () |
| bool | inhibitClockUpdatesLocked (uint8_t &status) |
| void | drainRemoteAlarmDispatch (class Event *pEvent, void *owner) |
| virtual | ~IrqHandler () |
Private Member Functions inherited from IrqHandlerBase | |
| virtual | ~IrqHandlerBase () |
Private Attributes | |
| IoPort | m_IoPort |
| irq_id_t | m_IrqId |
| size_t | m_PeriodicIrqInfoIndex |
| uint8_t | m_CenturyIndex |
| size_t | m_Year |
| uint8_t | m_Month |
| uint8_t | m_DayOfMonth |
| uint8_t | m_Hour |
| uint8_t | m_Minute |
| uint8_t | m_Second |
| uint64_t | m_Nanosecond |
| Atomic< uint64_t > | m_TickCount |
| uint64_t | m_ProcessedTickCount |
| TimerHandlerRegistry | m_HandlerRegistry |
| RtcAlarmQueue | m_AlarmQueue |
| Spinlock | m_Lock |
| Mutex | m_CmosLock |
| PcTscClock::Calibration | m_TscCalibration |
| uint64_t | m_Tsc0 |
| PcTscClock::MonotonicPublication | m_MonotonicTicks |
Static Private Attributes | |
| static periodicIrqInfo_t | periodicIrqInfo [12] |
| static Rtc | m_Instance |
Class for the Real-time clock / CMOS implementing the Timer interface
|
private |
|
private |
The copy-constructor
|
virtual |
Dispatches the Event pEvent to the current thread in alarmSecs time.
| pEvent | Event to dispatch. |
| alarmSecs | Number of seconds to wait. |
Implements Timer.
Definition at line 134 of file Rtc.cc.
References Spinlock::acquire(), getTickCountNano(), ProcessorBase::information(), m_AlarmQueue, m_Lock, and Spinlock::release().
|
private |
Drains a sendEvent handoff owned by another processor.
Definition at line 154 of file Rtc.cc.
References Spinlock::acquire(), Thread::getDebugState(), ProcessorBase::getInterrupts(), ProcessorBase::information(), Scheduler::instance(), m_AlarmQueue, m_Lock, ProcessorBase::pause(), Spinlock::release(), Thread::setDebugState(), and Scheduler::yield().
Referenced by removeAlarm(), and removeAlarm().
Here is the caller graph for this function:
|
virtual |
Get the current day of month
Implements Timer.
Definition at line 245 of file Rtc.cc.
References m_DayOfMonth.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Get the current nanosecond
Implements Timer.
Definition at line 271 of file Rtc.cc.
References m_Nanosecond.
|
virtual |
|
virtual |
Get the Tick count (time elapsed since system bootup)
Implements Timer.
Definition at line 274 of file Rtc.cc.
References getTickCountNano().
|
virtual |
Get the Tick count (time elapsed since system bootup) in nanosconds.
Reimplemented from Timer.
Definition at line 277 of file Rtc.cc.
References ProcessorBase::getInterrupts(), ProcessorBase::information(), m_MonotonicTicks, m_TickCount, m_Tsc0, m_TscCalibration, and ProcessorBase::setInterrupts().
Referenced by addAlarm(), getTickCount(), initialise3(), irq(), and removeAlarm().
Here is the caller graph for this function:
|
virtual |
Get the tick count while the caller already owns the IRQ-disabled window.
Reimplemented from Timer.
Definition at line 298 of file Rtc.cc.
References sampleCpuTime().
|
virtual |
|
private |
| bool Rtc::initialise1 | ( | uint8_t | centuryIndex | ) |
Initialises the class
Definition at line 316 of file Rtc.cc.
References IoPort::allocate(), Hex, m_HandlerRegistry, m_IoPort, m_IrqId, m_PeriodicIrqInfoIndex, periodicIrqInfo, Rtc::periodicIrqInfo_t::rateBits, readHardwareClock(), TimerHandlerRegistry::reset(), and write().
Referenced by Pc::initialise().
Here is the caller graph for this function:| bool Rtc::initialise2 | ( | ) |
Calibrates the TSC while the RTC line remains masked.
Definition at line 373 of file Rtc.cc.
References ProcessorBase::information(), m_MonotonicTicks, m_PeriodicIrqInfoIndex, m_ProcessedTickCount, m_TickCount, m_Tsc0, m_TscCalibration, Rtc::periodicIrqInfo_t::ns, ProcessorBase::pause(), periodicIrqInfo, and setPeriodicInterruptEnabled().
Referenced by Pc::initialise().
Here is the caller graph for this function:| bool Rtc::initialise3 | ( | ) |
Registers the RTC worker and enables periodic IRQ delivery.
Definition at line 444 of file Rtc.cc.
References Dec, getTickCountNano(), m_IrqId, m_PeriodicIrqInfoIndex, m_ProcessedTickCount, m_TickCount, periodicIrqInfo, Rtc::periodicIrqInfo_t::rateBits, IrqManager::registerIsaIrqHandler(), setPeriodicInterruptEnabled(), StringView::substring(), and write().
| void Rtc::initialiseProcessorClock | ( | ) |
Anchors the calling application processor to global monotonic time.
Definition at line 430 of file Rtc.cc.
References ProcessorBase::getInterrupts(), ProcessorBase::information(), m_MonotonicTicks, m_TickCount, and ProcessorBase::setInterrupts().
|
overrideprivatevirtual |
Handles a pending IRQ in thread context.
Implements IrqHandler.
Definition at line 570 of file Rtc.cc.
References getTickCountNano(), m_CmosLock, and processElapsedTime().
|
private |
Applies every elapsed interval observed by the IRQ8 worker.
Definition at line 590 of file Rtc.cc.
References Spinlock::acquire(), Scheduler::acquireProcess(), Process::description(), TimerHandlerRegistry::dispatch(), Process::getHeapUsage(), Process::getId(), Scheduler::getNumProcesses(), TargetInfo::getPageSize(), Machine::getSerial(), Scheduler::instance(), m_AlarmQueue, m_DayOfMonth, m_HandlerRegistry, m_Hour, m_Lock, m_Minute, m_Month, m_Nanosecond, m_ProcessedTickCount, m_Second, m_TickCount, m_Year, Spinlock::release(), Thread::sendEvent(), IrqManager::tick(), and UNLIKELY.
Referenced by irq().
Here is the caller graph for this function:
|
private |
|
static |
Access CMOS through the RTC-owned selector/data transaction.
These entrypoints exist for PC compatibility layers which need CMOS bytes but must not access ports 0x70/0x71 independently of the RTC.
Definition at line 719 of file Rtc.cc.
References m_Instance.
|
private |
Transfer a complete clock snapshot without partially publishing it.
Definition at line 773 of file Rtc.cc.
References m_CmosLock, m_DayOfMonth, m_Hour, m_Minute, m_Month, m_Second, m_Year, and waitForUpdateCompletion().
Referenced by initialise1(), and synchronise().
Here is the caller graph for this function:
|
virtual |
|
virtual |
Removes the event pEvent from the alarm queue. Once this returns, the timer will not begin another delivery of this event.
| pEvent | Event to remove alarm for. |
Implements Timer.
Definition at line 188 of file Rtc.cc.
References Spinlock::acquire(), drainRemoteAlarmDispatch(), m_AlarmQueue, m_Lock, and Spinlock::release().
|
virtual |
Removes the event pEvent from the alarm queue. Once this returns, the timer will not begin another delivery of this event.
| pEvent | Event to remove alarm for. |
| bRetZero | If true, returns zero rather the time until firing |
Implements Timer.
Definition at line 204 of file Rtc.cc.
References Spinlock::acquire(), drainRemoteAlarmDispatch(), getTickCountNano(), m_AlarmQueue, m_Lock, and Spinlock::release().
|
overridevirtual |
Samples nanoseconds and CPU identity while the caller keeps interrupts disabled.
Reimplemented from Timer.
Definition at line 302 of file Rtc.cc.
References ProcessorBase::index(), ProcessorBase::information(), m_Tsc0, and m_TscCalibration.
Referenced by getTickCountNanoFast().
Here is the caller graph for this function:
|
private |
Set the index register
| [in] | index | the new index |
Definition at line 687 of file Rtc.cc.
References m_IoPort, IoPort::read8(), and IoPort::write8().
Referenced by waitForUpdateCompletion().
Here is the caller graph for this function:
|
private |
Atomically changes the RTC periodic-interrupt source and clears C.
Definition at line 822 of file Rtc.cc.
References m_CmosLock.
Referenced by initialise2(), initialise3(), and uninitialise().
Here is the caller graph for this function:
|
virtual |
Synchronise the time/date with the hardware
Reimplemented from Timer.
Definition at line 501 of file Rtc.cc.
References readHardwareClock().
Referenced by uninitialise().
Here is the caller graph for this function:| void Rtc::uninitialise | ( | ) |
Uninitialises the class
Definition at line 512 of file Rtc.cc.
References IoPort::free(), m_AlarmQueue, m_HandlerRegistry, m_IoPort, m_IrqId, m_Lock, panic(), TimerHandlerRegistry::reset(), setPeriodicInterruptEnabled(), and synchronise().
Referenced by Pc::deinitialise().
Here is the caller graph for this function:
|
virtual |
|
private |
Wait until the Update of the RTC entries in the CMOS is complete, if we want to access one of those entries
| [in] | index | the index we want to access afterwards |
Definition at line 692 of file Rtc.cc.
References m_CmosLock, m_IoPort, ProcessorBase::pause(), IoPort::read8(), and setIndexLocked().
Referenced by readHardwareClock(), and write().
Here is the caller graph for this function:
|
private |
Write the value to the CMOS at a specific index
| [in] | index | the index |
| [in] | value | the value |
Definition at line 743 of file Rtc.cc.
References m_CmosLock, and waitForUpdateCompletion().
Referenced by initialise1(), and initialise3().
Here is the caller graph for this function:
|
private |
|
private |
Intrusive alarm ownership; queue operations never allocate in IRQs.
Definition at line 223 of file Rtc.h.
Referenced by addAlarm(), drainRemoteAlarmDispatch(), processElapsedTime(), removeAlarm(), removeAlarm(), and uninitialise().
|
private |
Serialises the CMOS index/data register pair across processors.
Definition at line 228 of file Rtc.h.
Referenced by irq(), readHardwareClock(), setPeriodicInterruptEnabled(), waitForUpdateCompletion(), and write().
|
private |
The current day of month
Definition at line 185 of file Rtc.h.
Referenced by getDayOfMonth(), getDayOfWeek(), processElapsedTime(), and readHardwareClock().
|
private |
Timer handlers and their callback lifetime state.
Definition at line 218 of file Rtc.h.
Referenced by initialise1(), processElapsedTime(), and uninitialise().
|
private |
The current hour
Definition at line 187 of file Rtc.h.
Referenced by getHour(), processElapsedTime(), and readHardwareClock().
|
staticprivate |
|
private |
The CMOS/Real-time Clock I/O port range
Definition at line 170 of file Rtc.h.
Referenced by initialise1(), setIndexLocked(), uninitialise(), and waitForUpdateCompletion().
|
private |
The IRQ Identifier
Definition at line 173 of file Rtc.h.
Referenced by initialise1(), initialise3(), and uninitialise().
|
private |
Protects the alarm queue and the dispatch-ownership transition.
Definition at line 225 of file Rtc.h.
Referenced by addAlarm(), drainRemoteAlarmDispatch(), processElapsedTime(), removeAlarm(), removeAlarm(), and uninitialise().
|
private |
The current minute
Definition at line 189 of file Rtc.h.
Referenced by getMinute(), processElapsedTime(), and readHardwareClock().
|
private |
Cross-processor monotonic floor, published without a retry loop.
Definition at line 237 of file Rtc.h.
Referenced by getTickCountNano(), initialise2(), and initialiseProcessorClock().
|
private |
The current month
Definition at line 183 of file Rtc.h.
Referenced by getDayOfWeek(), getMonth(), processElapsedTime(), and readHardwareClock().
|
private |
The current nanosecond
Definition at line 193 of file Rtc.h.
Referenced by getNanosecond(), and processElapsedTime().
|
private |
Index into the periodicIrqInfo table
Definition at line 176 of file Rtc.h.
Referenced by initialise1(), initialise2(), and initialise3().
|
private |
Worker cursor used to aggregate delayed periodic delivery.
Definition at line 199 of file Rtc.h.
Referenced by initialise2(), initialise3(), and processElapsedTime().
|
private |
The current second
Definition at line 191 of file Rtc.h.
Referenced by getSecond(), processElapsedTime(), and readHardwareClock().
|
private |
Latest elapsed-time cursor published by the IRQ8 worker.
Definition at line 196 of file Rtc.h.
Referenced by getTickCountNano(), initialise2(), initialise3(), initialiseProcessorClock(), and processElapsedTime().
|
private |
Bootstrap fallback before a per-processor anchor is available.
Definition at line 234 of file Rtc.h.
Referenced by getTickCountNano(), initialise2(), and sampleCpuTime().
|
private |
Exact RTC-calibrated conversion from TSC cycles to nanoseconds.
Definition at line 231 of file Rtc.h.
Referenced by getTickCountNano(), initialise2(), and sampleCpuTime().
|
private |
The current year
Definition at line 181 of file Rtc.h.
Referenced by getDayOfWeek(), getYear(), processElapsedTime(), and readHardwareClock().
|
staticprivate |
Information about the RTC's periodic irq
Definition at line 86 of file Rtc.h.
Referenced by initialise1(), initialise2(), and initialise3().