events_internal.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl);
  29. unsigned int cpu_from_evtchn(evtchn_port_t evtchn);
  30. static inline unsigned xen_evtchn_max_channels(void)
  31. {
  32. return evtchn_ops->max_channels();
  33. }
  34. /*
  35. * Do any ABI specific setup for a bound event channel before it can
  36. * be unmasked and used.
  37. */
  38. static inline int xen_evtchn_port_setup(evtchn_port_t evtchn)
  39. {
  40. if (evtchn_ops->setup)
  41. return evtchn_ops->setup(evtchn);
  42. return 0;
  43. }
  44. static inline void xen_evtchn_port_remove(evtchn_port_t evtchn,
  45. unsigned int cpu)
  46. {
  47. if (evtchn_ops->remove)
  48. evtchn_ops->remove(evtchn, cpu);
  49. }
  50. static inline void xen_evtchn_port_bind_to_cpu(evtchn_port_t evtchn,
  51. unsigned int cpu,
  52. unsigned int old_cpu)
  53. {
  54. evtchn_ops->bind_to_cpu(evtchn, cpu, old_cpu);
  55. }
  56. static inline void clear_evtchn(evtchn_port_t port)
  57. {
  58. evtchn_ops->clear_pending(port);
  59. }
  60. static inline void set_evtchn(evtchn_port_t port)
  61. {
  62. evtchn_ops->set_pending(port);
  63. }
  64. static inline bool test_evtchn(evtchn_port_t port)
  65. {
  66. return evtchn_ops->is_pending(port);
  67. }
  68. static inline void mask_evtchn(evtchn_port_t port)
  69. {
  70. return evtchn_ops->mask(port);
  71. }
  72. static inline void unmask_evtchn(evtchn_port_t port)
  73. {
  74. return evtchn_ops->unmask(port);
  75. }
  76. static inline void xen_evtchn_handle_events(unsigned cpu,
  77. struct evtchn_loop_ctrl *ctrl)
  78. {
  79. return evtchn_ops->handle_events(cpu, ctrl);
  80. }
  81. static inline void xen_evtchn_resume(void)
  82. {
  83. if (evtchn_ops->resume)
  84. evtchn_ops->resume();
  85. }
  86. void xen_evtchn_2l_init(void);
  87. int xen_evtchn_fifo_init(void);
  88. #endif /* #ifndef __EVENTS_INTERNAL_H__ */