@@ -149,4 +149,13 @@ void qemu_clk_set_callback(QEMUClock *clk,
QEMUClkRateUpdateCallback *cb,
void *opaque);
+/**
+ * qemu_clk_print:
+ * @dev: the device for which the clock need to be printed.
+ *
+ * Print the clock information for a given device.
+ *
+ */
+void qemu_clk_print(Monitor *mon, DeviceState *dev, int indent);
+
#endif /* QEMU_CLOCK_H */
@@ -30,6 +30,7 @@
#include "qemu/help_option.h"
#include "sysemu/block-backend.h"
#include "migration/migration.h"
+#include "qemu/qemu-clock.h"
/*
* Aliases were a bad idea from the start. Let's keep them
@@ -699,6 +700,7 @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
ngl->num_out);
}
}
+ qemu_clk_print(mon, dev, indent);
class = object_get_class(OBJECT(dev));
do {
qdev_print_props(mon, dev, DEVICE_CLASS(class)->props, indent);
@@ -27,6 +27,7 @@
#include "qemu/log.h"
#include "qapi/error.h"
#include "hw/qdev-core.h"
+#include "monitor/monitor.h"
#ifndef DEBUG_QEMU_CLOCK
#define DEBUG_QEMU_CLOCK 0
@@ -134,6 +135,33 @@ QEMUClock *qemu_clk_device_get_clock(DeviceState *dev, const char *name)
return QEMU_CLOCK(clk);
}
+struct print_opaque {
+ Monitor *mon;
+ int indent;
+};
+
+static int qemu_clk_print_rec(Object *obj, void *opaque)
+{
+ QEMUClock *clk = (QEMUClock *)(object_dynamic_cast(obj, TYPE_CLOCK));
+ struct print_opaque *po = opaque;
+
+ if (clk) {
+ monitor_printf(po->mon, "%*s" "qemu-clk \"%s\" %" PRIu64 "\n",
+ po->indent, " ", clk->name, clk->rate);
+ }
+
+ return 0;
+}
+
+void qemu_clk_print(Monitor *mon, DeviceState *dev, int indent)
+{
+ struct print_opaque po;
+
+ po.indent = indent;
+ po.mon = mon;
+ object_child_foreach(OBJECT(dev), qemu_clk_print_rec, &po);
+}
+
static const TypeInfo qemu_clk_info = {
.name = TYPE_CLOCK,
.parent = TYPE_OBJECT,