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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef _IPXE_TIMER_H
  2. #define _IPXE_TIMER_H
  3. /** @file
  4. *
  5. * iPXE timers
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <ipxe/tables.h>
  10. /** Number of ticks per second */
  11. #define TICKS_PER_SEC 1024
  12. /** Number of ticks per millisecond
  13. *
  14. * This is (obviously) not 100% consistent with the definition of
  15. * TICKS_PER_SEC, but it allows for multiplications and divisions to
  16. * be elided. In any case, timer ticks are not expected to be a
  17. * precision timing source; for example, the standard BIOS timer is
  18. * based on an 18.2Hz clock.
  19. */
  20. #define TICKS_PER_MS 1
  21. /** A timer */
  22. struct timer {
  23. /** Name */
  24. const char *name;
  25. /**
  26. * Probe timer
  27. *
  28. * @ret rc Return status code
  29. */
  30. int ( * probe ) ( void );
  31. /**
  32. * Get current system time in ticks
  33. *
  34. * @ret ticks Current time, in ticks
  35. */
  36. unsigned long ( * currticks ) ( void );
  37. /**
  38. * Delay for a fixed number of microseconds
  39. *
  40. * @v usecs Number of microseconds for which to delay
  41. */
  42. void ( * udelay ) ( unsigned long usecs );
  43. };
  44. /** Timer table */
  45. #define TIMERS __table ( struct timer, "timers" )
  46. /** Declare a timer */
  47. #define __timer( order ) __table_entry ( TIMERS, order )
  48. /** @defgroup timer_order Timer detection order
  49. *
  50. * @{
  51. */
  52. #define TIMER_PREFERRED 01 /**< Preferred timer */
  53. #define TIMER_NORMAL 02 /**< Normal timer */
  54. /** @} */
  55. /*
  56. * sleep() prototype is defined by POSIX.1. usleep() prototype is
  57. * defined by 4.3BSD. udelay() and mdelay() prototypes are chosen to
  58. * be reasonably sensible.
  59. *
  60. */
  61. extern void udelay ( unsigned long usecs );
  62. extern void mdelay ( unsigned long msecs );
  63. extern unsigned long currticks ( void );
  64. extern unsigned int sleep ( unsigned int seconds );
  65. #endif /* _IPXE_TIMER_H */