From owner-p4-projects@FreeBSD.ORG Fri Jul 1 18:42:54 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0E6F416A420; Fri, 1 Jul 2005 18:42:54 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C669A16A41C for ; Fri, 1 Jul 2005 18:42:53 +0000 (GMT) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A80FD43D48 for ; Fri, 1 Jul 2005 18:42:53 +0000 (GMT) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j61IgrgI007354 for ; Fri, 1 Jul 2005 18:42:53 GMT (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j61IgrXj007351 for perforce@freebsd.org; Fri, 1 Jul 2005 18:42:53 GMT (envelope-from peter@freebsd.org) Date: Fri, 1 Jul 2005 18:42:53 GMT Message-Id: <200507011842.j61IgrXj007351@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Cc: Subject: PERFORCE change 79399 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jul 2005 18:42:54 -0000 http://perforce.freebsd.org/chv.cgi?CH=79399 Change 79399 by peter@peter_overcee on 2005/07/01 18:41:52 integ -b i386_hammer (notably the i8254 simple timecounter) Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/dump_machdep.c#23 integrate .. //depot/projects/hammer/sys/amd64/amd64/identcpu.c#43 integrate .. //depot/projects/hammer/sys/amd64/amd64/initcpu.c#13 integrate .. //depot/projects/hammer/sys/amd64/amd64/local_apic.c#55 integrate .. //depot/projects/hammer/sys/amd64/amd64/machdep.c#137 integrate .. //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#101 integrate .. //depot/projects/hammer/sys/amd64/amd64/trap.c#69 integrate .. //depot/projects/hammer/sys/amd64/include/md_var.h#33 integrate .. //depot/projects/hammer/sys/amd64/include/pmap.h#56 integrate .. //depot/projects/hammer/sys/amd64/isa/clock.c#42 integrate Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/dump_machdep.c#23 (text+ko) ==== ==== //depot/projects/hammer/sys/amd64/amd64/identcpu.c#43 (text+ko) ==== ==== //depot/projects/hammer/sys/amd64/amd64/initcpu.c#13 (text+ko) ==== ==== //depot/projects/hammer/sys/amd64/amd64/local_apic.c#55 (text+ko) ==== ==== //depot/projects/hammer/sys/amd64/amd64/machdep.c#137 (text+ko) ==== ==== //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#101 (text+ko) ==== ==== //depot/projects/hammer/sys/amd64/amd64/trap.c#69 (text+ko) ==== ==== //depot/projects/hammer/sys/amd64/include/md_var.h#33 (text+ko) ==== ==== //depot/projects/hammer/sys/amd64/include/pmap.h#56 (text+ko) ==== ==== //depot/projects/hammer/sys/amd64/isa/clock.c#42 (text+ko) ==== @@ -127,6 +127,7 @@ static u_char timer2_state; static unsigned i8254_get_timecount(struct timecounter *tc); +static unsigned i8254_simple_get_timecount(struct timecounter *tc); static void set_timer_freq(u_int freq, int intr_freq); static struct timecounter i8254_timecounter = { @@ -518,10 +519,15 @@ { int new_timer0_max_count; + i8254_timecounter.tc_frequency = freq; mtx_lock_spin(&clock_lock); timer_freq = freq; new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq); - if (new_timer0_max_count != timer0_max_count) { + if (using_lapic_timer) { + outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); + outb(TIMER_CNTR0, 0); + outb(TIMER_CNTR0, 0); + } else if (new_timer0_max_count != timer0_max_count) { timer0_max_count = new_timer0_max_count; outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); outb(TIMER_CNTR0, timer0_max_count & 0xff); @@ -575,7 +581,6 @@ } set_timer_freq(timer_freq, hz); - i8254_timecounter.tc_frequency = timer_freq; tc_init(&i8254_timecounter); init_TSC(); @@ -728,15 +733,21 @@ /* * 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(). + * that it can drive hardclock(). Otherwise, change the 8254 + * timecounter to user a simpler algorithm. */ - if (!using_lapic_timer) { + if (!using_lapic_timer || 1) { 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; + } else { + i8254_timecounter.tc_get_timecount = + i8254_simple_get_timecount; + i8254_timecounter.tc_counter_mask = 0xffff; + set_timer_freq(timer_freq, hz); } /* Initialize RTC. */ @@ -804,10 +815,8 @@ */ freq = timer_freq; error = sysctl_handle_int(oidp, &freq, sizeof(freq), req); - if (error == 0 && req->newptr != NULL) { + if (error == 0 && req->newptr != NULL) set_timer_freq(freq, hz); - i8254_timecounter.tc_frequency = freq; - } return (error); } @@ -815,6 +824,24 @@ 0, sizeof(u_int), sysctl_machdep_i8254_freq, "IU", ""); static unsigned +i8254_simple_get_timecount(struct timecounter *tc) +{ + u_int count; + u_int high, low; + + mtx_lock_spin(&clock_lock); + + /* Select timer0 and latch counter value. */ + outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH); + + low = inb(TIMER_CNTR0); + high = inb(TIMER_CNTR0); + count = 0xffff - ((high << 8) | low); + mtx_unlock_spin(&clock_lock); + return (count); +} + +static unsigned i8254_get_timecount(struct timecounter *tc) { u_int count;