@@ -26,6 +26,7 @@
*/
#include "hw/qdev-core.h"
+#include "hw/usb/usb.h"
#include "qemu/iov.h"
#include "qemu/queue.h"
@@ -176,7 +177,6 @@
typedef struct USBBus USBBus;
typedef struct USBBusOps USBBusOps;
typedef struct USBPort USBPort;
-typedef struct USBDevice USBDevice;
typedef struct USBPacket USBPacket;
typedef struct USBCombinedPacket USBCombinedPacket;
typedef struct USBEndpoint USBEndpoint;
@@ -256,9 +256,6 @@ struct USBDevice {
const USBDescIface *ifaces[USB_MAX_INTERFACES];
};
-#define TYPE_USB_DEVICE "usb-device"
-#define USB_DEVICE(obj) \
- OBJECT_CHECK(USBDevice, (obj), TYPE_USB_DEVICE)
#define USB_DEVICE_CLASS(klass) \
OBJECT_CLASS_CHECK(USBDeviceClass, (klass), TYPE_USB_DEVICE)
#define USB_DEVICE_GET_CLASS(obj) \
@@ -459,15 +456,8 @@ void usb_device_reset(USBDevice *dev);
void usb_wakeup(USBEndpoint *ep, unsigned int stream);
void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p);
-/* usb-linux.c */
-void hmp_info_usbhost(Monitor *mon, const QDict *qdict);
-bool usb_host_dev_is_scsi_storage(USBDevice *usbdev);
-
/* usb-bus.c */
-#define TYPE_USB_BUS "usb-bus"
-#define USB_BUS(obj) OBJECT_CHECK(USBBus, (obj), TYPE_USB_BUS)
-
struct USBBus {
BusState qbus;
USBBusOps *ops;
@@ -489,13 +479,8 @@ struct USBBusOps {
void usb_bus_new(USBBus *bus, size_t bus_size,
USBBusOps *ops, DeviceState *host);
void usb_bus_release(USBBus *bus);
-USBBus *usb_bus_find(int busnr);
void usb_legacy_register(const char *typename, const char *usbdevice_name,
USBDevice *(*usbdevice_init)(const char *params));
-USBDevice *usb_new(const char *name);
-bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp);
-USBDevice *usb_create_simple(USBBus *bus, const char *name);
-USBDevice *usbdevice_create(const char *cmdline);
void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
USBPortOps *ops, int speedmask);
void usb_register_companion(const char *masterbus, USBPort *ports[],
@@ -506,16 +491,6 @@ void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);
void usb_unregister_port(USBBus *bus, USBPort *port);
void usb_claim_port(USBDevice *dev, Error **errp);
void usb_release_port(USBDevice *dev);
-/**
- * usb_get_port_path:
- * @dev: the USB device
- *
- * The returned data must be released with g_free()
- * when no longer required.
- *
- * Returns: a dynamically allocated pathname.
- */
-char *usb_get_port_path(USBDevice *dev);
void usb_device_attach(USBDevice *dev, Error **errp);
int usb_device_detach(USBDevice *dev);
void usb_check_attach(USBDevice *dev, Error **errp);
new file mode 100644
@@ -0,0 +1,58 @@
+/*
+ * QEMU USB API
+ *
+ * Copyright (c) 2005 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#ifndef QEMU_HW_USB_H
+#define QEMU_HW_USB_H
+
+typedef struct USBDevice USBDevice;
+
+#define TYPE_USB_DEVICE "usb-device"
+#define USB_DEVICE(obj) \
+ OBJECT_CHECK(USBDevice, (obj), TYPE_USB_DEVICE)
+
+typedef struct USBBus USBBus;
+
+#define TYPE_USB_BUS "usb-bus"
+#define USB_BUS(obj) OBJECT_CHECK(USBBus, (obj), TYPE_USB_BUS)
+
+USBBus *usb_bus_find(int busnr);
+USBDevice *usb_new(const char *name);
+bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp);
+USBDevice *usb_create_simple(USBBus *bus, const char *name);
+USBDevice *usbdevice_create(const char *cmdline);
+
+/**
+ * usb_get_port_path:
+ * @dev: the USB device
+ *
+ * The returned data must be released with g_free()
+ * when no longer required.
+ *
+ * Returns: a dynamically allocated pathname.
+ */
+char *usb_get_port_path(USBDevice *dev);
+
+void hmp_info_usbhost(Monitor *mon, const QDict *qdict);
+bool usb_host_dev_is_scsi_storage(USBDevice *usbdev);
+
+#endif
@@ -28,7 +28,7 @@
#include "qemu/main-loop.h"
#include "qemu/module.h"
#include "qemu/timer.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
#include "ui/console.h"
#include <brlapi.h>
#include <brlapi_constants.h>
@@ -83,7 +83,7 @@
#include "qapi/qapi-visit-common.h"
#include "qapi/visitor.h"
#include "hw/core/cpu.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
#include "hw/i386/intel_iommu.h"
#include "hw/net/ne2000-isa.h"
#include "standard-headers/asm-x86/bootparam.h"
@@ -36,7 +36,7 @@
#include "hw/firmware/smbios.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_ids.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
#include "net/net.h"
#include "hw/ide/pci.h"
#include "hw/irq.h"
@@ -50,7 +50,7 @@
#include "hw/firmware/smbios.h"
#include "hw/ide/pci.h"
#include "hw/ide/ahci.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "sysemu/numa.h"
@@ -69,7 +69,7 @@
#include "sysemu/kvm.h"
#include "sysemu/reset.h"
#include "kvm_ppc.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
#include "exec/address-spaces.h"
#include "hw/sysbus.h"
#include "trace.h"
@@ -35,6 +35,7 @@
#include "hw/char/serial.h"
#include "hw/i2c/ppc4xx_i2c.h"
#include "hw/i2c/smbus_eeprom.h"
+#include "hw/usb/usb.h"
#include "hw/usb/hcd-ehci.h"
#include "hw/ppc/fdt.h"
#include "hw/qdev-properties.h"
@@ -70,7 +70,7 @@
#include "exec/address-spaces.h"
#include "exec/ram_addr.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
#include "trace.h"
@@ -40,7 +40,7 @@
#include "hw/ide.h"
#include "hw/irq.h"
#include "hw/loader.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
#include "hw/block/flash.h"
#include "exec/address-spaces.h"
@@ -32,7 +32,7 @@
#include "qemu/osdep.h"
#include "ui/console.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
#include "monitor/monitor.h"
void hmp_info_usbhost(Monitor *mon, const QDict *qdict)
@@ -26,7 +26,7 @@
#include "monitor-internal.h"
#include "cpu.h"
#include "monitor/qdev.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
#include "hw/pci/pci.h"
#include "sysemu/watchdog.h"
#include "hw/loader.h"
@@ -41,7 +41,7 @@
#include "qemu/error-report.h"
#include "qemu/sockets.h"
#include "sysemu/accel.h"
-#include "hw/usb.h"
+#include "hw/usb/usb.h"
#include "hw/isa/isa.h"
#include "hw/scsi/scsi.h"
#include "hw/display/vga.h"
Only the USB devices require to access the USB internal APIs. The rest of the code base only wants to consume USB devices with a generic API. Move the generic declarations to the new "hw/usb/usb.h" header. Reported-by: BALATON Zoltan <balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- include/hw/usb.h | 27 +------------------- include/hw/usb/usb.h | 58 +++++++++++++++++++++++++++++++++++++++++++ chardev/baum.c | 2 +- hw/i386/pc.c | 2 +- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/sam460ex.c | 1 + hw/ppc/spapr.c | 2 +- hw/sh4/r2d.c | 2 +- hw/usb/host-stub.c | 2 +- monitor/misc.c | 2 +- softmmu/vl.c | 2 +- 13 files changed, 70 insertions(+), 36 deletions(-) create mode 100644 include/hw/usb/usb.h