[PATCH] uml: move libc-dependent time code
The serial UML OS-abstraction layer patch (um/kernel dir). This moves all systemcalls from time.c file under os-Linux dir and joins time.c and tine_kernel.c files Signed-off-by: Gennady Sharapov <Gennady.V.Sharapov@intel.com> Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
4fef0c10fa
commit
cff65c4f0e
@ -9,7 +9,7 @@ clean-files :=
|
||||
obj-y = config.o exec_kern.o exitcode.o \
|
||||
init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \
|
||||
process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \
|
||||
signal_kern.o smp.o syscall_kern.o sysrq.o time.o \
|
||||
signal_kern.o smp.o syscall_kern.o sysrq.o \
|
||||
time_kern.o tlb.o trap_kern.o uaccess.o um_arch.o umid.o
|
||||
|
||||
obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
|
||||
@ -23,7 +23,7 @@ obj-$(CONFIG_MODE_SKAS) += skas/
|
||||
|
||||
user-objs-$(CONFIG_TTY_LOG) += tty_log.o
|
||||
|
||||
USER_OBJS := $(user-objs-y) config.o time.o tty_log.o
|
||||
USER_OBJS := $(user-objs-y) config.o tty_log.o
|
||||
|
||||
include arch/um/scripts/Makefile.rules
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "irq_user.h"
|
||||
#include "tlb.h"
|
||||
#include "os.h"
|
||||
#include "time_user.h"
|
||||
#include "choose-mode.h"
|
||||
#include "mode_kern.h"
|
||||
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include "init.h"
|
||||
#include "irq_user.h"
|
||||
#include "mem_user.h"
|
||||
#include "time_user.h"
|
||||
#include "tlb.h"
|
||||
#include "frame_kern.h"
|
||||
#include "sigcontext.h"
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <asm/types.h>
|
||||
#include "user.h"
|
||||
#include "ptrace_user.h"
|
||||
#include "time_user.h"
|
||||
#include "sysdep/ptrace.h"
|
||||
#include "user_util.h"
|
||||
#include "kern_util.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "asm/uaccess.h"
|
||||
#include "asm/atomic.h"
|
||||
#include "kern_util.h"
|
||||
#include "time_user.h"
|
||||
#include "skas.h"
|
||||
#include "os.h"
|
||||
#include "user_util.h"
|
||||
|
@ -25,12 +25,12 @@ int record_syscall_start(int syscall)
|
||||
syscall_record[index].syscall = syscall;
|
||||
syscall_record[index].pid = current_pid();
|
||||
syscall_record[index].result = 0xdeadbeef;
|
||||
syscall_record[index].start = os_usecs();
|
||||
syscall_record[index].start = os_nsecs();
|
||||
return(index);
|
||||
}
|
||||
|
||||
void record_syscall_end(int index, long result)
|
||||
{
|
||||
syscall_record[index].result = result;
|
||||
syscall_record[index].end = os_usecs();
|
||||
syscall_record[index].end = os_nsecs();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
||||
* Licensed under the GPL
|
||||
*/
|
||||
@ -13,12 +13,12 @@
|
||||
#include "linux/interrupt.h"
|
||||
#include "linux/init.h"
|
||||
#include "linux/delay.h"
|
||||
#include "linux/hrtimer.h"
|
||||
#include "asm/irq.h"
|
||||
#include "asm/param.h"
|
||||
#include "asm/current.h"
|
||||
#include "kern_util.h"
|
||||
#include "user_util.h"
|
||||
#include "time_user.h"
|
||||
#include "mode.h"
|
||||
#include "os.h"
|
||||
|
||||
@ -39,7 +39,7 @@ unsigned long long sched_clock(void)
|
||||
int timer_irq_inited = 0;
|
||||
|
||||
static int first_tick;
|
||||
static unsigned long long prev_usecs;
|
||||
static unsigned long long prev_nsecs;
|
||||
#ifdef CONFIG_UML_REAL_TIME_CLOCK
|
||||
static long long delta; /* Deviation per interval */
|
||||
#endif
|
||||
@ -58,23 +58,23 @@ void timer_irq(union uml_pt_regs *regs)
|
||||
if(first_tick){
|
||||
#ifdef CONFIG_UML_REAL_TIME_CLOCK
|
||||
/* We've had 1 tick */
|
||||
unsigned long long usecs = os_usecs();
|
||||
unsigned long long nsecs = os_nsecs();
|
||||
|
||||
delta += usecs - prev_usecs;
|
||||
prev_usecs = usecs;
|
||||
delta += nsecs - prev_nsecs;
|
||||
prev_nsecs = nsecs;
|
||||
|
||||
/* Protect against the host clock being set backwards */
|
||||
if(delta < 0)
|
||||
delta = 0;
|
||||
|
||||
ticks += (delta * HZ) / MILLION;
|
||||
delta -= (ticks * MILLION) / HZ;
|
||||
ticks += (delta * HZ) / BILLION;
|
||||
delta -= (ticks * BILLION) / HZ;
|
||||
#else
|
||||
ticks = 1;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
prev_usecs = os_usecs();
|
||||
prev_nsecs = os_nsecs();
|
||||
first_tick = 1;
|
||||
}
|
||||
|
||||
@ -88,45 +88,99 @@ void boot_timer_handler(int sig)
|
||||
{
|
||||
struct pt_regs regs;
|
||||
|
||||
CHOOSE_MODE((void)
|
||||
CHOOSE_MODE((void)
|
||||
(UPT_SC(®s.regs) = (struct sigcontext *) (&sig + 1)),
|
||||
(void) (regs.regs.skas.is_user = 0));
|
||||
do_timer(®s);
|
||||
}
|
||||
|
||||
static DEFINE_SPINLOCK(timer_spinlock);
|
||||
|
||||
static unsigned long long local_offset = 0;
|
||||
|
||||
static inline unsigned long long get_time(void)
|
||||
{
|
||||
unsigned long long nsecs;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&timer_spinlock, flags);
|
||||
nsecs = os_nsecs();
|
||||
nsecs += local_offset;
|
||||
spin_unlock_irqrestore(&timer_spinlock, flags);
|
||||
|
||||
return nsecs;
|
||||
}
|
||||
|
||||
irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs)
|
||||
{
|
||||
unsigned long long nsecs;
|
||||
unsigned long flags;
|
||||
|
||||
do_timer(regs);
|
||||
|
||||
write_seqlock_irqsave(&xtime_lock, flags);
|
||||
timer();
|
||||
nsecs = get_time() + local_offset;
|
||||
xtime.tv_sec = nsecs / NSEC_PER_SEC;
|
||||
xtime.tv_nsec = nsecs - xtime.tv_sec * NSEC_PER_SEC;
|
||||
write_sequnlock_irqrestore(&xtime_lock, flags);
|
||||
|
||||
return(IRQ_HANDLED);
|
||||
}
|
||||
|
||||
long um_time(int __user *tloc)
|
||||
{
|
||||
struct timeval now;
|
||||
long ret = get_time() / NSEC_PER_SEC;
|
||||
|
||||
do_gettimeofday(&now);
|
||||
if (tloc) {
|
||||
if (put_user(now.tv_sec, tloc))
|
||||
now.tv_sec = -EFAULT;
|
||||
}
|
||||
return now.tv_sec;
|
||||
if((tloc != NULL) && put_user(ret, tloc))
|
||||
return -EFAULT;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void do_gettimeofday(struct timeval *tv)
|
||||
{
|
||||
unsigned long long nsecs = get_time();
|
||||
|
||||
tv->tv_sec = nsecs / NSEC_PER_SEC;
|
||||
/* Careful about calculations here - this was originally done as
|
||||
* (nsecs - tv->tv_sec * NSEC_PER_SEC) / NSEC_PER_USEC
|
||||
* which gave bogus (> 1000000) values. Dunno why, suspect gcc
|
||||
* (4.0.0) miscompiled it, or there's a subtle 64/32-bit conversion
|
||||
* problem that I missed.
|
||||
*/
|
||||
nsecs -= tv->tv_sec * NSEC_PER_SEC;
|
||||
tv->tv_usec = (unsigned long) nsecs / NSEC_PER_USEC;
|
||||
}
|
||||
|
||||
static inline void set_time(unsigned long long nsecs)
|
||||
{
|
||||
unsigned long long now;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&timer_spinlock, flags);
|
||||
now = os_nsecs();
|
||||
local_offset = nsecs - now;
|
||||
spin_unlock_irqrestore(&timer_spinlock, flags);
|
||||
|
||||
clock_was_set();
|
||||
}
|
||||
|
||||
long um_stime(int __user *tptr)
|
||||
{
|
||||
int value;
|
||||
struct timespec new;
|
||||
|
||||
if (get_user(value, tptr))
|
||||
return -EFAULT;
|
||||
new.tv_sec = value;
|
||||
new.tv_nsec = 0;
|
||||
do_settimeofday(&new);
|
||||
|
||||
set_time((unsigned long long) value * NSEC_PER_SEC);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_settimeofday(struct timespec *tv)
|
||||
{
|
||||
set_time((unsigned long long) tv->tv_sec * NSEC_PER_SEC + tv->tv_nsec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -142,21 +196,6 @@ void timer_handler(int sig, union uml_pt_regs *regs)
|
||||
timer_irq(regs);
|
||||
}
|
||||
|
||||
static DEFINE_SPINLOCK(timer_spinlock);
|
||||
|
||||
unsigned long time_lock(void)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&timer_spinlock, flags);
|
||||
return(flags);
|
||||
}
|
||||
|
||||
void time_unlock(unsigned long flags)
|
||||
{
|
||||
spin_unlock_irqrestore(&timer_spinlock, flags);
|
||||
}
|
||||
|
||||
int __init timer_init(void)
|
||||
{
|
||||
int err;
|
||||
@ -171,14 +210,3 @@ int __init timer_init(void)
|
||||
}
|
||||
|
||||
__initcall(timer_init);
|
||||
|
||||
/*
|
||||
* 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:
|
||||
*/
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "user_util.h"
|
||||
#include "kern_util.h"
|
||||
#include "irq_user.h"
|
||||
#include "time_user.h"
|
||||
#include "mem_user.h"
|
||||
#include "os.h"
|
||||
#include "tlb.h"
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "os.h"
|
||||
#include "kern.h"
|
||||
#include "sigcontext.h"
|
||||
#include "time_user.h"
|
||||
#include "mem_user.h"
|
||||
#include "tlb.h"
|
||||
#include "mode.h"
|
||||
|
Reference in New Issue
Block a user