summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdike <jdike>2004-04-07 20:46:19 +0000
committerjdike <jdike>2004-04-07 20:46:19 +0000
commitf5e1a8d5d376fc002d52a239bbdaf9d9fef5b774 (patch)
tree6125c0dbc5f434e4bb1f21abe8d7c07a59d7376e
parent1c8873684fa3c42cb21a6a04dcda083dbbac18b6 (diff)
downloaduml-history-f5e1a8d5d376fc002d52a239bbdaf9d9fef5b774.tar.gz
Time calculations are now done with gettimeofday rather than the tsc.
-rw-r--r--arch/um/kernel/time.c46
-rw-r--r--arch/um/kernel/time_kern.c22
-rw-r--r--arch/um/sys-i386/Makefile2
-rw-r--r--arch/um/sys-i386/time.c24
4 files changed, 21 insertions, 73 deletions
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index c740ef7..21372e0 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -47,6 +47,15 @@ void enable_timer(void)
errno);
}
+void disable_timer(void)
+{
+ struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
+ if((setitimer(ITIMER_VIRTUAL, &disable, NULL) < 0) ||
+ (setitimer(ITIMER_REAL, &disable, NULL) < 0))
+ printk("disnable_timer - setitimer failed, errno = %d\n",
+ errno);
+}
+
void switch_timers(int to_real)
{
struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
@@ -79,42 +88,6 @@ void idle_timer(void)
set_interval(ITIMER_REAL);
}
-static unsigned long long get_host_hz(void)
-{
- char mhzline[16], *end;
- unsigned long long mhz;
- int ret, mult, rest, len;
-
- ret = cpu_feature("cpu MHz", mhzline,
- sizeof(mhzline) / sizeof(mhzline[0]));
- if(!ret)
- panic ("Could not get host MHZ");
-
- mhz = strtoul(mhzline, &end, 10);
-
- /* This business is to parse a floating point number without using
- * floating types.
- */
-
- rest = 0;
- mult = 0;
- if(*end == '.'){
- end++;
- len = strlen(end);
- if(len < 6)
- mult = 6 - len;
- else if(len > 6)
- end[6] = '\0';
- rest = strtoul(end, NULL, 10);
- while(mult-- > 0)
- rest *= 10;
- }
-
- return(1000000 * mhz + rest);
-}
-
-unsigned long long host_hz = 0;
-
void time_init(void)
{
/* XXX This is to fill xtime with something real - otherwise by the
@@ -124,7 +97,6 @@ void time_init(void)
*/
timer();
- host_hz = get_host_hz();
if(signal(SIGVTALRM, boot_timer_handler) == SIG_ERR)
panic("Couldn't set SIGVTALRM handler");
set_interval(ITIMER_VIRTUAL);
diff --git a/arch/um/kernel/time_kern.c b/arch/um/kernel/time_kern.c
index 3df7611..94380dd 100644
--- a/arch/um/kernel/time_kern.c
+++ b/arch/um/kernel/time_kern.c
@@ -18,6 +18,7 @@
#include "user_util.h"
#include "time_user.h"
#include "mode.h"
+#include "os.h"
extern rwlock_t xtime_lock;
@@ -36,10 +37,10 @@ int timer_irq_inited = 0;
int __attribute__ ((__section__ (".unprotected"))) missed_ticks[NR_CPUS];
static int first_tick;
-static unsigned long long prev_tsc;
+static unsigned long long prev_usecs;
static long long delta; /* Deviation per interval */
-extern unsigned long long host_hz;
+#define MILLION 1000000
void timer_irq(union uml_pt_regs *regs)
{
@@ -54,21 +55,20 @@ void timer_irq(union uml_pt_regs *regs)
if(first_tick){
#if defined(CONFIG_UML_REAL_TIME_CLOCK)
- unsigned long long tsc;
/* We've had 1 tick */
- tsc = time_stamp();
+ unsigned long long usecs = os_usecs();
- delta += tsc - prev_tsc;
- prev_tsc = tsc;
+ delta += usecs - prev_usecs;
+ prev_usecs = usecs;
- ticks += (delta * HZ) / host_hz;
- delta -= (ticks * host_hz) / HZ;
+ ticks += (delta * HZ) / MILLION;
+ delta -= (ticks * MILLION) / HZ;
#else
ticks = 1;
#endif
}
else {
- prev_tsc = time_stamp();
+ prev_usecs = os_usecs();
first_tick = 1;
}
@@ -142,7 +142,7 @@ void __udelay(um_udelay_t usecs)
{
int i, n;
- n = (loops_per_jiffy * HZ * usecs) / 1000000;
+ n = (loops_per_jiffy * HZ * usecs) / MILLION;
for(i=0;i<n;i++) ;
}
@@ -150,7 +150,7 @@ void __const_udelay(um_udelay_t usecs)
{
int i, n;
- n = (loops_per_jiffy * HZ * usecs) / 1000000;
+ n = (loops_per_jiffy * HZ * usecs) / MILLION;
for(i=0;i<n;i++) ;
}
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile
index 2ddff6d..0b23fef 100644
--- a/arch/um/sys-i386/Makefile
+++ b/arch/um/sys-i386/Makefile
@@ -6,7 +6,7 @@
O_TARGET = built-in.o
obj-y = bugs.o checksum.o extable.o fault.o ksyms.o ldt.o ptrace.o \
- ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o time.o
+ ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o
export-objs = ksyms.o
USER_OBJS = bugs.o ptrace_user.o sigcontext.o fault.o
diff --git a/arch/um/sys-i386/time.c b/arch/um/sys-i386/time.c
deleted file mode 100644
index a6a5ba7..0000000
--- a/arch/um/sys-i386/time.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * sys-i386/time.c
- * Created 25.9.2002 Sapan Bhatia
- *
- */
-
-unsigned long long time_stamp(void)
-{
- unsigned long low, high;
-
- asm("rdtsc" : "=a" (low), "=d" (high));
- return((((unsigned long long) high) << 32) + low);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */