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.8KB

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