Don't need to shift the factor in system_time(), just store the already shifted value.

This commit is contained in:
Alex Smith
2012-07-09 12:25:49 +01:00
parent 5e9bb17da7
commit 8c5e747190
2 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -824,7 +824,8 @@ arch_cpu_init(kernel_args* args)
// The x86_64 system_time() implementation uses 64-bit multiplication and
// therefore shifting is not necessary for low frequencies (it's also not
// too likely that there'll be any x86_64 CPUs clocked under 1GHz).
__x86_setup_system_time(conversionFactor, conversionFactorNsecs);
__x86_setup_system_time((uint64)conversionFactor << 32,
conversionFactorNsecs);
#else
if (conversionFactorNsecs >> 32 != 0) {
// the TSC frequency is < 1 GHz, which forces us to shift the factor
@@ -29,9 +29,9 @@ FUNCTION_END(__x86_setup_system_time)
/* int64 system_time(); */
FUNCTION(system_time):
// (rdtsc * cv_factor) >> 32.
// Factor is pre-shifted left by 32 bits.
movq cv_factor, %rcx
shl $32, %rcx
// Load 64-bit TSC into %eax (low), %edx (high).
rdtsc
@@ -43,7 +43,7 @@ FUNCTION(system_time):
// Multiply by conversion factor, result in %rax (low), %rdx (high).
mulq %rcx
// Conversion factor preshifted by 32, whole result in high.
// Due to pre-shifting of the factor the whole result in high.
movq %rdx, %rax
ret
FUNCTION_END(system_time)
@@ -53,7 +53,7 @@ FUNCTION_END(system_time)
FUNCTION(system_time_nsecs):
// Same algorithm as system_time(), but with a different factor.
// (rdtsc * cv_factor_nsecs) >> 32.
// Cannot pre-shift the factor here, otherwise we may lose the upper
// Factor has not been pre-shifted here, otherwise we may lose the upper
// 32 bits.
movq cv_factor_nsecs, %rcx