xen_intr.h revision 189699
150477Speter/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- */ 22998Swollman#ifndef _XEN_INTR_H_ 3249596Sken#define _XEN_INTR_H_ 483651Speter 583651Speter/* 6249592Sken* The flat IRQ space is divided into two regions: 7195202Sdfr* 1. A one-to-one mapping of real physical IRQs. This space is only used 8185299Sdfr* if we have physical device-access privilege. This region is at the 983651Speter* start of the IRQ space so that existing device drivers do not need 10100134Salfred* to be modified to translate physical IRQ numbers into our IRQ space. 11151350Syar* 3. A dynamic mapping of inter-domain and Xen-sourced virtual IRQs. These 12151350Syar* are bound using the provided bind/unbind functions. 13100134Salfred* 1470711Sobrien* 15100134Salfred* $FreeBSD: head/sys/xen/xen_intr.h 189699 2009-03-11 15:30:12Z dfr $ 16100134Salfred*/ 17100134Salfred 18100134Salfred#define PIRQ_BASE 0 19151350Syar#define NR_PIRQS 128 20100134Salfred 2160966Speter#define DYNIRQ_BASE (PIRQ_BASE + NR_PIRQS) 22#define NR_DYNIRQS 128 23 24#define NR_IRQS (NR_PIRQS + NR_DYNIRQS) 25 26#define pirq_to_irq(_x) ((_x) + PIRQ_BASE) 27#define irq_to_pirq(_x) ((_x) - PIRQ_BASE) 28 29#define dynirq_to_irq(_x) ((_x) + DYNIRQ_BASE) 30#define irq_to_dynirq(_x) ((_x) - DYNIRQ_BASE) 31 32/* 33 * Dynamic binding of event channels and VIRQ sources to guest IRQ space. 34 */ 35 36/* 37 * Bind a caller port event channel to an interrupt handler. If 38 * successful, the guest IRQ number is returned in *irqp. Return zero 39 * on success or errno otherwise. 40 */ 41extern int bind_caller_port_to_irqhandler(unsigned int caller_port, 42 const char *devname, driver_intr_t handler, void *arg, 43 unsigned long irqflags, unsigned int *irqp); 44 45/* 46 * Bind a listening port to an interrupt handler. If successful, the 47 * guest IRQ number is returned in *irqp. Return zero on success or 48 * errno otherwise. 49 */ 50extern int bind_listening_port_to_irqhandler(unsigned int remote_domain, 51 const char *devname, driver_intr_t handler, void *arg, 52 unsigned long irqflags, unsigned int *irqp); 53 54/* 55 * Bind a VIRQ to an interrupt handler. If successful, the guest IRQ 56 * number is returned in *irqp. Return zero on success or errno 57 * otherwise. 58 */ 59extern int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, 60 const char *devname, driver_filter_t filter, driver_intr_t handler, 61 void *arg, unsigned long irqflags, unsigned int *irqp); 62 63/* 64 * Bind an IPI to an interrupt handler. If successful, the guest 65 * IRQ number is returned in *irqp. Return zero on success or errno 66 * otherwise. 67 */ 68extern int bind_ipi_to_irqhandler(unsigned int ipi, unsigned int cpu, 69 const char *devname, driver_filter_t filter, 70 unsigned long irqflags, unsigned int *irqp); 71 72/* 73 * Bind an interdomain event channel to an interrupt handler. If 74 * successful, the guest IRQ number is returned in *irqp. Return zero 75 * on success or errno otherwise. 76 */ 77extern int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain, 78 unsigned int remote_port, const char *devname, 79 driver_filter_t filter, driver_intr_t handler, 80 unsigned long irqflags, unsigned int *irqp); 81 82/* 83 * Unbind an interrupt handler using the guest IRQ number returned 84 * when it was bound. 85 */ 86extern void unbind_from_irqhandler(unsigned int irq); 87 88static __inline__ int irq_cannonicalize(unsigned int irq) 89{ 90 return (irq == 2) ? 9 : irq; 91} 92 93extern void disable_irq(unsigned int); 94extern void disable_irq_nosync(unsigned int); 95extern void enable_irq(unsigned int); 96 97extern void irq_suspend(void); 98extern void irq_resume(void); 99 100extern void idle_block(void); 101extern int ap_cpu_initclocks(int cpu); 102 103#endif /* _XEN_INTR_H_ */ 104