|
PatchworkOS
966e257
A non-POSIX operating system.
|
#include <kernel/cpu/cpu.h>#include <kernel/log/log.h>#include <kernel/log/panic.h>#include <kernel/mem/vmm.h>#include <kernel/module/module.h>#include <kernel/sched/sched.h>#include <kernel/sched/clock.h>#include <kernel/sched/thread.h>#include <kernel/sched/wait.h>#include <kernel/sync/seqlock.h>#include <kernel/utils/utils.h>#include <modules/acpi/tables.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 | |
| static void | hpet_write (hpet_register_t reg, uint64_t value) |
| Write to an HPET register. | |
| static uint64_t | hpet_read (hpet_register_t reg) |
| Read from an HPET register. | |
| static clock_t | hpet_ns_per_tick (void) |
| Get the HPET clock period in nanoseconds. | |
| static clock_t | hpet_read_ns_counter (void) |
| Safely read the HPET counter value in nanoseconds. | |
| static void | hpet_reset_counter (void) |
| Reset the HPET main counter to zero and enable the HPET. | |
| static void | hpet_overflow_thread (void *arg) |
| Thread function that periodically accumulates the HPET counter to prevent overflow. | |
| static uint64_t | hpet_init (void) |
| Initialize the HPET. | |
| static void | hpet_deinit (void) |
| Deinitialize the HPET. | |
| uint64_t | _module_procedure (const module_event_t *event) |
| MODULE_INFO ("HPET Driver", "Kai Norberg", "A High Precision Event Timer driver", OS_VERSION, "MIT", "PNP0103") | |
Variables | |
| static hpet_t * | hpet |
| Pointer to the HPET ACPI table. | |
| static uintptr_t | address |
| Mapped virtual address of the HPET registers. | |
| static uint64_t | period |
| Main counter tick period in femtoseconds (10^-15 s). | |
| static atomic_uint64_t | counter = ATOMIC_VAR_INIT(0) |
| Accumulated nanosecond counter, used to avoid overflows. | |
| static seqlock_t | counterLock = SEQLOCK_CREATE() |
| Seqlock for the accumulated counter. | |
| static tid_t | overflowThreadTid = 0 |
| Thread ID of the overflow thread. | |
| static wait_queue_t | overflowQueue = WAIT_QUEUE_CREATE(overflowQueue) |
| Wait queue for the overflow thread. | |
| static atomic_bool | overflowShouldStop = ATOMIC_VAR_INIT(false) |
| Flag to signal the overflow thread to stop. | |
| static clock_source_t | source |
| Structure to describe the HPET to the sys time subsystem. | |
| uint64_t _module_procedure | ( | const module_event_t * | event | ) |
| MODULE_INFO | ( | "HPET Driver" | , |
| "Kai Norberg" | , | ||
| "A High Precision Event Timer driver" | , | ||
| OS_VERSION | , | ||
| "MIT" | , | ||
| "PNP0103" | |||
| ) |