root/sys/timetc.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


    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  * $OpenBSD: timetc.h,v 1.2 2006/10/30 20:19:33 otto Exp $
   10  * $FreeBSD: src/sys/sys/timetc.h,v 1.57 2003/04/10 23:07:24 des Exp $
   11  */
   12 
   13 #ifndef _SYS_TIMETC_H_
   14 #define _SYS_TIMETC_H_
   15 
   16 #ifndef _KERNEL
   17 #error "no user-serviceable parts inside"
   18 #endif
   19 
   20 /*-
   21  * `struct timecounter' is the interface between the hardware which implements
   22  * a timecounter and the MI code which uses this to keep track of time.
   23  *
   24  * A timecounter is a binary counter which has two properties:
   25  *    * it runs at a fixed, known frequency.
   26  *    * it has sufficient bits to not roll over in less than approximately
   27  *      max(2 msec, 2/HZ seconds).  (The value 2 here is really 1 + delta,
   28  *      for some indeterminate value of delta.)
   29  */
   30 
   31 struct timecounter;
   32 typedef u_int timecounter_get_t(struct timecounter *);
   33 typedef void timecounter_pps_t(struct timecounter *);
   34 
   35 struct timecounter {
   36         timecounter_get_t       *tc_get_timecount;
   37                 /*
   38                  * This function reads the counter.  It is not required to
   39                  * mask any unimplemented bits out, as long as they are
   40                  * constant.
   41                  */
   42         timecounter_pps_t       *tc_poll_pps;
   43                 /*
   44                  * This function is optional.  It will be called whenever the
   45                  * timecounter is rewound, and is intended to check for PPS
   46                  * events.  Normal hardware does not need it but timecounters
   47                  * which latch PPS in hardware (like sys/pci/xrpu.c) do.
   48                  */
   49         u_int                   tc_counter_mask;
   50                 /* This mask should mask off any unimplemented bits. */
   51         u_int64_t               tc_frequency;
   52                 /* Frequency of the counter in Hz. */
   53         char                    *tc_name;
   54                 /* Name of the timecounter. */
   55         int                     tc_quality;
   56                 /*
   57                  * Used to determine if this timecounter is better than
   58                  * another timecounter higher means better.  Negative
   59                  * means "only use at explicit request".
   60                  */
   61         void                    *tc_priv;
   62                 /* Pointer to the timecounter's private parts. */
   63         struct timecounter      *tc_next;
   64                 /* Pointer to the next timecounter. */
   65         int64_t                 tc_freq_adj;
   66                 /* Current frequency adjustment. */
   67 };
   68 
   69 extern struct timecounter *timecounter;
   70 
   71 u_int64_t tc_getfrequency(void);
   72 void    tc_init(struct timecounter *tc);
   73 void    tc_setclock(struct timespec *ts);
   74 void    tc_ticktock(void);
   75 void    inittimecounter(void);
   76 int     sysctl_tc(int *, u_int, void *, size_t *, void *, size_t);
   77 int     tc_adjfreq(int64_t *, int64_t *);
   78 
   79 #endif /* !_SYS_TIMETC_H_ */

/* [<][>][^][v][top][bottom][index][help] */