#include "user_util.h"
#include "time_user.h"
#include "mode.h"
-#include "os.h"
u64 jiffies_64;
int timer_irq_inited = 0;
static int first_tick;
-static unsigned long long prev_usecs;
+static unsigned long long prev_tsc;
static long long delta; /* Deviation per interval */
-#define MILLION 1000000
+extern unsigned long long host_hz;
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 */
- unsigned long long usecs = os_usecs();
+ tsc = time_stamp();
- delta += usecs - prev_usecs;
- prev_usecs = usecs;
+ delta += tsc - prev_tsc;
+ prev_tsc = tsc;
- /* Protect against the host clock being set backwards */
- if(delta < 0)
- delta = 0;
-
- ticks += (delta * HZ) / MILLION;
- delta -= (ticks * MILLION) / HZ;
+ ticks += (delta * HZ) / host_hz;
+ delta -= (ticks * host_hz) / HZ;
#else
ticks = 1;
#endif
}
else {
- prev_usecs = os_usecs();
+ prev_tsc = time_stamp();
first_tick = 1;
}
{
int i, n;
- n = (loops_per_jiffy * HZ * usecs) / MILLION;
+ n = (loops_per_jiffy * HZ * usecs) / 1000000;
for(i=0;i<n;i++) ;
}
{
int i, n;
- n = (loops_per_jiffy * HZ * usecs) / MILLION;
+ n = (loops_per_jiffy * HZ * usecs) / 1000000;
for(i=0;i<n;i++) ;
}