From 42c13951a7df0d504d425e029fcdfda3ac25cb65 Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Wed, 13 Jan 2010 18:22:41 +0000 Subject: [PATCH] APIC disabled if CPU lacks TSC - we cannot calibrate local APIC timer in such a case - fixes possible uninitialized variable problem during calibration if no TSC --- kernel/arch/i386/apic.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/arch/i386/apic.c b/kernel/arch/i386/apic.c index 7143aa6e3..126010441 100644 --- a/kernel/arch/i386/apic.c +++ b/kernel/arch/i386/apic.c @@ -155,9 +155,7 @@ PRIVATE int calib_clk_handler(irq_hook_t * hook) u64_t tsc; probe_ticks++; - if (cpu_has_tsc) { - read_tsc_64(&tsc); - } + read_tsc_64(&tsc); tcrt = lapic_read(LAPIC_TIMER_CCR); @@ -385,6 +383,13 @@ PUBLIC int lapic_enable(void) if (!lapic_addr) return 0; + cpu_has_tsc = _cpufeature(_CPUF_I386_TSC); + if (!cpu_has_tsc) { + kprintf("CPU lacks timestamp counter, " + "cannot calibrate LAPIC timer\n"); + return 0; + } + if (!lapic_enable_in_msr()) return 0; @@ -439,10 +444,6 @@ PUBLIC int lapic_enable(void) lapic_read (LAPIC_SIVR); *((u32_t *)lapic_eoi_addr) = 0; - - cpu_has_tsc = _cpufeature(_CPUF_I386_TSC); - BOOT_VERBOSE(if (cpu_has_tsc) kprintf("CPU has Timestamp counter\n")); - apic_calibrate_clocks(); BOOT_VERBOSE(kprintf("APIC timer calibrated\n")); -- 2.44.0