The Pedigree Project
0.1
|
#include <Rtc.h>
Classes | |
class | Alarm |
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 () |
bool | initialise1 () INITIALISATION_ONLY |
bool | initialise2 () INITIALISATION_ONLY |
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 () |
Protected Member Functions | |
Rtc () INITIALISATION_ONLY | |
virtual | ~Rtc () |
Protected Member Functions inherited from Timer | |
Timer () | |
virtual | ~Timer () |
Private Member Functions | |
Rtc (const Rtc &) | |
Rtc & | operator= (const Rtc &) |
virtual bool | irq (irq_id_t number, InterruptState &state) |
void | setIndex (uint8_t index) |
void | waitForUpdateCompletion (uint8_t index) |
void | enableRtcUpdates (bool enable) |
uint8_t | read (uint8_t index) |
void | write (uint8_t index, uint8_t value) |
virtual | ~IrqHandler () |
Private Attributes | |
IoPort | m_IoPort |
irq_id_t | m_IrqId |
size_t | m_PeriodicIrqInfoIndex |
bool | m_bBCD |
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 |
uint64_t | m_TickCount |
TimerHandler * | m_Handlers [MAX_TIMER_HANDLERS] |
List< Alarm * > | m_Alarms |
Spinlock | m_Lock |
uint64_t | m_TscTicksPerNanosecond |
uint64_t | m_Tsc0 |
Static Private Attributes | |
static periodicIrqInfo_t | periodicIrqInfo [12] |
static Rtc | m_Instance |
Class for the Real-time clock / CMOS implementing the Timer interface
|
protected |
The default constructor
Definition at line 405 of file Rtc.cc.
References g_FreePages.
Referenced by ~Rtc().
|
inlineprotectedvirtual |
The destructor
Definition at line 84 of file Rtc.h.
References enableRtcUpdates(), irq(), operator=(), read(), Rtc(), setIndex(), waitForUpdateCompletion(), and write().
|
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 72 of file Rtc.cc.
References Processor::information(), m_Alarms, m_Lock, and m_TickCount.
|
private |
Dis/Enable the RTC updates
[in] | index | the index we want to access / have accessed |
[in] | enable | Do we want to enable or disable? |
Definition at line 575 of file Rtc.cc.
References m_IoPort, IoPort::read8(), setIndex(), and IoPort::write8().
Referenced by synchronise(), and ~Rtc().
|
virtual |
Get the current day of month
Implements Timer.
Definition at line 182 of file Rtc.cc.
References m_DayOfMonth.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Get the current nanosecond
Implements Timer.
Definition at line 213 of file Rtc.cc.
References m_Nanosecond.
|
virtual |
|
virtual |
Get the Tick count (time elapsed since system bootup)
Implements Timer.
Definition at line 217 of file Rtc.cc.
References getTickCountNano().
Referenced by removeAlarm().
|
virtual |
Get the Tick count (time elapsed since system bootup) in nanosconds.
Reimplemented from Timer.
Definition at line 221 of file Rtc.cc.
References m_Tsc0, and m_TscTicksPerNanosecond.
Referenced by getTickCount().
|
virtual |
bool Rtc::initialise1 | ( | ) |
Initialises the class
Definition at line 234 of file Rtc.cc.
References IoPort::allocate(), m_bBCD, m_DayOfMonth, m_Handlers, m_Hour, m_IoPort, m_IrqId, m_Minute, m_Month, m_PeriodicIrqInfoIndex, m_Second, m_Year, NOTICE, periodicIrqInfo, Rtc::periodicIrqInfo_t::rateBits, read(), and write().
Referenced by Pc::initialise().
bool Rtc::initialise2 | ( | ) |
Initialises the RTC's IRQ.
Definition at line 288 of file Rtc.cc.
References Processor::getInterrupts(), Processor::haltUntilInterrupt(), m_IrqId, m_TickCount, m_Tsc0, m_TscTicksPerNanosecond, NOTICE, read(), IrqManager::registerIsaIrqHandler(), Processor::setInterrupts(), and write().
Referenced by Pc::initialise().
|
privatevirtual |
Called when the handler is registered with the irq manager and the irq occurred
[in] | number | the irq number |
Implements IrqHandler.
Definition at line 415 of file Rtc.cc.
References Process::description(), g_FreePages, Process::getHeapUsage(), Process::getId(), Scheduler::getNumProcesses(), Scheduler::getProcess(), Machine::getSerial(), Scheduler::instance(), m_Alarms, m_DayOfMonth, m_Handlers, m_Hour, m_Lock, m_Minute, m_Month, m_Nanosecond, m_PeriodicIrqInfoIndex, m_Second, m_TickCount, m_Year, Rtc::periodicIrqInfo_t::ns, periodicIrqInfo, read(), Thread::sendEvent(), IrqManager::tick(), TimerHandler::timer(), UNLIKELY, and WARNING.
Referenced by ~Rtc().
The assignment operator
Referenced by ~Rtc().
|
private |
Read the value in the CMOS at a specific index
[in] | index | the index |
Definition at line 584 of file Rtc.cc.
References m_IoPort, IoPort::read8(), setIndex(), and waitForUpdateCompletion().
Referenced by initialise1(), initialise2(), irq(), synchronise(), uninitialise(), and ~Rtc().
|
virtual |
|
virtual |
Removes the event pEvent
from the alarm queue.
pEvent | Event to remove alarm for. |
bRetZero | If true, returns zero rather the time until firing |
Implements Timer.
Definition at line 105 of file Rtc.cc.
References getTickCount(), m_Alarms, m_Handlers, and m_Lock.
|
private |
Set the index register
[in] | index | the new index |
Definition at line 561 of file Rtc.cc.
References m_IoPort, IoPort::read8(), and IoPort::write8().
Referenced by enableRtcUpdates(), read(), waitForUpdateCompletion(), write(), and ~Rtc().
|
virtual |
Synchronise the time/date with the hardware
Reimplemented from Timer.
Definition at line 336 of file Rtc.cc.
References enableRtcUpdates(), m_bBCD, m_DayOfMonth, m_Hour, m_Minute, m_Month, m_Second, m_Year, read(), and write().
Referenced by uninitialise().
void Rtc::uninitialise | ( | ) |
Uninitialises the class
Definition at line 389 of file Rtc.cc.
References IoPort::free(), m_IoPort, m_IrqId, read(), synchronise(), IrqManager::unregisterHandler(), and write().
|
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 566 of file Rtc.cc.
References m_IoPort, IoPort::read8(), and setIndex().
Referenced by read(), write(), and ~Rtc().
|
private |
Write the value to the CMOS at a specific index
[in] | index | the index |
[in] | value | the value |
Definition at line 595 of file Rtc.cc.
References m_IoPort, setIndex(), waitForUpdateCompletion(), and IoPort::write8().
Referenced by initialise1(), initialise2(), synchronise(), uninitialise(), and ~Rtc().
List of alarms.
Definition at line 189 of file Rtc.h.
Referenced by addAlarm(), irq(), and removeAlarm().
|
private |
BCD mode? (otherwise in binary mode)
Definition at line 131 of file Rtc.h.
Referenced by initialise1(), and synchronise().
|
private |
The current day of month
Definition at line 138 of file Rtc.h.
Referenced by getDayOfMonth(), getDayOfWeek(), initialise1(), irq(), and synchronise().
|
private |
All timer handlers installed
Definition at line 169 of file Rtc.h.
Referenced by initialise1(), irq(), and removeAlarm().
|
private |
The current hour
Definition at line 140 of file Rtc.h.
Referenced by getHour(), initialise1(), irq(), and synchronise().
|
private |
The CMOS/Real-time Clock I/O port range
Definition at line 122 of file Rtc.h.
Referenced by enableRtcUpdates(), initialise1(), read(), setIndex(), uninitialise(), waitForUpdateCompletion(), and write().
|
private |
The IRQ Identifier
Definition at line 125 of file Rtc.h.
Referenced by initialise1(), initialise2(), and uninitialise().
|
private |
Protects m_Alarms.
Definition at line 191 of file Rtc.h.
Referenced by addAlarm(), irq(), and removeAlarm().
|
private |
The current minute
Definition at line 142 of file Rtc.h.
Referenced by getMinute(), initialise1(), irq(), and synchronise().
|
private |
The current month
Definition at line 136 of file Rtc.h.
Referenced by getDayOfWeek(), getMonth(), initialise1(), irq(), and synchronise().
|
private |
The current nanosecond
Definition at line 146 of file Rtc.h.
Referenced by getNanosecond(), and irq().
|
private |
Index into the periodicIrqInfo table
Definition at line 128 of file Rtc.h.
Referenced by initialise1(), and irq().
|
private |
The current second
Definition at line 144 of file Rtc.h.
Referenced by getSecond(), initialise1(), irq(), and synchronise().
|
private |
The current tick count in nanoseconds
Definition at line 149 of file Rtc.h.
Referenced by addAlarm(), initialise2(), and irq().
|
private |
Initial TSC value.
Definition at line 197 of file Rtc.h.
Referenced by getTickCountNano(), and initialise2().
|
private |
Tracks the number of nanoseconds per TSC tick.
Definition at line 194 of file Rtc.h.
Referenced by getTickCountNano(), and initialise2().
|
private |
The current year
Definition at line 134 of file Rtc.h.
Referenced by getDayOfWeek(), getYear(), initialise1(), irq(), and synchronise().
|
staticprivate |
Information about the RTC's periodic irq
Definition at line 163 of file Rtc.h.
Referenced by initialise1(), and irq().