RTEMS 6.1-rc6
Loading...
Searching...
No Matches
timetc.h
Go to the documentation of this file.
1
10/*-
11 * ----------------------------------------------------------------------------
12 * "THE BEER-WARE LICENSE" (Revision 42):
13 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
14 * can do whatever you want with this stuff. If we meet some day, and you think
15 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
16 * ----------------------------------------------------------------------------
17 */
18
19#ifndef _SYS_TIMETC_H_
20#define _SYS_TIMETC_H_
21
22#ifndef __rtems__
23#ifndef _KERNEL
24#error "no user-serviceable parts inside"
25#endif
26#else /* __rtems__ */
27#ifdef __cplusplus
28extern "C" {
29#endif /* __cplusplus */
30#endif /* __rtems__ */
31
32/*-
33 * `struct timecounter' is the interface between the hardware which implements
34 * a timecounter and the MI code which uses this to keep track of time.
35 *
36 * A timecounter is a binary counter which has two properties:
37 * * it runs at a fixed, known frequency.
38 * * it has sufficient bits to not roll over in less than approximately
39 * max(2 msec, 2/HZ seconds). (The value 2 here is really 1 + delta,
40 * for some indeterminate value of delta.)
41 */
42
43struct timecounter;
44struct vdso_timehands;
45struct vdso_timehands32;
46#ifndef __rtems__
47typedef u_int timecounter_get_t(struct timecounter *);
48#else /* __rtems__ */
49typedef uint32_t timecounter_get_t(struct timecounter *);
50#define tc_getfrequency _Timecounter_Get_frequency
51#endif /* __rtems__ */
52typedef void timecounter_pps_t(struct timecounter *);
53typedef uint32_t timecounter_fill_vdso_timehands_t(struct vdso_timehands *,
54 struct timecounter *);
55typedef uint32_t timecounter_fill_vdso_timehands32_t(struct vdso_timehands32 *,
56 struct timecounter *);
57
59 timecounter_get_t *tc_get_timecount;
60#ifndef __rtems__
61 /*
62 * This function reads the counter. It is not required to
63 * mask any unimplemented bits out, as long as they are
64 * constant.
65 */
66 timecounter_pps_t *tc_poll_pps;
67#endif /* __rtems__ */
68 /*
69 * This function is optional. It will be called whenever the
70 * timecounter is rewound, and is intended to check for PPS
71 * events. Normal hardware does not need it but timecounters
72 * which latch PPS in hardware do.
73 */
74 uint32_t tc_counter_mask;
75 /* This mask should mask off any unimplemented bits. */
76 uint64_t tc_frequency;
77 /* Frequency of the counter in Hz. */
78 const char *tc_name;
79 /* Name of the timecounter. */
80 int tc_quality;
81#ifndef __rtems__
82 /*
83 * Used to determine if this timecounter is better than
84 * another timecounter higher means better. Negative
85 * means "only use at explicit request".
86 */
87 u_int tc_flags;
88#define TC_FLAGS_C2STOP 1 /* Timer dies in C2+. */
89#define TC_FLAGS_SUSPEND_SAFE 2 /*
90 * Timer functional across
91 * suspend/resume.
92 */
93
94 void *tc_priv;
95 /* Pointer to the timecounter's private parts. */
96 struct timecounter *tc_next;
97 /* Pointer to the next timecounter. */
98 timecounter_fill_vdso_timehands_t *tc_fill_vdso_timehands;
99 timecounter_fill_vdso_timehands32_t *tc_fill_vdso_timehands32;
100#endif /* __rtems__ */
101};
102
103extern struct timecounter *timecounter;
104extern int tc_min_ticktock_freq; /*
105 * Minimal tc_ticktock() call frequency,
106 * required to handle counter wraps.
107 */
108
109u_int64_t tc_getfrequency(void);
110void tc_init(struct timecounter *tc);
111void tc_setclock(struct timespec *ts);
112void tc_ticktock(int cnt);
113void cpu_tick_calibration(void);
114
115#ifdef SYSCTL_DECL
116SYSCTL_DECL(_kern_timecounter);
117#endif
118
119#ifdef __rtems__
120#ifdef __cplusplus
121}
122#endif /* __cplusplus */
123#endif /* __rtems__ */
124#endif /* !_SYS_TIMETC_H_ */
Definition: timetc.h:58