From: Tomas Hruby Date: Thu, 16 Sep 2010 07:18:47 +0000 (+0000) Subject: apic_timer_x X-Git-Tag: v3.2.0~836 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=72cc01ff48cf4ce12746a72e06ba30fb45d44543;p=minix.git apic_timer_x - set the apic_timer_x factor variable to slowdown apic timer in virtual machines --- diff --git a/kernel/arch/i386/apic.c b/kernel/arch/i386/apic.c index 53bad419c..c6f2155fa 100644 --- a/kernel/arch/i386/apic.c +++ b/kernel/arch/i386/apic.c @@ -506,7 +506,7 @@ PUBLIC void lapic_set_timer_one_shot(const u32_t usec) u32_t ticks_per_us; const u8_t cpu = cpuid; - ticks_per_us = lapic_bus_freq[cpu] / 1000000; + ticks_per_us = (lapic_bus_freq[cpu] / 1000000) * config_apic_timer_x; lvtt = APIC_TDCR_1; lapic_write(LAPIC_TIMER_DCR, lvtt); @@ -525,7 +525,7 @@ PUBLIC void lapic_set_timer_periodic(const unsigned freq) u32_t lapic_ticks_per_clock_tick; const u8_t cpu = cpuid; - lapic_ticks_per_clock_tick = lapic_bus_freq[cpu] / freq; + lapic_ticks_per_clock_tick = (lapic_bus_freq[cpu] / freq) * config_apic_timer_x; lvtt = APIC_TDCR_1; lapic_write(LAPIC_TIMER_DCR, lvtt); diff --git a/kernel/glo.h b/kernel/glo.h index fcbd73a94..1c9eb5137 100644 --- a/kernel/glo.h +++ b/kernel/glo.h @@ -54,6 +54,7 @@ EXTERN int verboseflags; #ifdef CONFIG_APIC EXTERN int config_no_apic; /* optionaly turn off apic */ +EXTERN int config_apic_timer_x; /* apic timer slowdown factor */ #endif EXTERN u64_t cpu_hz[CONFIG_MAX_CPUS]; diff --git a/kernel/start.c b/kernel/start.c index 7c6a5cf3c..a39ddb8ef 100644 --- a/kernel/start.c +++ b/kernel/start.c @@ -93,6 +93,11 @@ PUBLIC void cstart( config_no_apic = atoi(value); else config_no_apic = 1; + value = env_get("apic_timer_x"); + if(value) + config_apic_timer_x = atoi(value); + else + config_apic_timer_x = 1; #endif #ifdef CONFIG_WATCHDOG