diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/h8300/kernel/time.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/h8300/kernel/time.c')
-rw-r--r-- | arch/h8300/kernel/time.c | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/arch/h8300/kernel/time.c b/arch/h8300/kernel/time.c new file mode 100644 index 000000000000..8a600218334d --- /dev/null +++ b/arch/h8300/kernel/time.c | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * linux/arch/h8300/kernel/time.c | ||
3 | * | ||
4 | * Yoshinori Sato <ysato@users.sourceforge.jp> | ||
5 | * | ||
6 | * Copied/hacked from: | ||
7 | * | ||
8 | * linux/arch/m68k/kernel/time.c | ||
9 | * | ||
10 | * Copyright (C) 1991, 1992, 1995 Linus Torvalds | ||
11 | * | ||
12 | * This file contains the m68k-specific time handling details. | ||
13 | * Most of the stuff is located in the machine specific files. | ||
14 | * | ||
15 | * 1997-09-10 Updated NTP code according to technical memorandum Jan '96 | ||
16 | * "A Kernel Model for Precision Timekeeping" by Dave Mills | ||
17 | */ | ||
18 | |||
19 | #include <linux/config.h> /* CONFIG_HEARTBEAT */ | ||
20 | #include <linux/errno.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/param.h> | ||
25 | #include <linux/string.h> | ||
26 | #include <linux/mm.h> | ||
27 | #include <linux/timex.h> | ||
28 | #include <linux/profile.h> | ||
29 | |||
30 | #include <asm/io.h> | ||
31 | #include <asm/target_time.h> | ||
32 | |||
33 | #define TICK_SIZE (tick_nsec / 1000) | ||
34 | |||
35 | u64 jiffies_64; | ||
36 | |||
37 | EXPORT_SYMBOL(jiffies_64); | ||
38 | |||
39 | /* | ||
40 | * timer_interrupt() needs to keep up the real-time clock, | ||
41 | * as well as call the "do_timer()" routine every clocktick | ||
42 | */ | ||
43 | static void timer_interrupt(int irq, void *dummy, struct pt_regs * regs) | ||
44 | { | ||
45 | /* may need to kick the hardware timer */ | ||
46 | platform_timer_eoi(); | ||
47 | |||
48 | do_timer(regs); | ||
49 | #ifndef CONFIG_SMP | ||
50 | update_process_times(user_mode(regs)); | ||
51 | #endif | ||
52 | profile_tick(CPU_PROFILING, regs); | ||
53 | } | ||
54 | |||
55 | void time_init(void) | ||
56 | { | ||
57 | unsigned int year, mon, day, hour, min, sec; | ||
58 | |||
59 | /* FIX by dqg : Set to zero for platforms that don't have tod */ | ||
60 | /* without this time is undefined and can overflow time_t, causing */ | ||
61 | /* very stange errors */ | ||
62 | year = 1980; | ||
63 | mon = day = 1; | ||
64 | hour = min = sec = 0; | ||
65 | platform_gettod (&year, &mon, &day, &hour, &min, &sec); | ||
66 | |||
67 | if ((year += 1900) < 1970) | ||
68 | year += 100; | ||
69 | xtime.tv_sec = mktime(year, mon, day, hour, min, sec); | ||
70 | xtime.tv_nsec = 0; | ||
71 | |||
72 | platform_timer_setup(timer_interrupt); | ||
73 | } | ||
74 | |||
75 | /* | ||
76 | * This version of gettimeofday has near microsecond resolution. | ||
77 | */ | ||
78 | void do_gettimeofday(struct timeval *tv) | ||
79 | { | ||
80 | unsigned long flags; | ||
81 | unsigned long usec, sec; | ||
82 | |||
83 | read_lock_irqsave(&xtime_lock, flags); | ||
84 | usec = 0; | ||
85 | sec = xtime.tv_sec; | ||
86 | usec += (xtime.tv_nsec / 1000); | ||
87 | read_unlock_irqrestore(&xtime_lock, flags); | ||
88 | |||
89 | while (usec >= 1000000) { | ||
90 | usec -= 1000000; | ||
91 | sec++; | ||
92 | } | ||
93 | |||
94 | tv->tv_sec = sec; | ||
95 | tv->tv_usec = usec; | ||
96 | } | ||
97 | |||
98 | EXPORT_SYMBOL(do_gettimeofday); | ||
99 | |||
100 | int do_settimeofday(struct timespec *tv) | ||
101 | { | ||
102 | if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC) | ||
103 | return -EINVAL; | ||
104 | |||
105 | write_lock_irq(&xtime_lock); | ||
106 | /* This is revolting. We need to set the xtime.tv_usec | ||
107 | * correctly. However, the value in this location is | ||
108 | * is value at the last tick. | ||
109 | * Discover what correction gettimeofday | ||
110 | * would have done, and then undo it! | ||
111 | */ | ||
112 | while (tv->tv_nsec < 0) { | ||
113 | tv->tv_nsec += NSEC_PER_SEC; | ||
114 | tv->tv_sec--; | ||
115 | } | ||
116 | |||
117 | xtime.tv_sec = tv->tv_sec; | ||
118 | xtime.tv_nsec = tv->tv_nsec; | ||
119 | time_adjust = 0; /* stop active adjtime() */ | ||
120 | time_status |= STA_UNSYNC; | ||
121 | time_maxerror = NTP_PHASE_LIMIT; | ||
122 | time_esterror = NTP_PHASE_LIMIT; | ||
123 | write_sequnlock_irq(&xtime_lock); | ||
124 | clock_was_set(); | ||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | EXPORT_SYMBOL(do_settimeofday); | ||
129 | |||
130 | unsigned long long sched_clock(void) | ||
131 | { | ||
132 | return (unsigned long long)jiffies * (1000000000 / HZ); | ||
133 | |||
134 | } | ||