From: Tomas Hruby Date: Wed, 13 Jan 2010 18:22:41 +0000 (+0000) Subject: APIC disabled if CPU lacks TSC X-Git-Tag: v3.1.6~87 X-Git-Url: http://zhaoyanbai.com/repos/man.dnssec-verify.html?a=commitdiff_plain;h=42c13951a7df0d504d425e029fcdfda3ac25cb65;p=minix.git 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 --- 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"));