PatchworkOS
Loading...
Searching...
No Matches
hpet.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/acpi/acpi.h>
4
5#include <sys/proc.h>
6
32
36#define HPET_CAP_COUNTER_CLK_PERIOD_SHIFT 32
37
41#define HPET_CONF_ENABLE_CNF_BIT (1 << 0)
42
46#define HPET_CONF_LEG_RT_CNF_BIT (1 << 1)
47
51#define HPET_ADDRESS_SPACE_MEMORY 0
52
56#define HPET_ADDRESS_SPACE_IO 1
57
61#define HPET_FEMTOSECONDS_PER_SECOND 1000000000000000ULL
62
85
94
103
109void hpet_reset_counter(void);
110
117void hpet_write(uint64_t reg, uint64_t value);
118
126
135void hpet_wait(clock_t nanoseconds);
136
#define PACKED
GCC packed attribute.
Definition defs.h:32
void hpet_write(uint64_t reg, uint64_t value)
Write a value to an HPET register.
Definition hpet.c:86
hpet_register_t
HPET register offsets.
Definition hpet.h:24
void hpet_wait(clock_t nanoseconds)
Wait for a specified number of nanoseconds using the HPET.
Definition hpet.c:104
clock_t hpet_nanoseconds_per_tick(void)
Retrieve the number of nanoseconds per HPET tick.
Definition hpet.c:57
void hpet_reset_counter(void)
Reset the HPET main counter to 0 and enable the HPET.
Definition hpet.c:75
uint64_t hpet_read(uint64_t reg)
Read a value from an HPET register.
Definition hpet.c:95
uint64_t hpet_read_counter(void)
Read the current value of the HPET main counter.
Definition hpet.c:66
@ HPET_REG_GENERAL_CONFIG
Definition hpet.h:26
@ HPET_REG_GENERAL_CAPABILITIES_ID
Definition hpet.h:25
@ HPET_REG_MAIN_COUNTER_VALUE
Definition hpet.h:28
@ HPET_REG_GENERAL_INTERRUPT
Definition hpet.h:27
@ HPET_REG_TIMER0_COMPARATOR
Definition hpet.h:30
@ HPET_REG_TIMER0_CONFIG_CAP
Definition hpet.h:29
__UINT64_TYPE__ clock_t
A nanosecond time.
Definition clock_t.h:13
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
__UINT8_TYPE__ uint8_t
Definition stdint.h:11
__UINT16_TYPE__ uint16_t
Definition stdint.h:13
High Precision Event Timer structure.
Definition hpet.h:68
uint8_t hardwareRevId
Definition hpet.h:70
uint8_t legacyReplacementCapable
Definition hpet.h:74
uint8_t reserved1
Definition hpet.h:73
uint16_t pciVendorId
Definition hpet.h:75
uint8_t registerBitWidth
Definition hpet.h:77
uint64_t address
Definition hpet.h:80
uint8_t hpetNumber
Definition hpet.h:81
uint8_t addressSpaceId
Definition hpet.h:76
sdt_header_t header
Definition hpet.h:69
uint8_t counterIs64Bit
Definition hpet.h:72
uint8_t pageProtection
Definition hpet.h:83
uint16_t minimumTick
Definition hpet.h:82
uint8_t registerBitOffset
Definition hpet.h:78
uint8_t comparatorCount
Definition hpet.h:71
uint8_t reserved2
Definition hpet.h:79
System Description Table Header.
Definition acpi.h:90