David Vrabel | 9a489f4 | 2013-03-13 15:29:25 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Xen Event Channels (internal header) |
| 3 | * |
| 4 | * Copyright (C) 2013 Citrix Systems R&D Ltd. |
| 5 | * |
| 6 | * This source code is licensed under the GNU General Public License, |
| 7 | * Version 2 or later. See the file COPYING for more details. |
| 8 | */ |
| 9 | #ifndef __EVENTS_INTERNAL_H__ |
| 10 | #define __EVENTS_INTERNAL_H__ |
| 11 | |
| 12 | /* Interrupt types. */ |
| 13 | enum xen_irq_type { |
| 14 | IRQT_UNBOUND = 0, |
| 15 | IRQT_PIRQ, |
| 16 | IRQT_VIRQ, |
| 17 | IRQT_IPI, |
| 18 | IRQT_EVTCHN |
| 19 | }; |
| 20 | |
| 21 | /* |
| 22 | * Packed IRQ information: |
| 23 | * type - enum xen_irq_type |
| 24 | * event channel - irq->event channel mapping |
| 25 | * cpu - cpu this event channel is bound to |
| 26 | * index - type-specific information: |
| 27 | * PIRQ - vector, with MSB being "needs EIO", or physical IRQ of the HVM |
| 28 | * guest, or GSI (real passthrough IRQ) of the device. |
| 29 | * VIRQ - virq number |
| 30 | * IPI - IPI vector |
| 31 | * EVTCHN - |
| 32 | */ |
| 33 | struct irq_info { |
| 34 | struct list_head list; |
| 35 | int refcnt; |
| 36 | enum xen_irq_type type; /* type */ |
| 37 | unsigned irq; |
| 38 | unsigned short evtchn; /* event channel */ |
| 39 | unsigned short cpu; /* cpu bound */ |
| 40 | |
| 41 | union { |
| 42 | unsigned short virq; |
| 43 | enum ipi_vector ipi; |
| 44 | struct { |
| 45 | unsigned short pirq; |
| 46 | unsigned short gsi; |
| 47 | unsigned char vector; |
| 48 | unsigned char flags; |
| 49 | uint16_t domid; |
| 50 | } pirq; |
| 51 | } u; |
| 52 | }; |
| 53 | |
| 54 | #define PIRQ_NEEDS_EOI (1 << 0) |
| 55 | #define PIRQ_SHAREABLE (1 << 1) |
| 56 | |
| 57 | extern int *evtchn_to_irq; |
| 58 | |
| 59 | struct irq_info *info_for_irq(unsigned irq); |
| 60 | unsigned cpu_from_irq(unsigned irq); |
| 61 | unsigned cpu_from_evtchn(unsigned int evtchn); |
| 62 | |
| 63 | void xen_evtchn_port_bind_to_cpu(struct irq_info *info, int cpu); |
| 64 | |
| 65 | void clear_evtchn(int port); |
| 66 | void set_evtchn(int port); |
| 67 | int test_evtchn(int port); |
| 68 | int test_and_set_mask(int port); |
| 69 | void mask_evtchn(int port); |
| 70 | void unmask_evtchn(int port); |
| 71 | |
| 72 | void xen_evtchn_handle_events(int cpu); |
| 73 | |
| 74 | #endif /* #ifndef __EVENTS_INTERNAL_H__ */ |