summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2023-03-11 07:29:45 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-03-11 10:17:34 +0100
commit3c1537e84b49bbcc98d3a730cba263faceee4fc6 (patch)
tree25420b77927e307f76ac3b8af934116efd152374
parent8e5e86fc13732b60d2e4d14152d92db1f1ae73f9 (diff)
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>
-rw-r--r--i386/i386at/ioapic.c9
1 files 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();