mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20150609.0' into staging
Initial VFIO platform device support, v2 (Eric Auger, et al.) # gpg: Signature made Tue Jun 9 15:25:40 2015 BST using RSA key ID 3BB08B22 # gpg: Good signature from "Alex Williamson <alex.williamson@redhat.com>" # gpg: aka "Alex Williamson <alex@shazbot.org>" # gpg: aka "Alex Williamson <alwillia@redhat.com>" # gpg: aka "Alex Williamson <alex.l.williamson@gmail.com>" * remotes/awilliam/tags/vfio-update-20150609.0: hw/vfio/platform: calxeda xgmac device hw/vfio/platform: add irq assignment hw/vfio/platform: vfio-platform skeleton Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
ifeq ($(CONFIG_LINUX), y)
|
||||
obj-$(CONFIG_SOFTMMU) += common.o
|
||||
obj-$(CONFIG_PCI) += pci.o
|
||||
obj-$(CONFIG_SOFTMMU) += platform.o
|
||||
obj-$(CONFIG_SOFTMMU) += calxeda-xgmac.o
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* calxeda xgmac VFIO device
|
||||
*
|
||||
* Copyright Linaro Limited, 2014
|
||||
*
|
||||
* Authors:
|
||||
* Eric Auger <eric.auger@linaro.org>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2. See
|
||||
* the COPYING file in the top-level directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hw/vfio/vfio-calxeda-xgmac.h"
|
||||
|
||||
static void calxeda_xgmac_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev);
|
||||
VFIOCalxedaXgmacDeviceClass *k = VFIO_CALXEDA_XGMAC_DEVICE_GET_CLASS(dev);
|
||||
|
||||
vdev->compat = g_strdup("calxeda,hb-xgmac");
|
||||
|
||||
k->parent_realize(dev, errp);
|
||||
}
|
||||
|
||||
static const VMStateDescription vfio_platform_calxeda_xgmac_vmstate = {
|
||||
.name = TYPE_VFIO_CALXEDA_XGMAC,
|
||||
.unmigratable = 1,
|
||||
};
|
||||
|
||||
static void vfio_calxeda_xgmac_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
VFIOCalxedaXgmacDeviceClass *vcxc =
|
||||
VFIO_CALXEDA_XGMAC_DEVICE_CLASS(klass);
|
||||
vcxc->parent_realize = dc->realize;
|
||||
dc->realize = calxeda_xgmac_realize;
|
||||
dc->desc = "VFIO Calxeda XGMAC";
|
||||
dc->vmsd = &vfio_platform_calxeda_xgmac_vmstate;
|
||||
}
|
||||
|
||||
static const TypeInfo vfio_calxeda_xgmac_dev_info = {
|
||||
.name = TYPE_VFIO_CALXEDA_XGMAC,
|
||||
.parent = TYPE_VFIO_PLATFORM,
|
||||
.instance_size = sizeof(VFIOCalxedaXgmacDevice),
|
||||
.class_init = vfio_calxeda_xgmac_class_init,
|
||||
.class_size = sizeof(VFIOCalxedaXgmacDeviceClass),
|
||||
};
|
||||
|
||||
static void register_calxeda_xgmac_dev_type(void)
|
||||
{
|
||||
type_register_static(&vfio_calxeda_xgmac_dev_info);
|
||||
}
|
||||
|
||||
type_init(register_calxeda_xgmac_dev_type)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* VFIO calxeda xgmac device
|
||||
*
|
||||
* Copyright Linaro Limited, 2014
|
||||
*
|
||||
* Authors:
|
||||
* Eric Auger <eric.auger@linaro.org>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2. See
|
||||
* the COPYING file in the top-level directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HW_VFIO_VFIO_CALXEDA_XGMAC_H
|
||||
#define HW_VFIO_VFIO_CALXEDA_XGMAC_H
|
||||
|
||||
#include "hw/vfio/vfio-platform.h"
|
||||
|
||||
#define TYPE_VFIO_CALXEDA_XGMAC "vfio-calxeda-xgmac"
|
||||
|
||||
/**
|
||||
* This device exposes:
|
||||
* - a single MMIO region corresponding to its register space
|
||||
* - 3 IRQS (main and 2 power related IRQs)
|
||||
*/
|
||||
typedef struct VFIOCalxedaXgmacDevice {
|
||||
VFIOPlatformDevice vdev;
|
||||
} VFIOCalxedaXgmacDevice;
|
||||
|
||||
typedef struct VFIOCalxedaXgmacDeviceClass {
|
||||
/*< private >*/
|
||||
VFIOPlatformDeviceClass parent_class;
|
||||
/*< public >*/
|
||||
DeviceRealize parent_realize;
|
||||
} VFIOCalxedaXgmacDeviceClass;
|
||||
|
||||
#define VFIO_CALXEDA_XGMAC_DEVICE(obj) \
|
||||
OBJECT_CHECK(VFIOCalxedaXgmacDevice, (obj), TYPE_VFIO_CALXEDA_XGMAC)
|
||||
#define VFIO_CALXEDA_XGMAC_DEVICE_CLASS(klass) \
|
||||
OBJECT_CLASS_CHECK(VFIOCalxedaXgmacDeviceClass, (klass), \
|
||||
TYPE_VFIO_CALXEDA_XGMAC)
|
||||
#define VFIO_CALXEDA_XGMAC_DEVICE_GET_CLASS(obj) \
|
||||
OBJECT_GET_CLASS(VFIOCalxedaXgmacDeviceClass, (obj), \
|
||||
TYPE_VFIO_CALXEDA_XGMAC)
|
||||
|
||||
#endif
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
enum {
|
||||
VFIO_DEVICE_TYPE_PCI = 0,
|
||||
VFIO_DEVICE_TYPE_PLATFORM = 1,
|
||||
};
|
||||
|
||||
typedef struct VFIORegion {
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* vfio based device assignment support - platform devices
|
||||
*
|
||||
* Copyright Linaro Limited, 2014
|
||||
*
|
||||
* Authors:
|
||||
* Kim Phillips <kim.phillips@linaro.org>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2. See
|
||||
* the COPYING file in the top-level directory.
|
||||
*
|
||||
* Based on vfio based PCI device assignment support:
|
||||
* Copyright Red Hat, Inc. 2012
|
||||
*/
|
||||
|
||||
#ifndef HW_VFIO_VFIO_PLATFORM_H
|
||||
#define HW_VFIO_VFIO_PLATFORM_H
|
||||
|
||||
#include "hw/sysbus.h"
|
||||
#include "hw/vfio/vfio-common.h"
|
||||
#include "qemu/event_notifier.h"
|
||||
#include "qemu/queue.h"
|
||||
#include "hw/irq.h"
|
||||
|
||||
#define TYPE_VFIO_PLATFORM "vfio-platform"
|
||||
|
||||
enum {
|
||||
VFIO_IRQ_INACTIVE = 0,
|
||||
VFIO_IRQ_PENDING = 1,
|
||||
VFIO_IRQ_ACTIVE = 2,
|
||||
/* VFIO_IRQ_ACTIVE_AND_PENDING cannot happen with VFIO */
|
||||
};
|
||||
|
||||
typedef struct VFIOINTp {
|
||||
QLIST_ENTRY(VFIOINTp) next; /* entry for IRQ list */
|
||||
QSIMPLEQ_ENTRY(VFIOINTp) pqnext; /* entry for pending IRQ queue */
|
||||
EventNotifier interrupt; /* eventfd triggered on interrupt */
|
||||
EventNotifier unmask; /* eventfd for unmask on QEMU bypass */
|
||||
qemu_irq qemuirq;
|
||||
struct VFIOPlatformDevice *vdev; /* back pointer to device */
|
||||
int state; /* inactive, pending, active */
|
||||
uint8_t pin; /* index */
|
||||
uint32_t flags; /* IRQ info flags */
|
||||
} VFIOINTp;
|
||||
|
||||
/* function type for user side eventfd handler */
|
||||
typedef void (*eventfd_user_side_handler_t)(VFIOINTp *intp);
|
||||
|
||||
typedef struct VFIOPlatformDevice {
|
||||
SysBusDevice sbdev;
|
||||
VFIODevice vbasedev; /* not a QOM object */
|
||||
VFIORegion **regions;
|
||||
QLIST_HEAD(, VFIOINTp) intp_list; /* list of IRQs */
|
||||
/* queue of pending IRQs */
|
||||
QSIMPLEQ_HEAD(pending_intp_queue, VFIOINTp) pending_intp_queue;
|
||||
char *compat; /* compatibility string */
|
||||
uint32_t mmap_timeout; /* delay to re-enable mmaps after interrupt */
|
||||
QEMUTimer *mmap_timer; /* allows fast-path resume after IRQ hit */
|
||||
QemuMutex intp_mutex; /* protect the intp_list IRQ state */
|
||||
} VFIOPlatformDevice;
|
||||
|
||||
typedef struct VFIOPlatformDeviceClass {
|
||||
/*< private >*/
|
||||
SysBusDeviceClass parent_class;
|
||||
/*< public >*/
|
||||
} VFIOPlatformDeviceClass;
|
||||
|
||||
#define VFIO_PLATFORM_DEVICE(obj) \
|
||||
OBJECT_CHECK(VFIOPlatformDevice, (obj), TYPE_VFIO_PLATFORM)
|
||||
#define VFIO_PLATFORM_DEVICE_CLASS(klass) \
|
||||
OBJECT_CLASS_CHECK(VFIOPlatformDeviceClass, (klass), TYPE_VFIO_PLATFORM)
|
||||
#define VFIO_PLATFORM_DEVICE_GET_CLASS(obj) \
|
||||
OBJECT_GET_CLASS(VFIOPlatformDeviceClass, (obj), TYPE_VFIO_PLATFORM)
|
||||
|
||||
#endif /*HW_VFIO_VFIO_PLATFORM_H*/
|
||||
@@ -1564,6 +1564,18 @@ vfio_put_group(int fd) "close group->fd=%d"
|
||||
vfio_get_device(const char * name, unsigned int flags, unsigned int num_regions, unsigned int num_irqs) "Device %s flags: %u, regions: %u, irqs: %u"
|
||||
vfio_put_base_device(int fd) "close vdev->fd=%d"
|
||||
|
||||
# hw/vfio/platform.c
|
||||
vfio_platform_populate_regions(int region_index, unsigned long flag, unsigned long size, int fd, unsigned long offset) "- region %d flags = 0x%lx, size = 0x%lx, fd= %d, offset = 0x%lx"
|
||||
vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d"
|
||||
vfio_platform_realize(char *name, char *compat) "vfio device %s, compat = %s"
|
||||
vfio_platform_eoi(int pin, int fd) "EOI IRQ pin %d (fd=%d)"
|
||||
vfio_platform_mmap_set_enabled(bool enabled) "fast path = %d"
|
||||
vfio_platform_intp_mmap_enable(int pin) "IRQ #%d still active, stay in slow path"
|
||||
vfio_platform_intp_interrupt(int pin, int fd) "Inject IRQ #%d (fd = %d)"
|
||||
vfio_platform_intp_inject_pending_lockheld(int pin, int fd) "Inject pending IRQ #%d (fd = %d)"
|
||||
vfio_platform_populate_interrupts(int pin, int count, int flags) "- IRQ index %d: count %d, flags=0x%x"
|
||||
vfio_intp_interrupt_set_pending(int index) "irq %d is set PENDING"
|
||||
|
||||
#hw/acpi/memory_hotplug.c
|
||||
mhp_acpi_invalid_slot_selected(uint32_t slot) "0x%"PRIx32
|
||||
mhp_acpi_ejecting_invalid_slot(uint32_t slot) "0x%"PRIx32
|
||||
|
||||
Reference in New Issue
Block a user