FreeNOS
|
Intel 8254 Programmable Interrupt Timer (PIT). More...
#include <IntelPIT.h>
Public Member Functions | |
IntelPIT () | |
Constructor. More... | |
uint | getCounter () |
Get current timer counter. More... | |
virtual Result | setFrequency (Size hertz) |
Set interrupt frequency. More... | |
Result | waitTrigger () |
Busy wait for one trigger period. More... | |
Public Member Functions inherited from Timer | |
struct Timer::Info | ALIGN (8) Info |
Timer information structure. More... | |
Timer () | |
Constructor. More... | |
Size | getInterrupt () const |
Get timer interrupt number. More... | |
Size | getFrequency () const |
Get timer frequency. More... | |
virtual Result | getCurrent (Info *info, const Size msecOffset=0) |
Get current timer info. More... | |
virtual Result | initialize () |
Initialize the timer. More... | |
virtual Result | start () |
Start the timer. More... | |
virtual Result | stop () |
Stop the timer. More... | |
virtual Result | tick () |
Process timer tick. More... | |
virtual Result | wait (u32 microseconds) const |
Busy wait a number of microseconds. More... | |
bool | isExpired (const Info &info) const |
Check if a timer value is expired. More... | |
Private Types | |
enum | Registers { Control = 0x43, Channel0Data = 0x40 } |
Hardware registers. More... | |
enum | ControlFlags { Channel0 = 0, LatchedRead = 0, AccessLowHigh = (3 << 4), SquareWave = (3 << 1), RateGenerator = (2 << 1) } |
Control Register Flags. More... | |
Private Member Functions | |
Result | setControl (ControlFlags flags) |
Set Control register. More... | |
Private Attributes | |
IntelIO | m_io |
I/O instance. More... | |
Static Private Attributes | |
static const uint | OscillatorFreq = 1193182 |
Oscillator frequency in hertz used by the PIT. More... | |
static const uint | InterruptNumber = 0 |
The IRQ vector for channel 0 is fixed to IRQ0. More... | |
Additional Inherited Members | |
Public Types inherited from Timer | |
enum | Result { Success, NotFound, IOError, InvalidFrequency } |
Result codes. More... | |
Data Fields inherited from Timer | |
enum Timer::Result | ALIGN |
Protected Attributes inherited from Timer | |
Size | m_ticks |
The current timer ticks. More... | |
Size | m_frequency |
Frequency of the Timer. More... | |
Size | m_int |
Timer interrupt number. More... | |
Intel 8254 Programmable Interrupt Timer (PIT).
Definition at line 40 of file IntelPIT.h.
|
private |
Control Register Flags.
Enumerator | |
---|---|
Channel0 | |
LatchedRead | |
AccessLowHigh | |
SquareWave | |
RateGenerator |
Definition at line 62 of file IntelPIT.h.
|
private |
IntelPIT::IntelPIT | ( | ) |
Constructor.
Definition at line 20 of file IntelPIT.cpp.
References InterruptNumber, and Timer::m_int.
uint IntelPIT::getCounter | ( | ) |
Get current timer counter.
The timer counter is used internally by the PIT to generate interrupts on the desired frequency. The PIT will decrement the timer counter until 0 is reached, at which it will generate an interrupt and restart at the initial timer counter value.
Definition at line 26 of file IntelPIT.cpp.
References Channel0, Channel0Data, IntelIO::inb(), LatchedRead, m_io, and setControl().
Referenced by waitTrigger().
|
private |
Set Control register.
flags | New flags to set in the Control register. |
Definition at line 76 of file IntelPIT.cpp.
References Control, flags, m_io, IntelIO::outb(), and Timer::Success.
Referenced by getCounter(), and setFrequency().
|
virtual |
Set interrupt frequency.
This function configures the PIT to generate interrupts on the given frequency. The new frequency will be applied immediately on the interrupts generated.
hertz | Number of interrupt triggers per second (in hertz) |
Reimplemented from Timer.
Definition at line 37 of file IntelPIT.cpp.
References AccessLowHigh, Channel0, Channel0Data, Timer::InvalidFrequency, Timer::m_frequency, m_io, OscillatorFreq, IntelIO::outb(), RateGenerator, setControl(), and Timer::Success.
Referenced by IntelKernel::IntelKernel().
IntelPIT::Result IntelPIT::waitTrigger | ( | ) |
Busy wait for one trigger period.
Definition at line 58 of file IntelPIT.cpp.
References getCounter(), and Timer::Success.
Referenced by IntelAPIC::start().
|
staticprivate |
The IRQ vector for channel 0 is fixed to IRQ0.
Definition at line 48 of file IntelPIT.h.
Referenced by IntelPIT().
|
private |
I/O instance.
Definition at line 126 of file IntelPIT.h.
Referenced by getCounter(), setControl(), and setFrequency().
|
staticprivate |
Oscillator frequency in hertz used by the PIT.
Definition at line 45 of file IntelPIT.h.
Referenced by setFrequency().