Friedrich-Alexander-Universität Erlangen-Nürnberg  /   Technische Fakultät  /   Department Informatik

Class abstracting a single HPET comparator. More...

#include <machine/hpet.h>

Classes

union  ConfigAndCapabilitiesRegister
 Access Helper for comparators configuration register. More...
 
struct  ConfigAndCapabilitiesRegister.__unnamed__
 

Public Member Functions

 Comparator (const Comparator &)=delete
 
 Comparator (Comparator &&)=delete
 
Comparatoroperator= (const Comparator &)=delete
 
Comparatoroperator= (Comparator &&)=delete
 
void enable ()
 Activates interrupts (for the current comparator).
 
void disable ()
 Deactivates interrupts (for the current comparator).
 
bool isEnabled () const
 Checks whether interrupts are enabled for the current comparator.
 
bool supportsIOAPICSlot (unsigned slot) const
 Can this comparator trigger interrupts at an specific I/O-APIC Slot? More...
 
bool supportsPeriodicInterrupts () const
 Is this comparator capable of sending peridic interrupts? More...
 
bool isActive () const
 Check if this comparator triggered an interrupt. More...
 
void setHandled ()
 Mark this comparator interrupt as handled. More...
 
bool set (uint64_t usecs, uint8_t slot, bool periodic)
 Sets the comperator. More...
 

Protected Types

enum  TriggerMode {
  EDGE = 0,
  LEVEL = 1
}
 Trigger mode for the interrupts generated by a comparator. More...
 
enum  ComparatorMode {
  ONE_SHOT = 0,
  PERIODIC = 1
}
 Comparator mode a comparator is running in. More...
 

Protected Attributes

volatile uint64_t config_register
 Comparator Configuration and Capability Register. More...
 
volatile uint64_t value_register
 Comparator Value Register. More...
 
volatile uint64_t fsb_register
 Comparator FSB Interrupt Route Register. More...
 

Detailed Description

Class abstracting a single HPET comparator.

Abstracts the access to comparators. This class does not have any constructor, as it is used to encapsulate hardware structures already residing in memory.

The Registers for HPET comparator n are memory mapped at HPET base address plus offset

  • 0x100 + 0x20 * n for Configuration and Capability Register
  • 0x108 + 0x20 * n for Comparator Value Register and
  • 0x110 + 0x20 * n for FSB Interrupt Route Register

Use HPET::getComparator to obtain an instance for a particular HPET comparator.

See also
IA-PC HPET - 2.3.8 Timer N Configuration and Capabilities Register

Class Documentation

◆ HPET::Comparator::ConfigAndCapabilitiesRegister.__unnamed__

struct HPET::Comparator::ConfigAndCapabilitiesRegister.__unnamed__
Class Members
uint64_t __pad0__: 1
TriggerMode trigger_mode: 1 Generate edge or level triggered interrupts.
uint64_t interrupt_status: 1 Enable (1) or disable (0) interrupts.
ComparatorMode comparator_mode: 1 periodic or one shot mode
uint64_t periodic_capable: 1 Is timer capable of periodic mode (read-only)
CounterSize counter_size: 1 32- or 64bit size (read-only)
uint64_t set_value: 1 if set to 1, the accumulator can be set in software
uint64_t __pad1__: 1
uint64_t small_mode: 1 if set to 1 while supporting 64bit size, the timer runs in 32-bit mode
uint64_t ioapic_slot: 5 I/O-APIC slot (must be set in mask supported_ioapic_slots)
uint64_t fsb_interrupt_enabled: 1 if set to 1, the timer will use FSB interrupt mapping
uint64_t fsb_interrupt_delivery: 1 if set to 1, the timer supports FSB interrupt mapping (read-only)
uint64_t __pad2__: 16
uint64_t supported_ioapic_slots: 32 bit mask containing the supported I/O APIC slots (read-only)

Member Enumeration Documentation

◆ TriggerMode

Trigger mode for the interrupts generated by a comparator.

Enumerator
EDGE 

edge triggered

LEVEL 

level triggered

◆ ComparatorMode

Comparator mode a comparator is running in.

Enumerator
ONE_SHOT 

single shot (non-periodical)

PERIODIC 

periodical

Member Function Documentation

◆ supportsIOAPICSlot()

bool HPET::Comparator::supportsIOAPICSlot ( unsigned  slot) const
inline

Can this comparator trigger interrupts at an specific I/O-APIC Slot?

The standard mapping (not legacy or FSB!) is able to route interrupts to some I/O APIC slots. The possible slots can be determined by the corresponding bit in supported_ioapic_slots of the ConfigAndCapabilitiesRegister

Note
Currently Qemu/KVM only supports one slot (2) for comparators, which is shared as well.
See also
IA-PC HPET - 2.4.2.2 Mapping Option #2: Standard Option
Parameters
slotI/O-APIC slot to check
Returns
true if comparator is capable to route interrupts to the given slot

◆ supportsPeriodicInterrupts()

bool HPET::Comparator::supportsPeriodicInterrupts ( ) const
inline

Is this comparator capable of sending peridic interrupts?

See also
IA-PC HPET - 2.4.3.2 Mapping Option #2: Standard Option
Returns
true if comparator is capable of periodic interrupts

◆ isActive()

bool HPET::Comparator::isActive ( ) const

Check if this comparator triggered an interrupt.

Reads the corresponding bit of the General Interrupt Status Register if this comparator triggered an interrupt

Note
Only works for comparators operating in LEVEL triggered mode!
See also
IA-PC HPET - 2.3.6 General Interrupt Status Register
Returns
true if interrupt was triggered

◆ setHandled()

void HPET::Comparator::setHandled ( )

Mark this comparator interrupt as handled.

Sets the corresponding bit of the General Interrupt Status Register to mark the interrupt of this comparator as handled.

Note
Only works for comparators operating in LEVEL triggered mode!
See also
IA-PC HPET - 2.3.6 General Interrupt Status Register

◆ set()

bool HPET::Comparator::set ( uint64_t  usecs,
uint8_t  slot,
bool  periodic 
)

Sets the comperator.

Calculates the required ticks, sets the mode and I/O APIC slot for this comparator.

Since the I/O APIC slot might be shared with another device, the comparator should be configured to use level triggered interrupts (in standard interrupt mapping). The handler has to use isActive to verify that this HPET comparator was the source and mark it as handled.

Note
For periodic comperators, you need to reset the global counter to zero (using HPET::reset) to guarantee that the first interrupt will be fired (and therefore the comparator turns operational).
The global counter should be disabled while configuring the comparator (or you might lose interrupts)
See also
IA-PC HPET - 2.3.9.2.2 Periodic Mode
Parameters
usecstime to wait in micro seconds.
slotI/O APIC slot to be triggered on expiry of waiting time
periodicIf set, the interrupt will be issued periodically
Returns
true iff comperator was set up successful, false otherwise.

Member Data Documentation

◆ config_register

volatile uint64_t HPET::Comparator::config_register
protected

Comparator Configuration and Capability Register.

In addition to global configuration and value registers, every HPET comparator comes with its own configuration register containing config used locally by the respective timer.

Note
Only 32- or 64-bit access allowed (use local temporary copy for modifications)
See also
IA-PC HPET - 2.3.8 Timer N Configuration and Capabilities Register

◆ value_register

volatile uint64_t HPET::Comparator::value_register
protected

Comparator Value Register.

The comparator value register yields a different behavior depending on the timer mode:

For single-shot timers, the interrupt is issued (if enabled) once, as soon as the global timer is equal to the configured value. When using 32-bit timers, an additional interrupt is issued when the global counter overflows.

For periodic timers, the mode of operation is as follows:

  1. A first interrupt will be triggered when the global counter is equal to the value stored in this register.
  2. From there on, the HPET will automatically increase the value by the initial period. Reading from this registers will return the point in time the next interrupt will be issued.
Note
Only 32- or 64-bit access allowed
See also
IA-PC HPET - 2.3.10 Timer N FSB Interrupt Route Register

◆ fsb_register

volatile uint64_t HPET::Comparator::fsb_register
protected

Comparator FSB Interrupt Route Register.

Note
Currently, this register is not used by StuBS; it's definition is only here for the sake of completeness.
See also
IA-PC HPET - 2.3.9.1 Register Definition and Usage Model

The documentation for this class was generated from the following files:
  • machine/hpet.h
  • machine/hpet.cc