Skip to contentSkip to conversation

linux_2-4-20-pre3_timer-changes_A1

RFC PATCH New john stultz 1 participant 1 message Aug 20, 2002

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 linux_2-4-20-pre3_timer-changes_A1

Alan, all
Here is the backport of my 2.5 timer changes/cleanups. Basically it
splits the TSC and PIT timer code into their own files, then creates an abstract interface (struct timer_ops) to use them. This should aid in adding new timers (cyclone, ACPI,etc) as well as just help cleaning up the time code. I have further cleanups planned, but want to keep the changes understandable for now. Compiles and boots, but handle with care.

Let me know what you think.

thanks
-john

arch/i386/kernel/Makefile +4 -2
diff -Nru a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
@@ -14,11 +14,13 @@
 
 O_TARGET := kernel.o
 
-export-objs     := mca.o mtrr.o msr.o cpuid.o microcode.o i386_ksyms.o time.o
+export-objs     := mca.o mtrr.o msr.o cpuid.o microcode.o i386_ksyms.o \
+				time.o timer_pit.o
 
 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
+		pci-dma.o i386_ksyms.o i387.o bluesmoke.o dmi_scan.o \
+		timer.o timer_pit.o timer_tsc.o
 
 
 ifdef CONFIG_PCI
arch/i386/kernel/time.c +7 -323

387 lines not on this page · raw message

arch/i386/kernel/timer.c new file +28 -0
diff -Nru a/arch/i386/kernel/timer.c b/arch/i386/kernel/timer.c
@@ -0,0 +1,28 @@
+#include <linux/kernel.h>
+
+#include <asm/timer.h>
+
+/*list of externed timers*/
+extern struct timer_opts timer_pit;
+extern struct timer_opts timer_tsc;
+
+/*list of timers, ordered by preference*/
+struct timer_opts* timers[] = {
+	&timer_tsc,
+	&timer_pit
+};
+
+#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;
+	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 +164 -0

164 lines not on this page · raw message

arch/i386/kernel/timer_tsc.c new file +209 -0

209 lines not on this page · raw message

include/asm-i386/timer.h new file +13 -0
diff -Nru a/include/asm-i386/timer.h b/include/asm-i386/timer.h
@@ -0,0 +1,13 @@
+
+#ifndef _ASMi386_TIMER_H
+#define _ASMi386_TIMER_H
+
+struct timer_opts{
+	int (*init)(void);
+	void (*mark_offset)(void);
+	unsigned long (*get_offset)(void);
+};
+
+#define TICK_SIZE tick
+struct timer_opts* select_timer(void);
+#endif