@@ -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) {
@@ -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. */
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(-)