[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
- [Qemu-devel] [RFC PATCH v1 0/7] Reset and Halting modifications + Zynq SMP, Peter Crosthwaite, 2013/03/04
- [Qemu-devel] [RFC PATCH v1 1/7] qdev: Define halting API,
Peter Crosthwaite <=
- [Qemu-devel] [RFC PATCH v1 2/7] qom/cpu.c: Encapsulate cpu halting, Peter Crosthwaite, 2013/03/04
- [Qemu-devel] [RFC PATCH v1 3/7] qom/cpu.c: Hook CPU reset up to device reset, Peter Crosthwaite, 2013/03/04
- [Qemu-devel] [RFC PATCH v1 4/7] sun4m: Use halting API to halt/unhalt CPUs, Peter Crosthwaite, 2013/03/04
- [Qemu-devel] [RFC PATCH v1 5/7] xilinx_zynq: added smp support, Peter Crosthwaite, 2013/03/04
- [Qemu-devel] [RFC PATCH v1 6/7] zynq_slcr: Add links to the CPUs, Peter Crosthwaite, 2013/03/04
- [Qemu-devel] [RFC PATCH v1 7/7] zynq_slcr: Implement CPU reset and halting, Peter Crosthwaite, 2013/03/04
- Re: [Qemu-devel] [RFC PATCH v1 0/7] Reset and Halting modifications + Zynq SMP, Andreas Färber, 2013/03/04