linux-2.5.38_timer-change_A3
PATCH 1/1 linux-2.5.38_timer-change_A3
Dave, Linus, all,
Here is a resync of the timer-change patch w/ 2.5.38. No major changes,
but a few cleanups. Again, this code breaks up the hardware specific time.c code into separate timer_pit.c and timer_tsc.c and creates an abstract interface (struct timer_opts) to be able to use either without caring/knowing about the lower level implementation. This should make it cleaner and easier to add new time sources to the kernel (such as the cyclone-timer, HPET, ACPI pm timer, etc).
I avoided any other cleanups to make the change as transparent and easy to follow as possible.
I may have mis-merged/dropped some of the recent #ifdef CONFIG_X86_TSC additions, but some of that didn't make sense to me, and I must have missed the dialog. Do we really want to have kernels forced to an either-or situation w/ regard to the TSC? Where kernels compiled for i386 won't use the TSC and kernels compiled for i686 must use it?
Any/all comments/nasty-grams welcome/accepted here/everywhere.
or something.
-john
arch/i386/kernel/Makefile +1 -1
@@ -9,7 +9,7 @@ obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o vm86.o \ ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_i386.o \ pci-dma.o i386_ksyms.o i387.o bluesmoke.o dmi_scan.o \ - bootflag.o + bootflag.o timer.o timer_tsc.o obj-y += cpu/ obj-$(CONFIG_X86_BIOS_REBOOT) += reboot.o
arch/i386/kernel/time.c +9 -291
372 lines not on this page · raw message
arch/i386/kernel/timer.c new file +32 -0
@@ -0,0 +1,32 @@ +#include <linux/kernel.h> +#include <asm/timer.h> + +/* list of externed timers */ +#ifndef CONFIG_X86_TSC +extern struct timer_opts timer_pit; +#endif +extern struct timer_opts timer_tsc; + +/* list of timers, ordered by preference */ +struct timer_opts * timers[] = { + &timer_tsc +#ifndef CONFIG_X86_TSC + ,&timer_pit +#endif +}; + +#define NR_TIMERS (sizeof(timers)/sizeof(timers[0])) + +/* iterates through the list of timers, returning the first +* one that initializes successfully. +*/ +struct timer_opts *select_timer (void ) +{ +int i; +/* find most preferred working timer */ +for (i=0 ; i <NR_TIMERS ; i++) +if (timers[i]->init ()) +return timers[i]; +panic ("select_timer: Cannot find a suitable timer\n" ); +return 0 ; +}
arch/i386/kernel/timer_pit.c new file +168 -0
168 lines not on this page · raw message
arch/i386/kernel/timer_tsc.c new file +215 -0
215 lines not on this page · raw message
include/asm-i386/timer.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef _ASMi386_TIMER_H +#define _ASMi386_TIMER_H + +#include <asm/timer.h> + +struct timer_opts { +/* probes and initializes timer. returns 1 on sucess, 0 on failure */ +int (*init)(void ); +/* called by the timer interrupt */ +void (*mark_offset)(void ); +/* called by gettimeofday. returns # ms since the last timer interrupt */ +unsigned long (*get_offset)(void ); +}; + +#define TICK_SIZE (tick_nsec / 1000) +struct timer_opts *select_timer (void ); +#endif