aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-ppc64/time.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-ppc64/time.h
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 'include/asm-ppc64/time.h')
-rw-r--r--include/asm-ppc64/time.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/include/asm-ppc64/time.h b/include/asm-ppc64/time.h
new file mode 100644
index 000000000000..8d6e3760ee10
--- /dev/null
+++ b/include/asm-ppc64/time.h
@@ -0,0 +1,115 @@
1/*
2 * Common time prototypes and such for all ppc machines.
3 *
4 * Written by Cort Dougan (cort@cs.nmt.edu) to merge
5 * Paul Mackerras' version and mine for PReP and Pmac.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#ifndef __PPC64_TIME_H
14#define __PPC64_TIME_H
15
16#ifdef __KERNEL__
17#include <linux/config.h>
18#include <linux/types.h>
19#include <linux/mc146818rtc.h>
20
21#include <asm/processor.h>
22#include <asm/paca.h>
23#include <asm/iSeries/HvCall.h>
24
25/* time.c */
26extern unsigned long tb_ticks_per_jiffy;
27extern unsigned long tb_ticks_per_usec;
28extern unsigned long tb_ticks_per_sec;
29extern unsigned long tb_to_xs;
30extern unsigned tb_to_us;
31extern unsigned long tb_last_stamp;
32
33struct rtc_time;
34extern void to_tm(int tim, struct rtc_time * tm);
35extern time_t last_rtc_update;
36
37/*
38 * By putting all of this stuff into a single struct we
39 * reduce the number of cache lines touched by do_gettimeofday.
40 * Both by collecting all of the data in one cache line and
41 * by touching only one TOC entry
42 */
43struct gettimeofday_vars {
44 unsigned long tb_to_xs;
45 unsigned long stamp_xsec;
46 unsigned long tb_orig_stamp;
47};
48
49struct gettimeofday_struct {
50 unsigned long tb_ticks_per_sec;
51 struct gettimeofday_vars vars[2];
52 struct gettimeofday_vars * volatile varp;
53 unsigned var_idx;
54 unsigned tb_to_us;
55};
56
57struct div_result {
58 unsigned long result_high;
59 unsigned long result_low;
60};
61
62int via_calibrate_decr(void);
63
64static __inline__ unsigned long get_tb(void)
65{
66 return mftb();
67}
68
69/* Accessor functions for the decrementer register. */
70static __inline__ unsigned int get_dec(void)
71{
72 return (mfspr(SPRN_DEC));
73}
74
75static __inline__ void set_dec(int val)
76{
77#ifdef CONFIG_PPC_ISERIES
78 struct paca_struct *lpaca = get_paca();
79 int cur_dec;
80
81 if (lpaca->lppaca.shared_proc) {
82 lpaca->lppaca.virtual_decr = val;
83 cur_dec = get_dec();
84 if (cur_dec > val)
85 HvCall_setVirtualDecr();
86 } else
87#endif
88 mtspr(SPRN_DEC, val);
89}
90
91static inline unsigned long tb_ticks_since(unsigned long tstamp)
92{
93 return get_tb() - tstamp;
94}
95
96#define mulhwu(x,y) \
97({unsigned z; asm ("mulhwu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
98#define mulhdu(x,y) \
99({unsigned long z; asm ("mulhdu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
100
101
102unsigned mulhwu_scale_factor(unsigned, unsigned);
103void div128_by_32( unsigned long dividend_high, unsigned long dividend_low,
104 unsigned divisor, struct div_result *dr );
105
106/* Used to store Processor Utilization register (purr) values */
107
108struct cpu_usage {
109 u64 current_tb; /* Holds the current purr register values */
110};
111
112DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array);
113
114#endif /* __KERNEL__ */
115#endif /* __PPC64_TIME_H */