events_internal.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Xen Event Channels (internal header)
  4. *
  5. * Copyright (C) 2013 Citrix Systems R&D Ltd.
  6. */
  7. #ifndef __EVENTS_INTERNAL_H__
  8. #define __EVENTS_INTERNAL_H__
  9. struct evtchn_loop_ctrl;
  10. struct evtchn_ops {
  11. unsigned (*max_channels)(void);
  12. unsigned (*nr_channels)(void);
  13. int (*setup)(evtchn_port_t port);
  14. void (*remove)(evtchn_port_t port, unsigned int cpu);
  15. void (*bind_to_cpu)(evtchn_port_t evtchn, unsigned int cpu,
  16. unsigned int old_cpu);
  17. void (*clear_pending)(evtchn_port_t port);
  18. void (*set_pending)(evtchn_port_t port);
  19. bool (*is_pending)(evtchn_port_t port);
  20. void (*mask)(evtchn_port_t port);
  21. void (*unmask)(evtchn_port_t port);
  22. void (*handle_events)(unsigned cpu, struct evtchn_loop_ctrl *ctrl);
  23. void (*resume)(void);
  24. int (*percpu_init)(unsigned int cpu);
  25. int (*percpu_deinit)(unsigned int cpu);
  26. };
  27. extern const struct evtchn_ops *evtchn_ops;
  28. int get_evtchn_to_irq(evtchn_port_t evtchn);
  29. void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl);
  30. unsigned int cpu_from_evtchn(evtchn_port_t evtchn);
  31. static inline unsigned xen_evtchn_max_channels(void)
  32. {
  33. return evtchn_ops->max_channels();
  34. }
  35. /*
  36. * Do any ABI specific setup for a bound event channel before it can
  37. * be unmasked and used.
  38. */
  39. static inline int xen_evtchn_port_setup(evtchn_port_t evtchn)
  40. {
  41. if (evtchn_ops->setup)
  42. return evtchn_ops->setup(evtchn);
  43. return 0;
  44. }
  45. static inline void xen_evtchn_port_remove(evtchn_port_t evtchn,
  46. unsigned int cpu)
  47. {
  48. if (evtchn_ops->remove)
  49. evtchn_ops->remove(evtchn, cpu);
  50. }
  51. static inline void xen_evtchn_port_bind_to_cpu(evtchn_port_t evtchn,
  52. unsigned int cpu,
  53. unsigned int old_cpu)
  54. {
  55. evtchn_ops->bind_to_cpu(evtchn, cpu, old_cpu);
  56. }
  57. static inline void clear_evtchn(evtchn_port_t port)
  58. {
  59. evtchn_ops->clear_pending(port);
  60. }
  61. static inline void set_evtchn(evtchn_port_t port)
  62. {
  63. evtchn_ops->set_pending(port);
  64. }
  65. static inline bool test_evtchn(evtchn_port_t port)
  66. {
  67. return evtchn_ops->is_pending(port);
  68. }
  69. static inline void mask_evtchn(evtchn_port_t port)
  70. {
  71. return evtchn_ops->mask(port);
  72. }
  73. static inline void unmask_evtchn(evtchn_port_t port)
  74. {
  75. return evtchn_ops->unmask(port);
  76. }
  77. static inline void xen_evtchn_handle_events(unsigned cpu,
  78. struct evtchn_loop_ctrl *ctrl)
  79. {
  80. return evtchn_ops->handle_events(cpu, ctrl);
  81. }
  82. static inline void xen_evtchn_resume(void)
  83. {
  84. if (evtchn_ops->resume)
  85. evtchn_ops->resume();
  86. }
  87. void xen_evtchn_2l_init(void);
  88. int xen_evtchn_fifo_init(void);
  89. #endif /* #ifndef __EVENTS_INTERNAL_H__ */