1e46cdb66SJeremy Fitzhardinge #ifndef _XEN_EVENTS_H 2e46cdb66SJeremy Fitzhardinge #define _XEN_EVENTS_H 3e46cdb66SJeremy Fitzhardinge 4f87e4cacSJeremy Fitzhardinge #include <linux/interrupt.h> 5f87e4cacSJeremy Fitzhardinge 6f87e4cacSJeremy Fitzhardinge #include <xen/interface/event_channel.h> 7f87e4cacSJeremy Fitzhardinge #include <asm/xen/hypercall.h> 8e849c3e9SIsaku Yamahata #include <asm/xen/events.h> 9e46cdb66SJeremy Fitzhardinge 10b536b4b9SJeremy Fitzhardinge int bind_evtchn_to_irq(unsigned int evtchn); 11e46cdb66SJeremy Fitzhardinge int bind_evtchn_to_irqhandler(unsigned int evtchn, 12f87e4cacSJeremy Fitzhardinge irq_handler_t handler, 13e46cdb66SJeremy Fitzhardinge unsigned long irqflags, const char *devname, 14e46cdb66SJeremy Fitzhardinge void *dev_id); 154fe7d5a7SJeremy Fitzhardinge int bind_virq_to_irq(unsigned int virq, unsigned int cpu); 16e46cdb66SJeremy Fitzhardinge int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, 17f87e4cacSJeremy Fitzhardinge irq_handler_t handler, 18f87e4cacSJeremy Fitzhardinge unsigned long irqflags, const char *devname, 19f87e4cacSJeremy Fitzhardinge void *dev_id); 20f87e4cacSJeremy Fitzhardinge int bind_ipi_to_irqhandler(enum ipi_vector ipi, 21f87e4cacSJeremy Fitzhardinge unsigned int cpu, 22f87e4cacSJeremy Fitzhardinge irq_handler_t handler, 23f87e4cacSJeremy Fitzhardinge unsigned long irqflags, 24f87e4cacSJeremy Fitzhardinge const char *devname, 25f87e4cacSJeremy Fitzhardinge void *dev_id); 262e820f58SIan Campbell int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, 272e820f58SIan Campbell unsigned int remote_port, 282e820f58SIan Campbell irq_handler_t handler, 292e820f58SIan Campbell unsigned long irqflags, 302e820f58SIan Campbell const char *devname, 312e820f58SIan Campbell void *dev_id); 32e46cdb66SJeremy Fitzhardinge 33e46cdb66SJeremy Fitzhardinge /* 34e46cdb66SJeremy Fitzhardinge * Common unbind function for all event sources. Takes IRQ to unbind from. 35e46cdb66SJeremy Fitzhardinge * Automatically closes the underlying event channel (even for bindings 36e46cdb66SJeremy Fitzhardinge * made with bind_evtchn_to_irqhandler()). 37e46cdb66SJeremy Fitzhardinge */ 38e46cdb66SJeremy Fitzhardinge void unbind_from_irqhandler(unsigned int irq, void *dev_id); 39e46cdb66SJeremy Fitzhardinge 40f87e4cacSJeremy Fitzhardinge void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector); 41642e0c88SIsaku Yamahata int resend_irq_on_evtchn(unsigned int irq); 42eb1e305fSJeremy Fitzhardinge void rebind_evtchn_irq(int evtchn, int irq); 43f87e4cacSJeremy Fitzhardinge 44e46cdb66SJeremy Fitzhardinge static inline void notify_remote_via_evtchn(int port) 45e46cdb66SJeremy Fitzhardinge { 46e46cdb66SJeremy Fitzhardinge struct evtchn_send send = { .port = port }; 47e46cdb66SJeremy Fitzhardinge (void)HYPERVISOR_event_channel_op(EVTCHNOP_send, &send); 48e46cdb66SJeremy Fitzhardinge } 49e46cdb66SJeremy Fitzhardinge 5076465b2dSIan Campbell void notify_remote_via_irq(int irq); 510e91398fSJeremy Fitzhardinge 5276465b2dSIan Campbell void xen_irq_resume(void); 530e91398fSJeremy Fitzhardinge 542d9e1e2fSJeremy Fitzhardinge /* Clear an irq's pending state, in preparation for polling on it */ 552d9e1e2fSJeremy Fitzhardinge void xen_clear_irq_pending(int irq); 56168d2f46SJeremy Fitzhardinge void xen_set_irq_pending(int irq); 57168d2f46SJeremy Fitzhardinge bool xen_test_irq_pending(int irq); 582d9e1e2fSJeremy Fitzhardinge 592d9e1e2fSJeremy Fitzhardinge /* Poll waiting for an irq to become pending. In the usual case, the 602d9e1e2fSJeremy Fitzhardinge irq will be disabled so it won't deliver an interrupt. */ 612d9e1e2fSJeremy Fitzhardinge void xen_poll_irq(int irq); 622d9e1e2fSJeremy Fitzhardinge 63d9a8814fSKonrad Rzeszutek Wilk /* Poll waiting for an irq to become pending with a timeout. In the usual case, 64d9a8814fSKonrad Rzeszutek Wilk * the irq will be disabled so it won't deliver an interrupt. */ 65d9a8814fSKonrad Rzeszutek Wilk void xen_poll_irq_timeout(int irq, u64 timeout); 66d9a8814fSKonrad Rzeszutek Wilk 67d4c04536SIan Campbell /* Determine the IRQ which is bound to an event channel */ 68d4c04536SIan Campbell unsigned irq_from_evtchn(unsigned int evtchn); 69d4c04536SIan Campbell 7038e20b07SSheng Yang /* Xen HVM evtchn vector callback */ 7176465b2dSIan Campbell void xen_hvm_callback_vector(void); 7238e20b07SSheng Yang extern int xen_have_vector_callback; 7338e20b07SSheng Yang int xen_set_callback_via(uint64_t via); 7438e20b07SSheng Yang void xen_evtchn_do_upcall(struct pt_regs *regs); 7538e20b07SSheng Yang void xen_hvm_evtchn_do_upcall(void); 7638e20b07SSheng Yang 77f4d0635bSIan Campbell /* Allocate a pirq for a physical interrupt, given a gsi. */ 78f4d0635bSIan Campbell int xen_allocate_pirq_gsi(unsigned gsi); 79f4d0635bSIan Campbell /* Bind a pirq for a physical interrupt to an irq. */ 80f4d0635bSIan Campbell int xen_bind_pirq_gsi_to_irq(unsigned gsi, 81f4d0635bSIan Campbell unsigned pirq, int shareable, char *name); 82f731e3efSQing He 83f731e3efSQing He #ifdef CONFIG_PCI_MSI 84f4d0635bSIan Campbell /* Allocate a pirq for a MSI style physical interrupt. */ 85bf480d95SIan Campbell int xen_allocate_pirq_msi(struct pci_dev *dev, struct msi_desc *msidesc); 86f4d0635bSIan Campbell /* Bind an PSI pirq to an irq. */ 87bf480d95SIan Campbell int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, 88beafbdc1SKonrad Rzeszutek Wilk int pirq, int vector, const char *name, 89beafbdc1SKonrad Rzeszutek Wilk domid_t domid); 90f731e3efSQing He #endif 91d46a78b0SJeremy Fitzhardinge 92b5401a96SAlex Nixon /* De-allocates the above mentioned physical interrupt. */ 93b5401a96SAlex Nixon int xen_destroy_irq(int irq); 94b5401a96SAlex Nixon 95af42b8d1SStefano Stabellini /* Return irq from pirq */ 96af42b8d1SStefano Stabellini int xen_irq_from_pirq(unsigned pirq); 97af42b8d1SStefano Stabellini 98e6197accSKonrad Rzeszutek Wilk /* Return the pirq allocated to the irq. */ 99e6197accSKonrad Rzeszutek Wilk int xen_pirq_from_irq(unsigned irq); 100e6197accSKonrad Rzeszutek Wilk 101c7c2c3a2SKonrad Rzeszutek Wilk /* Determine whether to ignore this IRQ if it is passed to a guest. */ 102c7c2c3a2SKonrad Rzeszutek Wilk int xen_test_irq_shared(int irq); 103c7c2c3a2SKonrad Rzeszutek Wilk 104e46cdb66SJeremy Fitzhardinge #endif /* _XEN_EVENTS_H */ 105