Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 18916
b: refs/heads/master
c: cff65c4
h: refs/heads/master
v: v3
  • Loading branch information
Gennady Sharapov authored and Linus Torvalds committed Jan 19, 2006
1 parent a5cb504 commit f007c97
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 95 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4fef0c10fa174b57a10854b8b4b2b90d155706e0
refs/heads/master: cff65c4f0ea6662124bbb7bf3806e5df1c6d735d
12 changes: 11 additions & 1 deletion trunk/arch/um/include/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ extern int os_protect_memory(void *addr, unsigned long len,
int r, int w, int x);
extern int os_unmap_memory(void *addr, int len);
extern void os_flush_stdout(void);
extern unsigned long long os_usecs(void);

/* tt.c
* for tt mode only (will be deleted in future...)
Expand Down Expand Up @@ -245,4 +244,15 @@ extern void setup_machinename(char *machine_out);
extern void setup_hostinfo(void);
extern int setjmp_wrapper(void (*proc)(void *, void *), ...);

/* time.c */
#define BILLION (1000 * 1000 * 1000)

extern void switch_timers(int to_real);
extern void idle_sleep(int secs);
extern void enable_timer(void);
extern void disable_timer(void);
extern void user_time_init(void);
extern void uml_idle_timer(void);
extern unsigned long long os_nsecs(void);

#endif
19 changes: 0 additions & 19 deletions trunk/arch/um/include/time_user.h

This file was deleted.

4 changes: 2 additions & 2 deletions trunk/arch/um/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion trunk/arch/um/kernel/exec_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion trunk/arch/um/kernel/process_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/um/kernel/skas/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/um/kernel/skas/process_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/um/kernel/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
124 changes: 76 additions & 48 deletions trunk/arch/um/kernel/time_kern.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL
*/
Expand All @@ -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"

Expand All @@ -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
Expand All @@ -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;
}

Expand All @@ -88,45 +88,99 @@ void boot_timer_handler(int sig)
{
struct pt_regs regs;

CHOOSE_MODE((void)
CHOOSE_MODE((void)
(UPT_SC(&regs.regs) = (struct sigcontext *) (&sig + 1)),
(void) (regs.regs.skas.is_user = 0));
do_timer(&regs);
}

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;
}

Expand All @@ -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;
Expand All @@ -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:
*/
1 change: 0 additions & 1 deletion trunk/arch/um/kernel/tt/exec_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/um/kernel/tt/process_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/um/os-Linux/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "user_util.h"
#include "kern_util.h"
#include "mem_user.h"
#include "time_user.h"
#include "irq_user.h"
#include "user.h"
#include "init.h"
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/um/os-Linux/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "sysdep/sigcontext.h"
#include "sysdep/signal.h"
#include "sigcontext.h"
#include "time_user.h"
#include "mode.h"
#include "os.h"

void sig_handler(ARCH_SIGHDLR_PARAM)
{
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/um/os-Linux/start_up.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "irq_user.h"
#include "ptrace_user.h"
#include "mem_user.h"
#include "time_user.h"
#include "init.h"
#include "os.h"
#include "uml-config.h"
Expand Down
Loading

0 comments on commit f007c97

Please sign in to comment.