From 542b2a8123c6a0c336d8404f5cf12fe32df9ab69 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 24 Mar 2005 21:36:15 +0000 Subject: Merge from i386: - Add a i8254_pending variable to save some indirections in clkintr(). - Don't bother setting up an IRQ0 handler if we are using the lapic timer. --- sys/pc98/cbus/clock.c | 23 ++++++++++++++++------- sys/pc98/cbus/pcrtc.c | 23 ++++++++++++++++------- 2 files changed, 32 insertions(+), 14 deletions(-) (limited to 'sys/pc98/cbus') diff --git a/sys/pc98/cbus/clock.c b/sys/pc98/cbus/clock.c index 60936a2..484e8df 100644 --- a/sys/pc98/cbus/clock.c +++ b/sys/pc98/cbus/clock.c @@ -114,11 +114,12 @@ struct mtx clock_lock; static int beeping = 0; static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; static u_int hardclock_max_count; +static struct intsrc *i8254_intsrc; static u_int32_t i8254_lastcount; static u_int32_t i8254_offset; +static int (*i8254_pending)(struct intsrc *); static int i8254_ticked; static int using_lapic_timer; -static struct intsrc *i8254_intsrc; /* Values for timerX_state: */ #define RELEASED 0 @@ -757,10 +758,19 @@ cpu_initclocks() #ifdef DEV_APIC using_lapic_timer = lapic_setup_clock(); #endif - /* Finish initializing 8254 timer 0. */ - intr_add_handler("clk", 0, (driver_intr_t *)clkintr, NULL, - INTR_TYPE_CLK | INTR_FAST, NULL); - i8254_intsrc = intr_lookup_source(0); + /* + * If we aren't using the local APIC timer to drive the kernel + * clocks, setup the interrupt handler for the 8254 timer 0 so + * that it can drive hardclock(). + */ + if (!using_lapic_timer) { + intr_add_handler("clk", 0, (driver_intr_t *)clkintr, NULL, + INTR_TYPE_CLK | INTR_FAST, NULL); + i8254_intsrc = intr_lookup_source(0); + if (i8254_intsrc != NULL) + i8254_pending = + i8254_intsrc->is_pic->pic_source_pending; + } init_TSC_tc(); } @@ -816,8 +826,7 @@ i8254_get_timecount(struct timecounter *tc) if (count < i8254_lastcount || (!i8254_ticked && (clkintr_pending || ((count < 20 || (!(eflags & PSL_I) && count < timer0_max_count / 2u)) && - i8254_intsrc != NULL && - i8254_intsrc->is_pic->pic_source_pending(i8254_intsrc))))) { + i8254_pending != NULL && i8254_pending(i8254_intsrc))))) { i8254_ticked = 1; i8254_offset += timer0_max_count; } diff --git a/sys/pc98/cbus/pcrtc.c b/sys/pc98/cbus/pcrtc.c index 60936a2..484e8df 100644 --- a/sys/pc98/cbus/pcrtc.c +++ b/sys/pc98/cbus/pcrtc.c @@ -114,11 +114,12 @@ struct mtx clock_lock; static int beeping = 0; static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; static u_int hardclock_max_count; +static struct intsrc *i8254_intsrc; static u_int32_t i8254_lastcount; static u_int32_t i8254_offset; +static int (*i8254_pending)(struct intsrc *); static int i8254_ticked; static int using_lapic_timer; -static struct intsrc *i8254_intsrc; /* Values for timerX_state: */ #define RELEASED 0 @@ -757,10 +758,19 @@ cpu_initclocks() #ifdef DEV_APIC using_lapic_timer = lapic_setup_clock(); #endif - /* Finish initializing 8254 timer 0. */ - intr_add_handler("clk", 0, (driver_intr_t *)clkintr, NULL, - INTR_TYPE_CLK | INTR_FAST, NULL); - i8254_intsrc = intr_lookup_source(0); + /* + * If we aren't using the local APIC timer to drive the kernel + * clocks, setup the interrupt handler for the 8254 timer 0 so + * that it can drive hardclock(). + */ + if (!using_lapic_timer) { + intr_add_handler("clk", 0, (driver_intr_t *)clkintr, NULL, + INTR_TYPE_CLK | INTR_FAST, NULL); + i8254_intsrc = intr_lookup_source(0); + if (i8254_intsrc != NULL) + i8254_pending = + i8254_intsrc->is_pic->pic_source_pending; + } init_TSC_tc(); } @@ -816,8 +826,7 @@ i8254_get_timecount(struct timecounter *tc) if (count < i8254_lastcount || (!i8254_ticked && (clkintr_pending || ((count < 20 || (!(eflags & PSL_I) && count < timer0_max_count / 2u)) && - i8254_intsrc != NULL && - i8254_intsrc->is_pic->pic_source_pending(i8254_intsrc))))) { + i8254_pending != NULL && i8254_pending(i8254_intsrc))))) { i8254_ticked = 1; i8254_offset += timer0_max_count; } -- cgit v1.1