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