You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

timer.h 1.7KB

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