Skip to contentSkip to conversation

Patchset description

PATCH In review Ákos Kovács 3 participants 6 messages Aug 23, 2013

lore
Share & tools
lore
#0 lore raw

cover Patchset description

Patch 1: Move sysbus and PCI specific code to a new files from hw/usb/hcd-ohci.c.

Patch 2: Make them new configuration variables *_OHCI_SYSBUS and *_OHCI_PCI and add them to the arm and sh4 default configuration.

Patch 3: Create similar configuration variables for hcd-uhci-sysbus.c and hcd-uhci-pci.c as *_UHCI_SYSBUS and *_UHCI_PCI.

#1 lore raw

PATCH 1/3 hw/usb/hcd-ohci.c: Move sysbus and PCI code to new files

Move the existing sysbus and PCI logic to hcd-ohci-sysbus.c and hcd-ohci-pci.c from hcd-ohci.c. Create a new hcd-ohci.h header for the shared declarations and macros.

---
 hw/usb/hcd-ohci-pci.c    |   96 ++++++++++
 hw/usb/hcd-ohci-sysbus.c |   84 +++++++++
 hw/usb/hcd-ohci.c        |  434 +++-------------------------------------------
 hw/usb/hcd-ohci.h        |  311 +++++++++++++++++++++++++++++++++
 4 files changed, 514 insertions(+), 411 deletions(-)
 create mode 100644 hw/usb/hcd-ohci-pci.c
 create mode 100644 hw/usb/hcd-ohci-sysbus.c
 create mode 100644 hw/usb/hcd-ohci.h
hw/usb/hcd-ohci-pci.c new file +96 -0
new file mode 100644
index 0000000..ac50951
@@ -0,0 +1,96 @@
+/*
+ * QEMU USB OHCI Emulation
+ * Copyright (c) 2004 Gianni Tedesco
+ * Copyright (c) 2006 CodeSourcery
+ * Copyright (c) 2006 Openedhand Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * TODO:
+ *  o Isochronous transfers
+ *  o Allocate bandwidth in frames properly
+ *  o Disable timers when nothing needs to be done, or remove timer usage
+ *    all together.
+ *  o BIOS work to boot from USB storage
+*/
+
+#include "hw/usb/hcd-ohci.h"
+
+#define TYPE_PCI_OHCI "pci-ohci"
+#define PCI_OHCI(obj) OBJECT_CHECK(OHCIPCIState, (obj), TYPE_PCI_OHCI)
+
+typedef struct {
+    /*< private >*/
+    PCIDevice parent_obj;
+    /*< public >*/
+
+    OHCIState state;
+    char *masterbus;
+    uint32_t num_ports;
+    uint32_t firstport;
+} OHCIPCIState;
+
+static Property ohci_pci_properties[] = {
+    DEFINE_PROP_STRING("masterbus", OHCIPCIState, masterbus),
+    DEFINE_PROP_UINT32("num-ports", OHCIPCIState, num_ports, 3),
+    DEFINE_PROP_UINT32("firstport", OHCIPCIState, firstport, 0),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static int usb_ohci_initfn_pci(PCIDevice *dev)
+{
+    OHCIPCIState *ohci = PCI_OHCI(dev);
+
+    dev->config[PCI_CLASS_PROG] = 0x10; /* OHCI */
+    dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */
+
+    if (usb_ohci_init(&ohci->state, DEVICE(dev), ohci->num_ports, 0,
+                      ohci->masterbus, ohci->firstport,
+                      pci_get_address_space(dev)) != 0) {
+        return -1;
+    }
+    ohci->state.irq = dev->irq[0];
+
+    pci_register_bar(dev, 0, 0, &ohci->state.mem);
+    return 0;
+}
+
+static void ohci_pci_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+    k->init = usb_ohci_initfn_pci;
+    k->vendor_id = PCI_VENDOR_ID_APPLE;
+    k->device_id = PCI_DEVICE_ID_APPLE_IPID_USB;
+    k->class_id = PCI_CLASS_SERIAL_USB;
+    k->no_hotplug = 1;
+    set_bit(DEVICE_CATEGORY_USB, dc->categories);
+    dc->desc = "Apple USB Controller";
+    dc->props = ohci_pci_properties;
+}
+
+static const TypeInfo ohci_pci_info = {
+    .name          = TYPE_PCI_OHCI,
+    .parent        = TYPE_PCI_DEVICE,
+    .instance_size = sizeof(OHCIPCIState),
+    .class_init    = ohci_pci_class_init,
+};
+
+static void ohci_pci_register_type(void)
+{
+    type_register_static(&ohci_pci_info);
+}
+
+type_init(ohci_pci_register_type)
hw/usb/hcd-ohci-sysbus.c new file +84 -0

84 lines not on this page · raw message

hw/usb/hcd-ohci.c +23 -411

456 lines not on this page · raw message

hw/usb/hcd-ohci.h new file +311 -0

311 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] hw/usb/hcd-ohci.c: Move sysbus and PCI code to new files

Am 23.08.2013 03:18, schrieb Ákos Kovács:

Quoted 47 lines

Move the existing sysbus and PCI logic to hcd-ohci-sysbus.c and hcd-ohci-pci.c from hcd-ohci.c. Create a new hcd-ohci.h header for the shared declarations and macros.

---
 hw/usb/hcd-ohci-pci.c    |   96 ++++++++++
 hw/usb/hcd-ohci-sysbus.c |   84 +++++++++
 hw/usb/hcd-ohci.c        |  434 +++-------------------------------------------
 hw/usb/hcd-ohci.h        |  311 +++++++++++++++++++++++++++++++++
 4 files changed, 514 insertions(+), 411 deletions(-)
 create mode 100644 hw/usb/hcd-ohci-pci.c
 create mode 100644 hw/usb/hcd-ohci-sysbus.c
 create mode 100644 hw/usb/hcd-ohci.h
hw/usb/hcd-ohci-pci.c new file +26 -0
new file mode 100644
index 0000000..ac50951
@@ -0,0 +1,96 @@
+/*
+ * QEMU USB OHCI Emulation
+ * Copyright (c) 2004 Gianni Tedesco
+ * Copyright (c) 2006 CodeSourcery
+ * Copyright (c) 2006 Openedhand Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * TODO:
+ *  o Isochronous transfers
+ *  o Allocate bandwidth in frames properly
+ *  o Disable timers when nothing needs to be done, or remove timer usage
+ *    all together.
+ *  o BIOS work to boot from USB storage
+*/

[...]

Quoted 32 lines
hw/usb/hcd-ohci-sysbus.c new file +26 -0
new file mode 100644
index 0000000..b9d15db
@@ -0,0 +1,84 @@
+/*
+ * QEMU USB OHCI Emulation
+ * Copyright (c) 2004 Gianni Tedesco
+ * Copyright (c) 2006 CodeSourcery
+ * Copyright (c) 2006 Openedhand Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * TODO:
+ *  o Isochronous transfers
+ *  o Allocate bandwidth in frames properly
+ *  o Disable timers when nothing needs to be done, or remove timer usage
+ *    all together.
+ *  o BIOS work to boot from USB storage
+*/

[...]

Quoted 22 lines
hw/usb/hcd-ohci.h new file +16 -0
new file mode 100644
index 0000000..8be00f2
@@ -0,0 +1,311 @@
+/*
+ * QEMU USB OHCI Emulation
+ * Copyright (c) 2004 Gianni Tedesco
+ * Copyright (c) 2006 CodeSourcery
+ * Copyright (c) 2006 Openedhand Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *

hw/usb/hcd-ohci.h line 26

Quoted 10 lines
hw/usb/hcd-ohci.h new file +10 -0
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * TODO:
+ *  o Isochronous transfers
+ *  o Allocate bandwidth in frames properly
+ *  o Disable timers when nothing needs to be done, or remove timer usage
+ *    all together.
+ *  o BIOS work to boot from USB storage
+*/

Is it really a good idea to duplicate the TODO list into four files? I assume points 1-3 affect the core code that is not moving, so that all four points could stay in hcd-ohci.c. No one is going to remember to sync it otherwise.

Also there should probably be a space before */ for alignment. :)

When I create new files I usually add an up-to-date copyright line, not sure if that's applicable here, depending on amount of changes.

The split itself seems like a good idea, thanks.

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw

PATCH 2/3 hw/usb/Makefile.objs: Make config options for ohci-pci

In reply to Ákos Kovács

Create CONFIG_USB_OHCI_PCI and CONFIG_USB_OHCI_SYSBUS configuration options for the new hcd-ohci-pci.c and hcd-ohci-sysbus.c files.

Add CONFIG_USB_OHCI_PCI to default-configs/{arm,sh4}-softmmu.mak.

---
 default-configs/arm-softmmu.mak |    2 ++
 default-configs/sh4-softmmu.mak |    1 +
 hw/usb/Makefile.objs            |    2 ++
 3 files changed, 5 insertions(+)
default-configs/arm-softmmu.mak +2 -0
index ac0815d..899f560 100644
@@ -80,3 +80,5 @@ CONFIG_VERSATILE_PCI=y
 CONFIG_VERSATILE_I2C=y
 
 CONFIG_SDHCI=y
+
+CONFIG_USB_OHCI_SYSBUS=y
default-configs/sh4-softmmu.mak +1 -0
index 8e00390..11ed0e3 100644
@@ -16,3 +16,4 @@ CONFIG_PCSPK=y
 CONFIG_I82374=y
 CONFIG_I8257=y
 CONFIG_MC146818RTC=y
+CONFIG_USB_OHCI_SYSBUS=y
hw/usb/Makefile.objs +2 -0
index f9695e7..2eba141 100644
@@ -5,6 +5,8 @@ common-obj-y += libhw.o
 # usb host adapters
 common-obj-$(CONFIG_USB_UHCI) += hcd-uhci.o
 common-obj-$(CONFIG_USB_OHCI) += hcd-ohci.o
+common-obj-$(CONFIG_USB_OHCI_SYSBUS) += hcd-ohci-sysbus.o
+common-obj-$(CONFIG_USB_OHCI_PCI) += hcd-ohci-pci.o
 common-obj-$(CONFIG_USB_EHCI) += hcd-ehci.o hcd-ehci-pci.o hcd-ehci-sysbus.o
 common-obj-$(CONFIG_USB_XHCI) += hcd-xhci.o
 common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 3/3 Makefile.objs: Split CONFIG_USB_EHCI

In reply to Ákos Kovács

Create new configuration variables, CONFIG_USB_EHCI_SYSBUS and CONFIG_USB_EHCI_PCI for hcd-ehci-sysbus.o and hcd-ehci-pci.o.

Make CONFIG_USB_EHCI_SYSBUS default for arm-softmmu.mak.

---
 default-configs/arm-softmmu.mak |    1 +
 hw/usb/Makefile.objs            |    4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
default-configs/arm-softmmu.mak +1 -0
index 899f560..6a43d1a 100644
@@ -82,3 +82,4 @@ CONFIG_VERSATILE_I2C=y
 CONFIG_SDHCI=y
 
 CONFIG_USB_OHCI_SYSBUS=y
+CONFIG_USB_EHCI_SYSBUS=y
hw/usb/Makefile.objs +3 -1
index 2eba141..3e0526e 100644
@@ -7,7 +7,9 @@ common-obj-$(CONFIG_USB_UHCI) += hcd-uhci.o
 common-obj-$(CONFIG_USB_OHCI) += hcd-ohci.o
 common-obj-$(CONFIG_USB_OHCI_SYSBUS) += hcd-ohci-sysbus.o
 common-obj-$(CONFIG_USB_OHCI_PCI) += hcd-ohci-pci.o
-common-obj-$(CONFIG_USB_EHCI) += hcd-ehci.o hcd-ehci-pci.o hcd-ehci-sysbus.o
+common-obj-$(CONFIG_USB_EHCI) += hcd-ehci.o
+common-obj-$(CONFIG_USB_EHCI_SYSBUS) += hcd-ehci-sysbus.o
+common-obj-$(CONFIG_USB_EHCI_PCI) += hcd-ehci-pci.o
 common-obj-$(CONFIG_USB_XHCI) += hcd-xhci.o
 common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o
 
Signature · 1 line
1.7.10.4
#5 lore raw
In reply to Ákos Kovács
Quoted 1 line · Ákos Kovács

Patch 1: Move sysbus and PCI specific code to a new files from hw/usb/hcd-ohci.c.

Looks good, except that it breaks ohci due to not compiling the new files.

Quoted 5 lines

Patch 2: Make them new configuration variables *_OHCI_SYSBUS and *_OHCI_PCI and add them to the arm and sh4 default configuration.

Patch 3: Create similar configuration variables for hcd-uhci-sysbus.c and hcd-uhci-pci.c as *_UHCI_SYSBUS and *_UHCI_PCI.

Hmm, I think doing this fine-grained config should wait until we have Kconfig, so we can create proper dependencies for this.

cheers,
Gerd