irq_kern.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2001, 2002 Jeff Dike ([email protected])
  4. */
  5. #ifndef __IRQ_KERN_H__
  6. #define __IRQ_KERN_H__
  7. #include <linux/interrupt.h>
  8. #include <linux/time-internal.h>
  9. #include <asm/ptrace.h>
  10. #include "irq_user.h"
  11. #define UM_IRQ_ALLOC -1
  12. int um_request_irq(int irq, int fd, enum um_irq_type type,
  13. irq_handler_t handler, unsigned long irqflags,
  14. const char *devname, void *dev_id);
  15. #ifdef CONFIG_UML_TIME_TRAVEL_SUPPORT
  16. /**
  17. * um_request_irq_tt - request an IRQ with timetravel handler
  18. *
  19. * @irq: the IRQ number, or %UM_IRQ_ALLOC
  20. * @fd: The file descriptor to request an IRQ for
  21. * @type: read or write
  22. * @handler: the (generic style) IRQ handler
  23. * @irqflags: Linux IRQ flags
  24. * @devname: name for this to show
  25. * @dev_id: data pointer to pass to the IRQ handler
  26. * @timetravel_handler: the timetravel interrupt handler, invoked with the IRQ
  27. * number, fd, dev_id and time-travel event pointer.
  28. *
  29. * Returns: The interrupt number assigned or a negative error.
  30. *
  31. * Note that the timetravel handler is invoked only if the time_travel_mode is
  32. * %TT_MODE_EXTERNAL, and then it is invoked even while the system is suspended!
  33. * This function must call time_travel_add_irq_event() for the event passed with
  34. * an appropriate delay, before sending an ACK on the socket it was invoked for.
  35. *
  36. * If this was called while the system is suspended, then adding the event will
  37. * cause the system to resume.
  38. *
  39. * Since this function will almost certainly have to handle the FD's condition,
  40. * a read will consume the message, and after that it is up to the code using
  41. * it to pass such a message to the @handler in whichever way it can.
  42. *
  43. * If time_travel_mode is not %TT_MODE_EXTERNAL the @timetravel_handler will
  44. * not be invoked at all and the @handler must handle the FD becoming
  45. * readable (or writable) instead. Use um_irq_timetravel_handler_used() to
  46. * distinguish these cases.
  47. *
  48. * See virtio_uml.c for an example.
  49. */
  50. int um_request_irq_tt(int irq, int fd, enum um_irq_type type,
  51. irq_handler_t handler, unsigned long irqflags,
  52. const char *devname, void *dev_id,
  53. void (*timetravel_handler)(int, int, void *,
  54. struct time_travel_event *));
  55. #else
  56. static inline
  57. int um_request_irq_tt(int irq, int fd, enum um_irq_type type,
  58. irq_handler_t handler, unsigned long irqflags,
  59. const char *devname, void *dev_id,
  60. void (*timetravel_handler)(int, int, void *,
  61. struct time_travel_event *))
  62. {
  63. return um_request_irq(irq, fd, type, handler, irqflags,
  64. devname, dev_id);
  65. }
  66. #endif
  67. static inline bool um_irq_timetravel_handler_used(void)
  68. {
  69. return time_travel_mode == TT_MODE_EXTERNAL;
  70. }
  71. void um_free_irq(int irq, void *dev_id);
  72. #endif