From 890b96d5c5511f9a48b43997e9b83074376b5a71 Mon Sep 17 00:00:00 2001 From: beveloper Date: Wed, 20 Aug 2003 02:15:23 +0000 Subject: [PATCH] removed system_time from atomic.S file and added it in a separate one. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4332 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/os/arch/x86/system_time.S | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/kernel/libroot/os/arch/x86/system_time.S diff --git a/src/kernel/libroot/os/arch/x86/system_time.S b/src/kernel/libroot/os/arch/x86/system_time.S new file mode 100644 index 0000000000..7dd25fde4e --- /dev/null +++ b/src/kernel/libroot/os/arch/x86/system_time.S @@ -0,0 +1,38 @@ +/* +** Copyright 2001, Travis Geiselbrecht. All rights reserved. +** Distributed under the terms of the NewOS License. +*/ + +#define FUNCTION(x) .global x; .type x,@function; x + +.text + +/* saves the conversion factor needed for system_time */ +cv_factor: + .word 0 + +FUNCTION(setup_system_time): + movl 4(%esp),%eax + movl %eax,cv_factor + ret + +/* long long system_time(); */ +FUNCTION(system_time): + /* load 64-bit factor into %eax (low), %edx (high) */ + rdtsc /* time in %edx,%eax */ + + pushl %ebx + pushl %ecx + movl cv_factor, %ebx + movl %edx, %ecx /* save high half */ + mull %ebx /* truncate %eax, but keep %edx */ + movl %ecx, %eax + movl %edx, %ecx /* save high half of low */ + mull %ebx /*, %eax*/ + /* now compute [%edx, %eax] + [%ecx], propagating carry */ + subl %ebx, %ebx /* need zero to propagate carry */ + addl %ecx, %eax + adc %ebx, %edx + popl %ecx + popl %ebx + ret