Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
0004  */
0005 
0006 #ifndef __IRQ_KERN_H__
0007 #define __IRQ_KERN_H__
0008 
0009 #include <linux/interrupt.h>
0010 #include <linux/time-internal.h>
0011 #include <asm/ptrace.h>
0012 #include "irq_user.h"
0013 
0014 #define UM_IRQ_ALLOC    -1
0015 
0016 int um_request_irq(int irq, int fd, enum um_irq_type type,
0017            irq_handler_t handler, unsigned long irqflags,
0018            const char *devname, void *dev_id);
0019 
0020 #ifdef CONFIG_UML_TIME_TRAVEL_SUPPORT
0021 /**
0022  * um_request_irq_tt - request an IRQ with timetravel handler
0023  *
0024  * @irq: the IRQ number, or %UM_IRQ_ALLOC
0025  * @fd: The file descriptor to request an IRQ for
0026  * @type: read or write
0027  * @handler: the (generic style) IRQ handler
0028  * @irqflags: Linux IRQ flags
0029  * @devname: name for this to show
0030  * @dev_id: data pointer to pass to the IRQ handler
0031  * @timetravel_handler: the timetravel interrupt handler, invoked with the IRQ
0032  *  number, fd, dev_id and time-travel event pointer.
0033  *
0034  * Returns: The interrupt number assigned or a negative error.
0035  *
0036  * Note that the timetravel handler is invoked only if the time_travel_mode is
0037  * %TT_MODE_EXTERNAL, and then it is invoked even while the system is suspended!
0038  * This function must call time_travel_add_irq_event() for the event passed with
0039  * an appropriate delay, before sending an ACK on the socket it was invoked for.
0040  *
0041  * If this was called while the system is suspended, then adding the event will
0042  * cause the system to resume.
0043  *
0044  * Since this function will almost certainly have to handle the FD's condition,
0045  * a read will consume the message, and after that it is up to the code using
0046  * it to pass such a message to the @handler in whichever way it can.
0047  *
0048  * If time_travel_mode is not %TT_MODE_EXTERNAL the @timetravel_handler will
0049  * not be invoked at all and the @handler must handle the FD becoming
0050  * readable (or writable) instead. Use um_irq_timetravel_handler_used() to
0051  * distinguish these cases.
0052  *
0053  * See virtio_uml.c for an example.
0054  */
0055 int um_request_irq_tt(int irq, int fd, enum um_irq_type type,
0056               irq_handler_t handler, unsigned long irqflags,
0057               const char *devname, void *dev_id,
0058               void (*timetravel_handler)(int, int, void *,
0059                          struct time_travel_event *));
0060 #else
0061 static inline
0062 int um_request_irq_tt(int irq, int fd, enum um_irq_type type,
0063               irq_handler_t handler, unsigned long irqflags,
0064               const char *devname, void *dev_id,
0065               void (*timetravel_handler)(int, int, void *,
0066                          struct time_travel_event *))
0067 {
0068     return um_request_irq(irq, fd, type, handler, irqflags,
0069                   devname, dev_id);
0070 }
0071 #endif
0072 
0073 static inline bool um_irq_timetravel_handler_used(void)
0074 {
0075     return time_travel_mode == TT_MODE_EXTERNAL;
0076 }
0077 
0078 void um_free_irq(int irq, void *dev_id);
0079 #endif