source: rtems/cpukit/score/include/sys/timetc.h @ 664f844

4.115
Last change on this file since 664f844 was 664f844, checked in by Alexander Krutwig <alexander.krutwig@…>, on 05/12/15 at 10:10:04

timecounter: Use uint32_t instead of u_int

FreeBSD assumes that u_int is a 32-bit integer type. This is wrong for
some 16-bit targets supported by RTEMS.

Update #2271.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*-
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.ORG> wrote this file.  As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
8 *
9 * $FreeBSD r277406 2015-01-20T03:54:30Z$
10 */
11
12#ifndef _SYS_TIMETC_H_
13#define _SYS_TIMETC_H_
14
15#ifndef _KERNEL
16#error "no user-serviceable parts inside"
17#endif
18
19/*-
20 * `struct timecounter' is the interface between the hardware which implements
21 * a timecounter and the MI code which uses this to keep track of time.
22 *
23 * A timecounter is a binary counter which has two properties:
24 *    * it runs at a fixed, known frequency.
25 *    * it has sufficient bits to not roll over in less than approximately
26 *      max(2 msec, 2/HZ seconds).  (The value 2 here is really 1 + delta,
27 *      for some indeterminate value of delta.)
28 */
29
30struct timecounter;
31typedef uint32_t timecounter_get_t(struct timecounter *);
32typedef void timecounter_pps_t(struct timecounter *);
33
34struct timecounter {
35        timecounter_get_t       *tc_get_timecount;
36                /*
37                 * This function reads the counter.  It is not required to
38                 * mask any unimplemented bits out, as long as they are
39                 * constant.
40                 */
41        timecounter_pps_t       *tc_poll_pps;
42                /*
43                 * This function is optional.  It will be called whenever the
44                 * timecounter is rewound, and is intended to check for PPS
45                 * events.  Normal hardware does not need it but timecounters
46                 * which latch PPS in hardware (like sys/pci/xrpu.c) do.
47                 */
48        uint32_t                tc_counter_mask;
49                /* This mask should mask off any unimplemented bits. */
50        uint64_t                tc_frequency;
51                /* Frequency of the counter in Hz. */
52        char                    *tc_name;
53                /* Name of the timecounter. */
54        int                     tc_quality;
55                /*
56                 * Used to determine if this timecounter is better than
57                 * another timecounter higher means better.  Negative
58                 * means "only use at explicit request".
59                 */
60        u_int                   tc_flags;
61#define TC_FLAGS_C2STOP         1       /* Timer dies in C2+. */
62#define TC_FLAGS_SUSPEND_SAFE   2       /*
63                                         * Timer functional across
64                                         * suspend/resume.
65                                         */
66
67        void                    *tc_priv;
68                /* Pointer to the timecounter's private parts. */
69        struct timecounter      *tc_next;
70                /* Pointer to the next timecounter. */
71};
72
73extern struct timecounter *timecounter;
74extern int tc_min_ticktock_freq; /*
75                                  * Minimal tc_ticktock() call frequency,
76                                  * required to handle counter wraps.
77                                  */
78
79u_int64_t tc_getfrequency(void);
80void    tc_init(struct timecounter *tc);
81void    tc_setclock(struct timespec *ts);
82void    tc_ticktock(int cnt);
83void    cpu_tick_calibration(void);
84
85#ifdef SYSCTL_DECL
86SYSCTL_DECL(_kern_timecounter);
87#endif
88
89#endif /* !_SYS_TIMETC_H_ */
Note: See TracBrowser for help on using the repository browser.