FreeNOS
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
IntelPIT Class Reference

Intel 8254 Programmable Interrupt Timer (PIT). More...

#include <IntelPIT.h>

Inheritance diagram for IntelPIT:
Timer

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...
 

Detailed Description

Intel 8254 Programmable Interrupt Timer (PIT).

Definition at line 40 of file IntelPIT.h.

Member Enumeration Documentation

◆ ControlFlags

enum IntelPIT::ControlFlags
private

Control Register Flags.

Enumerator
Channel0 
LatchedRead 
AccessLowHigh 
SquareWave 
RateGenerator 

Definition at line 62 of file IntelPIT.h.

◆ Registers

enum IntelPIT::Registers
private

Hardware registers.

Enumerator
Control 
Channel0Data 

Definition at line 53 of file IntelPIT.h.

Constructor & Destructor Documentation

◆ IntelPIT()

IntelPIT::IntelPIT ( )

Constructor.

Definition at line 20 of file IntelPIT.cpp.

References InterruptNumber, and Timer::m_int.

Member Function Documentation

◆ getCounter()

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.

Returns
Current timer counter.

Definition at line 26 of file IntelPIT.cpp.

References Channel0, Channel0Data, IntelIO::inb(), LatchedRead, m_io, and setControl().

Referenced by waitTrigger().

◆ setControl()

IntelPIT::Result IntelPIT::setControl ( IntelPIT::ControlFlags  flags)
private

Set Control register.

Parameters
flagsNew flags to set in the Control register.
Returns
Result code.

Definition at line 76 of file IntelPIT.cpp.

References Control, flags, m_io, IntelIO::outb(), and Timer::Success.

Referenced by getCounter(), and setFrequency().

◆ setFrequency()

IntelPIT::Result IntelPIT::setFrequency ( Size  hertz)
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.

Parameters
hertzNumber of interrupt triggers per second (in hertz)
Returns
Result code.

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().

◆ waitTrigger()

IntelPIT::Result IntelPIT::waitTrigger ( )

Busy wait for one trigger period.

Returns
Result code.

Definition at line 58 of file IntelPIT.cpp.

References getCounter(), and Timer::Success.

Referenced by IntelAPIC::start().

Field Documentation

◆ InterruptNumber

const uint IntelPIT::InterruptNumber = 0
staticprivate

The IRQ vector for channel 0 is fixed to IRQ0.

Definition at line 48 of file IntelPIT.h.

Referenced by IntelPIT().

◆ m_io

IntelIO IntelPIT::m_io
private

I/O instance.

Definition at line 126 of file IntelPIT.h.

Referenced by getCounter(), setControl(), and setFrequency().

◆ OscillatorFreq

const uint IntelPIT::OscillatorFreq = 1193182
staticprivate

Oscillator frequency in hertz used by the PIT.

Definition at line 45 of file IntelPIT.h.

Referenced by setFrequency().


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