MAINTAINERS: Make section QOM cover hw/core/*bus.c as well
[qemu/armbru.git] / include / hw / vfio / vfio-platform.h
blob4ec70c813a2ce69cd543048de19df342427ce313
1 /*
2 * vfio based device assignment support - platform devices
4 * Copyright Linaro Limited, 2014
6 * Authors:
7 * Kim Phillips <kim.phillips@linaro.org>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
12 * Based on vfio based PCI device assignment support:
13 * Copyright Red Hat, Inc. 2012
16 #ifndef HW_VFIO_VFIO_PLATFORM_H
17 #define HW_VFIO_VFIO_PLATFORM_H
19 #include "hw/sysbus.h"
20 #include "hw/vfio/vfio-common.h"
21 #include "qemu/event_notifier.h"
22 #include "qemu/queue.h"
24 #define TYPE_VFIO_PLATFORM "vfio-platform"
26 enum {
27 VFIO_IRQ_INACTIVE = 0,
28 VFIO_IRQ_PENDING = 1,
29 VFIO_IRQ_ACTIVE = 2,
30 /* VFIO_IRQ_ACTIVE_AND_PENDING cannot happen with VFIO */
33 typedef struct VFIOINTp {
34 QLIST_ENTRY(VFIOINTp) next; /* entry for IRQ list */
35 QSIMPLEQ_ENTRY(VFIOINTp) pqnext; /* entry for pending IRQ queue */
36 EventNotifier *interrupt; /* eventfd triggered on interrupt */
37 EventNotifier *unmask; /* eventfd for unmask on QEMU bypass */
38 qemu_irq qemuirq;
39 struct VFIOPlatformDevice *vdev; /* back pointer to device */
40 int state; /* inactive, pending, active */
41 uint8_t pin; /* index */
42 uint32_t flags; /* IRQ info flags */
43 bool kvm_accel; /* set when QEMU bypass through KVM enabled */
44 } VFIOINTp;
46 /* function type for user side eventfd handler */
47 typedef void (*eventfd_user_side_handler_t)(VFIOINTp *intp);
49 typedef struct VFIOPlatformDevice {
50 SysBusDevice sbdev;
51 VFIODevice vbasedev; /* not a QOM object */
52 VFIORegion **regions;
53 QLIST_HEAD(, VFIOINTp) intp_list; /* list of IRQs */
54 /* queue of pending IRQs */
55 QSIMPLEQ_HEAD(, VFIOINTp) pending_intp_queue;
56 char *compat; /* DT compatible values, separated by NUL */
57 unsigned int num_compat; /* number of compatible values */
58 uint32_t mmap_timeout; /* delay to re-enable mmaps after interrupt */
59 QEMUTimer *mmap_timer; /* allows fast-path resume after IRQ hit */
60 QemuMutex intp_mutex; /* protect the intp_list IRQ state */
61 bool irqfd_allowed; /* debug option to force irqfd on/off */
62 } VFIOPlatformDevice;
64 typedef struct VFIOPlatformDeviceClass {
65 /*< private >*/
66 SysBusDeviceClass parent_class;
67 /*< public >*/
68 } VFIOPlatformDeviceClass;
70 #define VFIO_PLATFORM_DEVICE(obj) \
71 OBJECT_CHECK(VFIOPlatformDevice, (obj), TYPE_VFIO_PLATFORM)
72 #define VFIO_PLATFORM_DEVICE_CLASS(klass) \
73 OBJECT_CLASS_CHECK(VFIOPlatformDeviceClass, (klass), TYPE_VFIO_PLATFORM)
74 #define VFIO_PLATFORM_DEVICE_GET_CLASS(obj) \
75 OBJECT_GET_CLASS(VFIOPlatformDeviceClass, (obj), TYPE_VFIO_PLATFORM)
77 #endif /* HW_VFIO_VFIO_PLATFORM_H */