time-internal.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2012 - 2014 Cisco Systems
  4. * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  5. */
  6. #ifndef __TIMER_INTERNAL_H__
  7. #define __TIMER_INTERNAL_H__
  8. #include <linux/list.h>
  9. #include <asm/bug.h>
  10. #include <shared/timetravel.h>
  11. #define TIMER_MULTIPLIER 256
  12. #define TIMER_MIN_DELTA 500
  13. #ifdef CONFIG_UML_TIME_TRAVEL_SUPPORT
  14. struct time_travel_event {
  15. unsigned long long time;
  16. void (*fn)(struct time_travel_event *d);
  17. struct list_head list;
  18. bool pending, onstack;
  19. };
  20. void time_travel_sleep(void);
  21. static inline void
  22. time_travel_set_event_fn(struct time_travel_event *e,
  23. void (*fn)(struct time_travel_event *d))
  24. {
  25. e->fn = fn;
  26. }
  27. void __time_travel_propagate_time(void);
  28. static inline void time_travel_propagate_time(void)
  29. {
  30. if (time_travel_mode == TT_MODE_EXTERNAL)
  31. __time_travel_propagate_time();
  32. }
  33. void __time_travel_wait_readable(int fd);
  34. static inline void time_travel_wait_readable(int fd)
  35. {
  36. if (time_travel_mode == TT_MODE_EXTERNAL)
  37. __time_travel_wait_readable(fd);
  38. }
  39. void time_travel_add_irq_event(struct time_travel_event *e);
  40. void time_travel_add_event_rel(struct time_travel_event *e,
  41. unsigned long long delay_ns);
  42. bool time_travel_del_event(struct time_travel_event *e);
  43. #else
  44. struct time_travel_event {
  45. };
  46. static inline void time_travel_sleep(void)
  47. {
  48. }
  49. /* this is a macro so the event/function need not exist */
  50. #define time_travel_set_event_fn(e, fn) do {} while (0)
  51. static inline void time_travel_propagate_time(void)
  52. {
  53. }
  54. static inline void time_travel_wait_readable(int fd)
  55. {
  56. }
  57. static inline void time_travel_add_irq_event(struct time_travel_event *e)
  58. {
  59. WARN_ON(1);
  60. }
  61. /*
  62. * not inlines so the data structure need not exist,
  63. * cause linker failures
  64. */
  65. extern void time_travel_not_configured(void);
  66. #define time_travel_add_event_rel(...) time_travel_not_configured()
  67. #define time_travel_del_event(...) time_travel_not_configured()
  68. #endif /* CONFIG_UML_TIME_TRAVEL_SUPPORT */
  69. /*
  70. * Without CONFIG_UML_TIME_TRAVEL_SUPPORT this is a linker error if used,
  71. * which is intentional since we really shouldn't link it in that case.
  72. */
  73. void time_travel_ndelay(unsigned long nsec);
  74. #endif /* __TIMER_INTERNAL_H__ */