qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH v1 1/7] qdev: Define halting API


From: Peter Crosthwaite
Subject: [Qemu-devel] [RFC PATCH v1 1/7] qdev: Define halting API
Date: Mon, 4 Mar 2013 19:01:33 +1000

Define APIs on the device level for halting and un-halting a device. The
semantic is the device freezes its state and does not respond to any form
of transaction.

The main intended use cases is to implement clock gating and power down. clock
gating is just a halt, whereas power down is a reset() and halt(). Unhalt is
then used to ungate the clock or power up the device.

Signed-off-by: Peter Crosthwaite <address@hidden>
---

 hw/qdev-core.h |   17 +++++++++++++++++
 hw/qdev.c      |   18 ++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/hw/qdev-core.h b/hw/qdev-core.h
index 2486f36..1fee53a 100644
--- a/hw/qdev-core.h
+++ b/hw/qdev-core.h
@@ -87,6 +87,9 @@ typedef struct DeviceClass {
 
     /* callbacks */
     void (*reset)(DeviceState *dev);
+    void (*halt)(DeviceState *dev);
+    void (*unhalt)(DeviceState *dev);
+
     DeviceRealize realize;
     DeviceUnrealize unrealize;
 
@@ -280,6 +283,20 @@ void qdev_machine_init(void);
  */
 void device_reset(DeviceState *dev);
 
+/**
+ * @device_halt
+ *
+ * Halt a single device (by calling the halt method).
+ */
+void device_halt(DeviceState *dev);
+
+/**
+ * @device_unhalt
+ *
+ * Unhalt a single device (by calling the unhalt method).
+ */
+void device_unhalt(DeviceState *dev);
+
 const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
 
 const char *qdev_fw_name(DeviceState *dev);
diff --git a/hw/qdev.c b/hw/qdev.c
index 689cd54..c338b74 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -797,6 +797,24 @@ void device_reset(DeviceState *dev)
     }
 }
 
+void device_halt(DeviceState *dev)
+{
+    DeviceClass *klass = DEVICE_GET_CLASS(dev);
+
+    if (klass->halt) {
+        klass->halt(dev);
+    }
+}
+
+void device_unhalt(DeviceState *dev)
+{
+    DeviceClass *klass = DEVICE_GET_CLASS(dev);
+
+    if (klass->halt) {
+        klass->unhalt(dev);
+    }
+}
+
 Object *qdev_get_machine(void)
 {
     static Object *dev;
-- 
1.7.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]