Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _XEN_EVENTS_H
0003 #define _XEN_EVENTS_H
0004 
0005 #include <linux/interrupt.h>
0006 #include <linux/irq.h>
0007 #ifdef CONFIG_PCI_MSI
0008 #include <linux/msi.h>
0009 #endif
0010 
0011 #include <xen/interface/event_channel.h>
0012 #include <asm/xen/hypercall.h>
0013 #include <asm/xen/events.h>
0014 
0015 struct xenbus_device;
0016 
0017 unsigned xen_evtchn_nr_channels(void);
0018 
0019 int bind_evtchn_to_irq(evtchn_port_t evtchn);
0020 int bind_evtchn_to_irq_lateeoi(evtchn_port_t evtchn);
0021 int bind_evtchn_to_irqhandler(evtchn_port_t evtchn,
0022                   irq_handler_t handler,
0023                   unsigned long irqflags, const char *devname,
0024                   void *dev_id);
0025 int bind_evtchn_to_irqhandler_lateeoi(evtchn_port_t evtchn,
0026                   irq_handler_t handler,
0027                   unsigned long irqflags, const char *devname,
0028                   void *dev_id);
0029 int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu);
0030 int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu,
0031                 irq_handler_t handler,
0032                 unsigned long irqflags, const char *devname,
0033                 void *dev_id);
0034 int bind_ipi_to_irqhandler(enum ipi_vector ipi,
0035                unsigned int cpu,
0036                irq_handler_t handler,
0037                unsigned long irqflags,
0038                const char *devname,
0039                void *dev_id);
0040 int bind_interdomain_evtchn_to_irq_lateeoi(struct xenbus_device *dev,
0041                        evtchn_port_t remote_port);
0042 int bind_interdomain_evtchn_to_irqhandler_lateeoi(struct xenbus_device *dev,
0043                           evtchn_port_t remote_port,
0044                           irq_handler_t handler,
0045                           unsigned long irqflags,
0046                           const char *devname,
0047                           void *dev_id);
0048 
0049 /*
0050  * Common unbind function for all event sources. Takes IRQ to unbind from.
0051  * Automatically closes the underlying event channel (even for bindings
0052  * made with bind_evtchn_to_irqhandler()).
0053  */
0054 void unbind_from_irqhandler(unsigned int irq, void *dev_id);
0055 
0056 /*
0057  * Send late EOI for an IRQ bound to an event channel via one of the *_lateeoi
0058  * functions above.
0059  */
0060 void xen_irq_lateeoi(unsigned int irq, unsigned int eoi_flags);
0061 /* Signal an event was spurious, i.e. there was no action resulting from it. */
0062 #define XEN_EOI_FLAG_SPURIOUS   0x00000001
0063 
0064 #define XEN_IRQ_PRIORITY_MAX     EVTCHN_FIFO_PRIORITY_MAX
0065 #define XEN_IRQ_PRIORITY_DEFAULT EVTCHN_FIFO_PRIORITY_DEFAULT
0066 #define XEN_IRQ_PRIORITY_MIN     EVTCHN_FIFO_PRIORITY_MIN
0067 int xen_set_irq_priority(unsigned irq, unsigned priority);
0068 
0069 /*
0070  * Allow extra references to event channels exposed to userspace by evtchn
0071  */
0072 int evtchn_make_refcounted(evtchn_port_t evtchn);
0073 int evtchn_get(evtchn_port_t evtchn);
0074 void evtchn_put(evtchn_port_t evtchn);
0075 
0076 void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector);
0077 void rebind_evtchn_irq(evtchn_port_t evtchn, int irq);
0078 int xen_set_affinity_evtchn(struct irq_desc *desc, unsigned int tcpu);
0079 
0080 static inline void notify_remote_via_evtchn(evtchn_port_t port)
0081 {
0082     struct evtchn_send send = { .port = port };
0083     (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
0084 }
0085 
0086 void notify_remote_via_irq(int irq);
0087 
0088 void xen_irq_resume(void);
0089 
0090 /* Clear an irq's pending state, in preparation for polling on it */
0091 void xen_clear_irq_pending(int irq);
0092 void xen_set_irq_pending(int irq);
0093 bool xen_test_irq_pending(int irq);
0094 
0095 /* Poll waiting for an irq to become pending.  In the usual case, the
0096    irq will be disabled so it won't deliver an interrupt. */
0097 void xen_poll_irq(int irq);
0098 
0099 /* Poll waiting for an irq to become pending with a timeout.  In the usual case,
0100  * the irq will be disabled so it won't deliver an interrupt. */
0101 void xen_poll_irq_timeout(int irq, u64 timeout);
0102 
0103 /* Determine the IRQ which is bound to an event channel */
0104 unsigned int irq_from_evtchn(evtchn_port_t evtchn);
0105 int irq_from_virq(unsigned int cpu, unsigned int virq);
0106 evtchn_port_t evtchn_from_irq(unsigned irq);
0107 
0108 int xen_set_callback_via(uint64_t via);
0109 void xen_evtchn_do_upcall(struct pt_regs *regs);
0110 void xen_hvm_evtchn_do_upcall(void);
0111 
0112 /* Bind a pirq for a physical interrupt to an irq. */
0113 int xen_bind_pirq_gsi_to_irq(unsigned gsi,
0114                  unsigned pirq, int shareable, char *name);
0115 
0116 #ifdef CONFIG_PCI_MSI
0117 /* Allocate a pirq for a MSI style physical interrupt. */
0118 int xen_allocate_pirq_msi(struct pci_dev *dev, struct msi_desc *msidesc);
0119 /* Bind an PSI pirq to an irq. */
0120 int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc,
0121                  int pirq, int nvec, const char *name, domid_t domid);
0122 #endif
0123 
0124 /* De-allocates the above mentioned physical interrupt. */
0125 int xen_destroy_irq(int irq);
0126 
0127 /* Return irq from pirq */
0128 int xen_irq_from_pirq(unsigned pirq);
0129 
0130 /* Return the pirq allocated to the irq. */
0131 int xen_pirq_from_irq(unsigned irq);
0132 
0133 /* Return the irq allocated to the gsi */
0134 int xen_irq_from_gsi(unsigned gsi);
0135 
0136 /* Determine whether to ignore this IRQ if it is passed to a guest. */
0137 int xen_test_irq_shared(int irq);
0138 
0139 /* initialize Xen IRQ subsystem */
0140 void xen_init_IRQ(void);
0141 #endif  /* _XEN_EVENTS_H */