PatchworkOS
Loading...
Searching...
No Matches
hpet.h File Reference
#include <kernel/acpi/acpi.h>
#include <sys/proc.h>

Go to the source code of this file.

Data Structures

struct  hpet_t
 High Precision Event Timer structure. More...
 

Macros

#define HPET_CAP_COUNTER_CLK_PERIOD_SHIFT   32
 The bit offset of the clock period in the capabilities register.
 
#define HPET_CONF_ENABLE_CNF_BIT   (1 << 0)
 The bit to set to enable the HPET in the configuration register.
 
#define HPET_CONF_LEG_RT_CNF_BIT   (1 << 1)
 The bit to set to enable legacy replacement mode in the configuration register.
 
#define HPET_ADDRESS_SPACE_MEMORY   0
 If hpet_t::addressSpaceId is equal to this, the address is in system memory space.
 
#define HPET_ADDRESS_SPACE_IO   1
 If hpet_t::addressSpaceId is equal to this, the address is in system I/O space.
 
#define HPET_FEMTOSECONDS_PER_SECOND   1000000000000000ULL
 The number of femtoseconds in one second.
 

Enumerations

enum  hpet_register_t {
  HPET_REG_GENERAL_CAPABILITIES_ID = 0x000 ,
  HPET_REG_GENERAL_CONFIG = 0x010 ,
  HPET_REG_GENERAL_INTERRUPT = 0x020 ,
  HPET_REG_MAIN_COUNTER_VALUE = 0x0F0 ,
  HPET_REG_TIMER0_CONFIG_CAP = 0x100 ,
  HPET_REG_TIMER0_COMPARATOR = 0x108
}
 HPET register offsets. More...
 

Functions

clock_t hpet_nanoseconds_per_tick (void)
 Retrieve the number of nanoseconds per HPET tick.
 
uint64_t hpet_read_counter (void)
 Read the current value of the HPET main counter.
 
void hpet_reset_counter (void)
 Reset the HPET main counter to 0 and enable the HPET.
 
void hpet_write (uint64_t reg, uint64_t value)
 Write a value to an HPET register.
 
uint64_t hpet_read (uint64_t reg)
 Read a value from an HPET register.
 
void hpet_wait (clock_t nanoseconds)
 Wait for a specified number of nanoseconds using the HPET.