Home | History | Annotate | Download | only in gpxe
      1 #ifndef	_GPXE_TIMER_H
      2 #define _GPXE_TIMER_H
      3 
      4 /** @file
      5  *
      6  * gPXE timer API
      7  *
      8  * The timer API provides udelay() for fixed delays, and currticks()
      9  * for a monotonically increasing tick counter.
     10  */
     11 
     12 FILE_LICENCE ( GPL2_OR_LATER );
     13 
     14 #include <gpxe/api.h>
     15 #include <config/timer.h>
     16 
     17 /**
     18  * Calculate static inline timer API function name
     19  *
     20  * @v _prefix		Subsystem prefix
     21  * @v _api_func		API function
     22  * @ret _subsys_func	Subsystem API function
     23  */
     24 #define TIMER_INLINE( _subsys, _api_func ) \
     25 	SINGLE_API_INLINE ( TIMER_PREFIX_ ## _subsys, _api_func )
     26 
     27 /**
     28  * Provide a timer API implementation
     29  *
     30  * @v _prefix		Subsystem prefix
     31  * @v _api_func		API function
     32  * @v _func		Implementing function
     33  */
     34 #define PROVIDE_TIMER( _subsys, _api_func, _func ) \
     35 	PROVIDE_SINGLE_API ( TIMER_PREFIX_ ## _subsys, _api_func, _func )
     36 
     37 /**
     38  * Provide a static inline timer API implementation
     39  *
     40  * @v _prefix		Subsystem prefix
     41  * @v _api_func		API function
     42  */
     43 #define PROVIDE_TIMER_INLINE( _subsys, _api_func ) \
     44 	PROVIDE_SINGLE_API_INLINE ( TIMER_PREFIX_ ## _subsys, _api_func )
     45 
     46 /* Include all architecture-independent I/O API headers */
     47 #include <gpxe/efi/efi_timer.h>
     48 
     49 /* Include all architecture-dependent I/O API headers */
     50 #include <bits/timer.h>
     51 
     52 /**
     53  * Delay for a fixed number of microseconds
     54  *
     55  * @v usecs		Number of microseconds for which to delay
     56  */
     57 void udelay ( unsigned long usecs );
     58 
     59 /**
     60  * Get current system time in ticks
     61  *
     62  * @ret ticks		Current time, in ticks
     63  */
     64 unsigned long currticks ( void );
     65 
     66 /**
     67  * Get number of ticks per second
     68  *
     69  * @ret ticks_per_sec	Number of ticks per second
     70  */
     71 unsigned long ticks_per_sec ( void );
     72 
     73 /** Number of ticks per second */
     74 #define TICKS_PER_SEC ( ticks_per_sec() )
     75 
     76 #endif /* _GPXE_TIMER_H */
     77