From: Sepherosa Ziehau Date: Fri, 1 May 2009 10:18:42 +0000 (+0800) Subject: lapic timer: Reimplement set_apic_timer using lapic_timer_oneshot X-Git-Tag: v2.3.1~32 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/2942ed6320bd57a5713048dc6d231f13936ccb54 lapic timer: Reimplement set_apic_timer using lapic_timer_oneshot --- diff --git a/sys/platform/pc32/apic/mpapic.c b/sys/platform/pc32/apic/mpapic.c index ab8a84e42e..534f85a9a0 100644 --- a/sys/platform/pc32/apic/mpapic.c +++ b/sys/platform/pc32/apic/mpapic.c @@ -753,40 +753,25 @@ selected_apic_ipi(u_int target, int vector, int delivery_mode) * - suggested by rgrimes@gndrsh.aac.dev.com */ -/** XXX FIXME: temp hack till we can determin bus clock */ -#ifndef BUS_CLOCK -#define BUS_CLOCK 66000000 -#define bus_clock() 66000000 -#endif - - /* * Load a 'downcount time' in uSeconds. */ void -set_apic_timer(int value) +set_apic_timer(int us) { - u_long lvtt; - long ticks_per_microsec; + u_int count; /* - * Calculate divisor and count from value: - * - * timeBase == CPU bus clock divisor == [1,2,4,8,16,32,64,128] - * value == time in uS + * When we reach here, lapic timer's frequency + * must have been calculated as well as the + * divisor (lapic.dcr_timer is setup during the + * divisor calculation). */ - lapic.dcr_timer = APIC_TDCR_1; - ticks_per_microsec = bus_clock() / 1000000; - - /* configure timer as one-shot */ - lvtt = lapic.lvt_timer; - lvtt &= ~(APIC_LVTT_VECTOR | APIC_LVTT_DS); - lvtt &= ~(APIC_LVTT_PERIODIC); - lvtt |= APIC_LVTT_MASKED; /* no INT, one-shot */ - lapic.lvt_timer = lvtt; - - /* */ - lapic.icr_timer = value * ticks_per_microsec; + KKASSERT(lapic_timer_freq != 0 && + lapic_timer_divisor_idx >= 0); + + count = ((us * (int64_t)lapic_timer_freq) + 999999) / 1000000; + lapic_timer_oneshot(count); }