The system timer source code is in the source file
arch/arm/vx115_clk.c, and provides the basic NetBSD system time
reference. The main functionality is as a driver for one of the
hardware timers on the SoC that responds to timer interrupts by calling
appropriate system functions to update the time. The timer source also
provides several other functions for services such as delays.
The driver provides the usual autoconfig match/attach functions to initialize the bus operations structure.
The system clock provides ticks at the rate defined by the
configuration define HZ. The default value for HZ is 100, giving a
system tick period of 10 ms. However, because the Vx115 timer uses a 32
kHz clock as a source, for this platform HZ is defined as 64 to give an
integer value for the hardware timer max count value.
The system clock is started through a call to cpu_initclocks( ) from
within the initclocks( ) function in kern/kern_clocks.c. This starts the process of timer interrupt
- register the timer interrupt handler
- configure the hardware timer to start generating interrupts at the rate HZ
- handler for timer interrupts
- call hardclock( ) so system can update time
- loop until at least the specified number of microseconds has elapsed
- return the time to the nearest microsecond