Aufgabe 5: Zeitscheiben
Abstraction of the HPET existing in "modern" computers (since ~2005) More...
Classes | |
struct | ConfigurationRegister.__unnamed38__ |
Typedefs | |
typedef uint64_t | InterruptStatusRegister |
Global state register for interrupts. More... | |
Enumerations | |
enum | RegisterOffset : uint16_t { CAPABILITIES_AND_ID = 0x000 , CONFIGURATION = 0x010 , INTERRUPT_STATUS = 0x020 , MAIN_COUNTER = 0x0f0 } |
Register Offsets. More... | |
enum | CounterSize { SIZE_32BIT = 0x0 , SIZE_64BIT = 0x1 } |
Size of the global counter and the comparators. | |
Functions | |
bool | init () |
Initializes the HPET system from ACPI Table. More... | |
void | delay (uint64_t usecs) |
Delays the caller's execution by approx. More... | |
bool | isEnabled () |
Checks whether the HPET system is enabled. More... | |
void | reset () |
Reset the global counter to zero. More... | |
uint64_t | get () |
void | enable () |
Activate the HPET system. More... | |
void | disable () |
Deactivate the HPET system. More... | |
size_t | countComparators () |
Retrieve the number of HPET comparators. More... | |
Comparator * | getComparator (size_t n) |
Returns a pointer to the n th timer comparator. More... | |
Constants | |
uintptr_t | base_address = 0 |
Detailed Description
Abstraction of the HPET existing in "modern" computers (since ~2005)
Today's systems contain, in addition to the old Programmable Interval Timer (PIT), several additional timers, the "High Precision Event Timers" (HPET). Those timers, developed by Intel and Microsoft, are intended as replacement for both the PIT and the CMOS Real Time Clock in the long run.
Unlike the PIT, the HPETs are in a well-define state at system boot, are configured via Memory Mapped IO, have a significantly higher precision, and support up to 256 independent comparators (depending on the architecture).
The HPET timers are implemented using a single counter and several comparators. The counter increments at a fixed frequency that is independent of the CPUs current frequency (which might change due to CPU power management). The only cause for reading a value smaller than previous values is a intermittent counter overflow.
After system boot, the HPET is in the following state:
- The global counter is set to 0 and stopped.
- The comparators' value registers are set to their maximum value.
- All interrupts are disabled:
- The global activation bit is 0.
- Every comparators' interrupt-enable bit is set to 0
- The legacy mode is disabled
Class Documentation
struct HPET::ConfigurationRegister.__unnamed38__ |
Typedef Documentation
typedef uint64_t HPET::InterruptStatusRegister |
Global state register for interrupts.
This register is only required for level-triggered interrupts – it provides information about the comparator that issued an interrupt. To acknowledge the interrupt, the software is required to write 1
to the corresponding bit (writes of 0
have no effect).
For edge-triggered interrupts, the corresponding bit is always set to 0
and should be ignored.
Enumeration Type Documentation
enum HPET::RegisterOffset : uint16_t |
Function Documentation
bool HPET::init | ( | ) |
Initializes the HPET system from ACPI Table.
- Returns
true
on success,false
on error
- Optional:
- Implement function
void HPET::delay | ( | uint64_t | usecs | ) |
Delays the caller's execution by approx.
Actively waits by polling the main counter until at least the given micro seconds have passed
- Parameters
-
usecs time to wait in micro seconds.
- Optional:
- Implement function
bool HPET::isEnabled | ( | ) |
Checks whether the HPET system is enabled.
Checks whether the HPET system is activated globally, i.e. the global counter is running and the comparators could send interrupts (if configured to do so).
- Returns
true
if enabled,false
if disabled
- Optional:
- Implement function
void HPET::reset | ( | ) |
Reset the global counter to zero.
- Optional:
- Implement function
void HPET::enable | ( | ) |
Activate the HPET system.
Activate the HPET system globally by enabling the global counter and, thereby, enabling all (previously configured) interrupts.
- Optional:
- Implement function
void HPET::disable | ( | ) |
Deactivate the HPET system.
Deactivates the HPET system globally by disabling the global counter and, thereby, disabling all interrupts.
- Optional:
- Implement function
size_t HPET::countComparators | ( | ) |
Retrieve the number of HPET comparators.
- Returns
- number of comparators.
Comparator * HPET::getComparator | ( | size_t | n | ) |
Returns a pointer to the n
th timer comparator.
- Returns
- A pointer to the timer comperator, or
nullptr
if invalid timer.