|
Module timers |
APIC timer Module for Linux
Documentation Timers of the APIC timer module. Author: Vincent Oberle Purpose This document describes how timers are managed in the APIC timer module in order to get the less latency possible. It also gives some information on how the kernel was patched to redirect the APIC timer IRQ. Content The timers linked list
The timers linked list The timers are managed in the form of a double-linked list
of timer struct, similar to the generic The declaration of the timer
struct apic_timer_list {
struct apic_timer_list *next, *prev;
unsigned long long expires;
unsigned long data;
void (*function)(unsigned long long, unsigned long);
};
where
expires is the value of the TSC register
when the timer expires,
data is a value that will be passed to the timer function,
function is the function to execute;
Its parameters are the expires value and data.
The linked list is ordered according to the The list itself, without any APIC stuff, is managed by 3 three functions:
The APIC timer patch With the Pentium processor family, Intel introduced the Advanced Programmable Interrupt Controller (APIC) to replace the old PIC. This APIC is refered as the local APIC to distinguish it from the I/O APIC, which is an external controller to manage interrupts on SMP systems. To summarize, there is no I/O APIC on UP boards but since P54C, all CPUs contain an on-chip local APIC. Nevertheless, the local APIC is generally disabled on P5 chips and cannot be enabled by software. Only P6 chips (ie starting with Pentium Pro) allow to enable the local APIC by software means. The disable pin only exists on P5. But the kernel must be patched to use APIC interrupts. If you want to use the interrupts generated by the APIC, like the timer interrupt in the module, you need to patch the kernel to redirect the corresponding Interrupt Service Routine (ISR) to your own ISR. It is currently not possible to use a method like request_irq with APIC interrupts. I may try to implement something for the kernel, so that it would be possible to use the interrupts generated by the APIC like other interrupts (the keyboard IRQ for example). To keep the patch as simple as possible, we preserve the original
APIC timer ISR, A pointer on a supplementary ISR is added: void (*apic_timer_up_handler)(unsigned long);and a function to modify this pointer: void set_apic_timer_up_handler (void (*f)(unsigned long)) In the There are a few other minor modifications to export the
How the timers are issued The timers are issued by the
The APIC timer is programmed on the first timer of the list.
The Both functions also contain some code to try to correct the
latency. It allows to have the microsecond precision.
From the user side... The user of the module only sees the
Moreover, when creating a new static inline void init_apic_timer (struct apic_timer_list *timer) |