Skip to main content

Module timer

Module timer 

Source
Expand description

Timer Implementation

Provides timer functionality for the kernel:

  • PIT (Programmable Interval Timer) for legacy fallback
  • APIC Timer for modern systems (calibrated via PIT channel 2)

Constantsยง

NS_PER_TICK
Nanoseconds per timer tick (derived from TIMER_HZ).
PIT_CHANNEL0_PORT ๐Ÿ”’
Programmable Interval Timer (PIT) constants
PIT_COMMAND_PORT ๐Ÿ”’
PIT_FREQUENCY ๐Ÿ”’
TIMER_HZ
Kernel timer frequency in Hz.

Staticsยง

APIC_TICKS_PER_10MS ๐Ÿ”’
Cached APIC ticks per 10ms from calibration (used by APs)
APIC_TIMER_ACTIVE ๐Ÿ”’
Whether the APIC timer is currently active

Functionsยง

apic_ticks_per_10ms
Return the cached calibration value (ticks per 10ms).
calibrate_apic_timer
Calibrate the APIC timer using PIT channel 2 as a reference.
init_pit
Initialize the Programmable Interval Timer (PIT)
is_apic_timer_active
Check if the APIC timer is active
start_apic_timer
Start the APIC timer in periodic mode.
start_apic_timer_cached
Start the APIC timer using the cached calibration value.
stop_pit
Stop PIT channel 0 to prevent phantom interrupts.