[haiku-commits] BRANCH xyzzy-github.x86_64 - in src/system: libroot/os/arch/x86_64 boot/platform/bios_ia32

  • From: xyzzy-github.x86_64 <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 9 Jul 2012 10:49:13 +0200 (CEST)

added 1 changeset to branch 'refs/remotes/xyzzy-github/x86_64'
old head: 93cba1da96275eb617fcdc581ec4522e0b107adf
new head: bc3093488f72315d8474d45b3dfe34cdc15ef4d6

----------------------------------------------------------------------------

bc30934: Changes suggested by Ingo: style fix, and a system_time optimization.

                                      [ Alex Smith <alex@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Commit:      bc3093488f72315d8474d45b3dfe34cdc15ef4d6

Author:      Alex Smith <alex@xxxxxxxxxxxxxxxx>
Date:        Mon Jul  9 08:03:11 2012 UTC

----------------------------------------------------------------------------

2 files changed, 11 insertions(+), 6 deletions(-)
src/system/boot/platform/bios_ia32/mmu.cpp         |    2 +-
.../libroot/os/arch/x86_64/system_time_asm.S       |   15 ++++++++++-----

----------------------------------------------------------------------------

diff --git a/src/system/boot/platform/bios_ia32/mmu.cpp 
b/src/system/boot/platform/bios_ia32/mmu.cpp
index 05167e7..4eef5de 100644
--- a/src/system/boot/platform/bios_ia32/mmu.cpp
+++ b/src/system/boot/platform/bios_ia32/mmu.cpp
@@ -522,7 +522,7 @@ mmu_get_virtual_mapping(addr_t virtualAddress, addr_t 
*_physicalAddress)
        if ((tableEntry & (1 << 0)) == 0)
                return false;
 
-       *_physicalAddress = tableEntry & 0xFFFFF000;
+       *_physicalAddress = tableEntry & 0xfffff000;
        return true;
 }
 
diff --git a/src/system/libroot/os/arch/x86_64/system_time_asm.S 
b/src/system/libroot/os/arch/x86_64/system_time_asm.S
index f63bdf3..135b54a 100644
--- a/src/system/libroot/os/arch/x86_64/system_time_asm.S
+++ b/src/system/libroot/os/arch/x86_64/system_time_asm.S
@@ -28,7 +28,10 @@ FUNCTION_END(__x86_setup_system_time)
 
 /* int64 system_time(); */
 FUNCTION(system_time):
+       // (rdtsc * cv_factor) >> 32.
+
        movq    cv_factor, %rcx
+       shl             $32, %rcx
 
        // Load 64-bit TSC into %eax (low), %edx (high).
        rdtsc
@@ -40,17 +43,19 @@ FUNCTION(system_time):
        // Multiply by conversion factor, result in %rax (low), %rdx (high).
        mulq    %rcx
 
-       // Shift the result right by 32 bits.
-       shr             $32, %rax
-       shl             $32, %rdx
-       orq             %rdx, %rax
+       // Conversion factor preshifted by 32, whole result in high.
+       movq    %rdx, %rax
        ret
 FUNCTION_END(system_time)
 
 
 /* int64 system_time_nsecs(); */
 FUNCTION(system_time_nsecs):
-       // Same algorithm as system_time(), just with a different factor.
+       // 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
+       // 32 bits.
+
        movq    cv_factor_nsecs, %rcx
 
        // Load 64-bit TSC into %eax (low), %edx (high).


Other related posts: