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

#include <GPTimer.h>

+ Inheritance diagram for GPTimer:
+ Collaboration diagram for GPTimer:

Classes

class  Alarm
 

Public Member Functions

 GPTimer ()
 
virtual ~GPTimer ()
 
void initialise (size_t timer, uintptr_t base)
 
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 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)
 
- Public Member Functions inherited from Timer
virtual uint64_t getTickCountNano ()
 
virtual Time::Timestamp getUnixTimestamp ()
 
virtual void synchronise (bool tohw=false)
 Synchronises the timer with the hardware. Useful for updating the fields returned by get*, especially if IRQs are not enabled. More...
 

Private Types

enum  Registers {
  TIDR = 0x00 / 4, TIOCP_CFG = 0x10 / 4, TISTAT = 0x14 / 4, TISR = 0x18 / 4,
  TIER = 0x1C / 4, TWER = 0x20 / 4, TCLR = 0x24 / 4, TCRR = 0x28 / 4,
  TLDR = 0x2C / 4, TTGR = 0x30 / 4, TWPS = 0x34 / 4, TMAR = 0x38 / 4,
  TCAR1 = 0x3C / 4, TSICR = 0x40 / 4, TCAR2 = 0x44 / 4, TPIR = 0x48 / 4,
  TNIR = 0x4C / 4, TCVR = 0x50 / 4, TOCR = 0x54 / 4, TOWR = 0x58 / 4
}
 

Private Member Functions

 GPTimer (const Timer &)
 
GPTimeroperator= (const Timer &)
 
virtual void interrupt (size_t nInterruptnumber, InterruptState &state)
 

Private Attributes

MemoryRegion m_MmioBase
 
bool m_bIrqInstalled
 
size_t m_Irq
 
TimerHandlerm_Handlers [MAX_TIMER_HANDLERS]
 
List< Alarm * > m_Alarms
 
uint64_t m_TickCount
 

Additional Inherited Members

- Protected Member Functions inherited from Timer
 Timer ()
 
virtual ~Timer ()
 
- Protected Member Functions inherited from SchedulerTimer
 SchedulerTimer ()
 
virtual ~SchedulerTimer ()
 
- Protected Member Functions inherited from InterruptHandler
virtual ~InterruptHandler ()
 

Detailed Description

Driver for a general purpose timer - provide the MMIO base during initialisation and it'll be able to generate IRQs and call handlers and all that good stuff.

Definition at line 54 of file GPTimer.h.

Member Enumeration Documentation

enum GPTimer::Registers
private

Register offsets

Definition at line 198 of file GPTimer.h.

Constructor & Destructor Documentation

GPTimer::GPTimer ( )
inline

The default constructor

Definition at line 58 of file GPTimer.h.

virtual GPTimer::~GPTimer ( )
inlinevirtual

The destructor

Definition at line 66 of file GPTimer.h.

GPTimer::GPTimer ( const Timer )
private

The copy-constructor

Note
NOT implemented

Member Function Documentation

void GPTimer::addAlarm ( class Event pEvent,
size_t  alarmSecs,
size_t  alarmUsecs = 0 
)
virtual

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 175 of file GPTimer.cc.

References Processor::information().

virtual uint8_t GPTimer::getDayOfMonth ( )
inlinevirtual

Get the current day of month

Returns
the current day of month

Implements Timer.

Definition at line 87 of file GPTimer.h.

virtual uint8_t GPTimer::getDayOfWeek ( )
inlinevirtual

Get the current day of week

Returns
the current day of week

Implements Timer.

Definition at line 93 of file GPTimer.h.

virtual uint8_t GPTimer::getHour ( )
inlinevirtual

Get the current hour

Returns
the current hour

Implements Timer.

Definition at line 99 of file GPTimer.h.

virtual uint8_t GPTimer::getMinute ( )
inlinevirtual

Get the current minute

Returns
the current minute

Implements Timer.

Definition at line 105 of file GPTimer.h.

virtual uint8_t GPTimer::getMonth ( )
inlinevirtual

Get the current month

Returns
the current month

Implements Timer.

Definition at line 81 of file GPTimer.h.

virtual uint64_t GPTimer::getNanosecond ( )
inlinevirtual

Get the current nanosecond

Returns
the current nanosecond

Implements Timer.

Definition at line 117 of file GPTimer.h.

virtual uint8_t GPTimer::getSecond ( )
inlinevirtual

Get the current second

Returns
the current second

Implements Timer.

Definition at line 111 of file GPTimer.h.

virtual uint64_t GPTimer::getTickCount ( )
inlinevirtual

Get the Tick count (time elapsed since system bootup)

Returns
the tick count in milliseconds

Implements Timer.

Definition at line 124 of file GPTimer.h.

virtual size_t GPTimer::getYear ( )
inlinevirtual

Get the current year

Returns
the current year

Implements Timer.

Definition at line 75 of file GPTimer.h.

void GPTimer::initialise ( size_t  timer,
uintptr_t  base 
)
void GPTimer::interrupt ( size_t  nInterruptNumber,
InterruptState &  state 
)
privatevirtual

Called when the handler is registered with the interrupt manager and the interrupt occurred

Parameters
[in]nInterruptNumberthe interrupt number
[in]statereference to the state before the interrupt

Implements InterruptHandler.

Definition at line 236 of file GPTimer.cc.

References Thread::sendEvent(), and MemoryRegion::virtualAddress().

GPTimer& GPTimer::operator= ( const Timer )
private

The assignment operator

Note
NOT implemented
void GPTimer::removeAlarm ( class Event pEvent)
virtual

Removes the event pEvent from the alarm queue.

Parameters
pEventEvent to remove alarm for.

Implements Timer.

Definition at line 185 of file GPTimer.cc.

size_t GPTimer::removeAlarm ( class Event pEvent,
bool  bRetZero 
)
virtual

Removes the event pEvent from the alarm queue.

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 200 of file GPTimer.cc.

Member Data Documentation

List<Alarm *> GPTimer::m_Alarms
private

List of alarms.

Definition at line 192 of file GPTimer.h.

bool GPTimer::m_bIrqInstalled
private

Whether the IRQ for this timer is installed. This allows lazy installation of the IRQ handler - we only need to get IRQs for timers which have handlers after all.

Definition at line 166 of file GPTimer.h.

TimerHandler* GPTimer::m_Handlers[MAX_TIMER_HANDLERS]
private

All timer handlers installed

Definition at line 172 of file GPTimer.h.

size_t GPTimer::m_Irq
private

Internal IRQ number

Definition at line 169 of file GPTimer.h.

MemoryRegion GPTimer::m_MmioBase
private

MMIO base

Definition at line 160 of file GPTimer.h.

uint64_t GPTimer::m_TickCount
private

Internal tick count - milliseconds, used for alarms and things

Definition at line 195 of file GPTimer.h.


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