[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 4/8] usb/ehci: Add usb-ehci-sysbus
From: |
Peter Crosthwaite |
Subject: |
[Qemu-devel] [PATCH v1 4/8] usb/ehci: Add usb-ehci-sysbus |
Date: |
Thu, 25 Oct 2012 19:47:15 +1000 |
Add QOM device definition for sysbus attached EHCI.
Signed-off-by: Peter Crosthwaite <address@hidden>
---
hw/usb/hcd-ehci.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 52 insertions(+), 1 deletions(-)
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 862564c..17482f7 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -35,6 +35,8 @@
#include "trace.h"
#include "dma.h"
#include "sysemu.h"
+#include "hw/sysbus.h"
+#include "exec-memory.h"
#define EHCI_DEBUG 0
@@ -446,7 +448,13 @@ struct EHCIState {
};
typedef struct EHCIItfState {
- PCIDevice pcidev;
+ /* FIXME: Figure out a better way to share one Property[] array between two
+ * QOM types with different parents
+ */
+ union {
+ PCIDevice pcidev;
+ SysBusDevice busdev;
+ };
struct EHCIState ehci;
} EHCIItfState;
@@ -2544,6 +2552,7 @@ static const MemoryRegionOps ehci_mmio_port_ops = {
};
static int usb_ehci_pci_initfn(PCIDevice *dev);
+static int usb_ehci_sysbus_initfn(SysBusDevice *dev);
static USBPortOps ehci_port_ops = {
.attach = ehci_attach,
@@ -2699,6 +2708,32 @@ static TypeInfo ich9_ehci_info = {
.class_init = ich9_ehci_class_init,
};
+static const VMStateDescription vmstate_ehci_sysbus = {
+ .name = "ehci-sysbus",
+ .version_id = 3,
+ .minimum_version_id = 2,
+ .fields = (VMStateField[]) {
+ VMSTATE_STRUCT(ehci, EHCIItfState, 3, vmstate_ehci, EHCIState),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+static void ehci_sysbus_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+
+ k->init = usb_ehci_sysbus_initfn;
+ dc->vmsd = &vmstate_ehci_sysbus;
+ dc->props = ehci_properties;
+}
+
+static TypeInfo ehci_sysbus_info = {
+ .name = "ehci-sysbus",
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(EHCIItfState),
+ .class_init = ehci_sysbus_class_init,
+};
static void usb_ehci_initfn(EHCIState *s, DeviceState *dev)
{
@@ -2750,6 +2785,21 @@ static void usb_ehci_initfn(EHCIState *s, DeviceState
*dev)
&s->mem_ports);
}
+static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
+{
+ EHCIItfState *i = FROM_SYSBUS(EHCIItfState, dev);
+ EHCIState *s = &i->ehci;
+
+ s->dma = g_new(DMAContext, 1);
+ dma_context_init(s->dma, &address_space_memory, NULL, NULL, NULL);
+
+ usb_ehci_initfn(s, DEVICE(dev));
+ sysbus_init_irq(dev, &s->irq);
+ sysbus_init_mmio(dev, &s->mem);
+
+ return 0;
+}
+
static int usb_ehci_pci_initfn(PCIDevice *dev)
{
EHCIItfState *i = DO_UPCAST(EHCIItfState, pcidev, dev);
@@ -2798,6 +2848,7 @@ static void ehci_register_types(void)
{
type_register_static(&ehci_pci_info);
type_register_static(&ich9_ehci_info);
+ type_register_static(&ehci_sysbus_info);
}
type_init(ehci_register_types)
--
1.7.0.4
[Qemu-devel] [PATCH v1 4/8] usb/ehci: Add usb-ehci-sysbus,
Peter Crosthwaite <=
[Qemu-devel] [PATCH v1 8/8] usb/ehci: Put RAM in undefined MMIO regions, Peter Crosthwaite, 2012/10/25