From 3c1537e84b49bbcc98d3a730cba263faceee4fc6 Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Sat, 11 Mar 2023 07:29:45 +0000 Subject: ioapic: Timer calibrated in 10 mach ticks hz variable is the number of mach ticks in 1 second. We want to know how many lapic ticks in 1 mach tick. Therefore, we set a timer for 10 mach ticks and divide the lapic stopwatch counter value by 10. Message-Id: <20230311072937.450161-1-damien@zamaudio.com> --- i386/i386at/ioapic.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/i386/i386at/ioapic.c b/i386/i386at/ioapic.c index c6da35e1..73fd216a 100644 --- a/i386/i386at/ioapic.c +++ b/i386/i386at/ioapic.c @@ -172,8 +172,8 @@ timer_measure_10x_apic_hz(void) /* Set APIC timer */ lapic->init_count.r = start; - /* Delay for 10 * 1/hz seconds */ - set_timeout(&tmp_timer, hz / 10); + /* Delay for 10 ticks (10 * 1/hz seconds) */ + set_timeout(&tmp_timer, 10); do { cpu_pause(); } while (!done); @@ -195,9 +195,8 @@ calibrate_lapic_timer(void) lapic->divider_config.r = LAPIC_TIMER_DIVIDE_2; lapic->lvt_timer.r = IOAPIC_INT_BASE; - /* Measure number of APIC timer ticks in 10x 1/hz seconds - * but calibrate the timer to expire at rate of hz - * divide by 10 because we waited 10 times longer than we needed. */ + /* Measure number of APIC timer ticks in 10 mach ticks + * divide by 10 because we want to know how many in 1 tick */ if (!calibrated_ticks) { s = splhigh(); spl0(); -- cgit v1.2.3