]>
Commit | Line | Data |
---|---|---|
d2312e33 SS |
1 | /* |
2 | * Copyright (C) 2001 Andrea Arcangeli <andrea@suse.de> SuSE | |
3 | * Copyright 2003 Andi Kleen, SuSE Labs. | |
4 | * | |
5 | * Modified for x86 32 bit architecture by | |
6 | * Stefani Seibold <stefani@seibold.net> | |
7c03156f | 7 | * sponsored by Rohde & Schwarz GmbH & Co. KG Munich/Germany |
d2312e33 SS |
8 | * |
9 | * Thanks to hpa@transmeta.com for some useful hint. | |
10 | * Special thanks to Ingo Molnar for his early experience with | |
11 | * a different vsyscall implementation for Linux/IA32 and for the name. | |
12 | * | |
13 | */ | |
14 | ||
15 | #include <linux/timekeeper_internal.h> | |
16 | #include <asm/vgtod.h> | |
7c03156f | 17 | #include <asm/vvar.h> |
d2312e33 SS |
18 | |
19 | DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data); | |
20 | ||
21 | void update_vsyscall_tz(void) | |
22 | { | |
7c03156f SS |
23 | vsyscall_gtod_data.tz_minuteswest = sys_tz.tz_minuteswest; |
24 | vsyscall_gtod_data.tz_dsttime = sys_tz.tz_dsttime; | |
d2312e33 SS |
25 | } |
26 | ||
27 | void update_vsyscall(struct timekeeper *tk) | |
28 | { | |
29 | struct vsyscall_gtod_data *vdata = &vsyscall_gtod_data; | |
30 | ||
7c03156f | 31 | gtod_write_begin(vdata); |
d2312e33 SS |
32 | |
33 | /* copy vsyscall data */ | |
7c03156f | 34 | vdata->vclock_mode = tk->clock->archdata.vclock_mode; |
4a0e6377 | 35 | vdata->cycle_last = tk->cycle_last; |
7c03156f SS |
36 | vdata->mask = tk->clock->mask; |
37 | vdata->mult = tk->mult; | |
38 | vdata->shift = tk->shift; | |
d2312e33 SS |
39 | |
40 | vdata->wall_time_sec = tk->xtime_sec; | |
41 | vdata->wall_time_snsec = tk->xtime_nsec; | |
42 | ||
43 | vdata->monotonic_time_sec = tk->xtime_sec | |
44 | + tk->wall_to_monotonic.tv_sec; | |
45 | vdata->monotonic_time_snsec = tk->xtime_nsec | |
28b92e09 | 46 | + ((u64)tk->wall_to_monotonic.tv_nsec |
d2312e33 SS |
47 | << tk->shift); |
48 | while (vdata->monotonic_time_snsec >= | |
49 | (((u64)NSEC_PER_SEC) << tk->shift)) { | |
50 | vdata->monotonic_time_snsec -= | |
51 | ((u64)NSEC_PER_SEC) << tk->shift; | |
52 | vdata->monotonic_time_sec++; | |
53 | } | |
54 | ||
7c03156f SS |
55 | vdata->wall_time_coarse_sec = tk->xtime_sec; |
56 | vdata->wall_time_coarse_nsec = (long)(tk->xtime_nsec >> tk->shift); | |
d2312e33 | 57 | |
7c03156f SS |
58 | vdata->monotonic_time_coarse_sec = |
59 | vdata->wall_time_coarse_sec + tk->wall_to_monotonic.tv_sec; | |
60 | vdata->monotonic_time_coarse_nsec = | |
61 | vdata->wall_time_coarse_nsec + tk->wall_to_monotonic.tv_nsec; | |
d2312e33 | 62 | |
7c03156f SS |
63 | while (vdata->monotonic_time_coarse_nsec >= NSEC_PER_SEC) { |
64 | vdata->monotonic_time_coarse_nsec -= NSEC_PER_SEC; | |
65 | vdata->monotonic_time_coarse_sec++; | |
66 | } | |
67 | ||
68 | gtod_write_end(vdata); | |
d2312e33 | 69 | } |