FreeBSD/Linux Kernel Cross Reference
sys/sys/timetc.h
1 /* $NetBSD: timetc.h,v 1.3 2006/09/02 13:47:03 kardel Exp $ */
2
3 /*-
4 * ----------------------------------------------------------------------------
5 * "THE BEER-WARE LICENSE" (Revision 42):
6 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
7 * can do whatever you want with this stuff. If we meet some day, and you think
8 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
9 * ----------------------------------------------------------------------------
10 *
11 * $FreeBSD: src/sys/sys/timetc.h,v 1.58 2003/08/16 08:23:52 phk Exp $
12 */
13
14 #ifndef _SYS_TIMETC_H_
15 #define _SYS_TIMETC_H_
16
17 #ifndef _KERNEL
18 #error "no user-serviceable parts inside"
19 #endif
20
21 /*
22 * max recommended timecounter name length
23 *
24 * it is not a functional limit but names longer
25 * then that will not be controllable via
26 * sysctl. see kern/kern_tc.c for the sysctl
27 * implementation.
28 */
29 #define MAX_TCNAMELEN 64
30
31 /*-
32 * `struct timecounter' is the interface between the hardware which implements
33 * a timecounter and the MI code which uses this to keep track of time.
34 *
35 * A timecounter is a binary counter which has two properties:
36 * * it runs at a fixed, known frequency.
37 * * it has sufficient bits to not roll over in less than approximately
38 * max(2 msec, 2/HZ seconds). (The value 2 here is really 1 + delta,
39 * for some indeterminate value of delta.)
40 */
41
42 struct timecounter;
43 typedef u_int timecounter_get_t(struct timecounter *);
44 typedef void timecounter_pps_t(struct timecounter *);
45
46 struct timecounter {
47 timecounter_get_t *tc_get_timecount;
48 /*
49 * This function reads the counter. It is not required to
50 * mask any unimplemented bits out, as long as they are
51 * constant.
52 */
53 timecounter_pps_t *tc_poll_pps;
54 /*
55 * This function is optional. It will be called whenever the
56 * timecounter is rewound, and is intended to check for PPS
57 * events. Normal hardware does not need it but timecounters
58 * which latch PPS in hardware (like sys/pci/xrpu.c) do.
59 */
60 u_int tc_counter_mask;
61 /* This mask should mask off any unimplemented bits. */
62 u_int64_t tc_frequency;
63 /* Frequency of the counter in Hz. */
64 const char *tc_name;
65 /* Name of the timecounter. */
66 int tc_quality;
67 /*
68 * Used to determine if this timecounter is better than
69 * another timecounter higher means better. Negative
70 * means "only use at explicit request".
71 */
72
73 void *tc_priv;
74 /* Pointer to the timecounter's private parts. */
75 struct timecounter *tc_next;
76 /* Pointer to the next timecounter. */
77 };
78
79 extern struct timecounter *timecounter;
80
81 u_int64_t tc_getfrequency(void);
82 void tc_init(struct timecounter *tc);
83 void tc_setclock(struct timespec *ts);
84 void tc_ticktock(void);
85
86 #ifdef SYSCTL_DECL
87 SYSCTL_DECL(_kern_timecounter);
88 #endif
89
90 #endif /* !_SYS_TIMETC_H_ */
Cache object: 07eb431a9a834f0e728c5781ec4652fc
|