Patchwork [v2,2/8] qdev: export qdev_reset() for later use.

login
register
mail settings
Submitter Isaku Yamahata
Date Aug. 5, 2010, 2:08 a.m.
Message ID <ea1251f424236c64a2967b267110b3d41b0ef5fa.1280973617.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/60920/
State New
Headers show

Comments

Isaku Yamahata - Aug. 5, 2010, 2:08 a.m.
export qdev_reset() for later use.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/qdev.c |   29 +++++++++++++++++++++++++----
 hw/qdev.h |    1 +
 2 files changed, 26 insertions(+), 4 deletions(-)

Patch

diff --git a/hw/qdev.c b/hw/qdev.c
index e99c73f..322b315 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -256,13 +256,34 @@  DeviceState *qdev_device_add(QemuOpts *opts)
     return qdev;
 }
 
-static void qdev_reset(void *opaque)
+/*
+ * reset the device.
+ * Bring the device into initial known state (to some extent)
+ * on warm reset(system reset).
+ * Typically on system reset(or power-on reset), bus reset occurs on
+ * each bus which causes devices to reset.
+ * This reset doesn't include software reset which is triggered by
+ * issuing reset command. Those device reset would be implemented in a bus
+ * specific way.
+ *
+ * For example
+ * PCI: reset with RST# signal asserted. Not FLR of advanced feature capability
+ * PCIe: conventional reset. Not FLR.
+ * ATA: hardware reset with RESET- signal asserted. Not DEVICE RESET command.
+ * SCSI: hard reset with SCSI RST signal asserted.
+ *       Not bus device reset message.
+ */
+void qdev_reset(DeviceState *dev)
 {
-    DeviceState *dev = opaque;
     if (dev->info->reset)
         dev->info->reset(dev);
 }
 
+static void qdev_reset_fn(void *opaque)
+{
+    qdev_reset(opaque);
+}
+
 /* Initialize a device.  Device properties should be set before calling
    this function.  IRQs and MMIO regions should be connected/mapped after
    calling this function.
@@ -278,7 +299,7 @@  int qdev_init(DeviceState *dev)
         qdev_free(dev);
         return rc;
     }
-    qemu_register_reset(qdev_reset, dev);
+    qemu_register_reset(qdev_reset_fn, dev);
     if (dev->info->vmsd) {
         vmstate_register_with_alias_id(dev, -1, dev->info->vmsd, dev,
                                        dev->instance_id_alias,
@@ -350,7 +371,7 @@  void qdev_free(DeviceState *dev)
         if (dev->opts)
             qemu_opts_del(dev->opts);
     }
-    qemu_unregister_reset(qdev_reset, dev);
+    qemu_unregister_reset(qdev_reset_fn, dev);
     QLIST_REMOVE(dev, sibling);
     for (prop = dev->info->props; prop && prop->name; prop++) {
         if (prop->info->free) {
diff --git a/hw/qdev.h b/hw/qdev.h
index 678f8b7..10f6769 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -162,6 +162,7 @@  struct DeviceInfo {
 extern DeviceInfo *device_info_list;
 
 void qdev_register(DeviceInfo *info);
+void qdev_reset(DeviceState *dev);
 
 /* Register device properties.  */
 /* GPIO inputs also double as IRQ sinks.  */