From patchwork Thu Jan 26 09:47:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?S09OUkFEIEZyw6lkw6lyaWM=?= X-Patchwork-Id: 9538723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C15A6601D7 for ; Thu, 26 Jan 2017 09:54:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B49A7269DA for ; Thu, 26 Jan 2017 09:54:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8E2D28178; Thu, 26 Jan 2017 09:54:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D5B05269DA for ; Thu, 26 Jan 2017 09:54:18 +0000 (UTC) Received: from localhost ([::1]:37132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWgky-0002DL-OV for patchwork-qemu-devel@patchwork.kernel.org; Thu, 26 Jan 2017 04:54:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWger-00053J-Ci for qemu-devel@nongnu.org; Thu, 26 Jan 2017 04:47:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWgeq-0000nz-DH for qemu-devel@nongnu.org; Thu, 26 Jan 2017 04:47:57 -0500 Received: from greensocs.com ([193.104.36.180]:33087) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWgeq-0000nj-1s for qemu-devel@nongnu.org; Thu, 26 Jan 2017 04:47:56 -0500 Received: from localhost (localhost [127.0.0.1]) by greensocs.com (Postfix) with ESMTP id 5D69B389832; Thu, 26 Jan 2017 10:47:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1485424075; bh=zvi7CMQoQU8M4ULtxw6MFkNVxW13UQI777yS8/ZujdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MGGgF/UTOv3DUuHjuNk52l1yFh0pT6wr3sYrPpoKVD68htWj0RUor6vkNZLrE0UW1 O2/pFasI4nwcYe0lB0PUHOFjrTTnhTMRdOqccixNOGcPzs+CsKEiZrlwMpVLZ+Fjm7 5nArcI+v0LEwn2jnblMwrTMDkoRq1SmyEhng0vzA= X-Virus-Scanned: amavisd-new at greensocs.com Authentication-Results: gs-01.greensocs.com (amavisd-new); dkim=pass (1024-bit key) header.d=greensocs.com header.b=q0o26FRs; dkim=pass (1024-bit key) header.d=greensocs.com header.b=q0o26FRs Received: from greensocs.com ([127.0.0.1]) by localhost (gs-01.greensocs.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hy-aBaqQSFMK; Thu, 26 Jan 2017 10:47:53 +0100 (CET) Received: by greensocs.com (Postfix, from userid 998) id D90EC38985D; Thu, 26 Jan 2017 10:47:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1485424072; bh=zvi7CMQoQU8M4ULtxw6MFkNVxW13UQI777yS8/ZujdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=q0o26FRsE2mKAfajzOqUJMvsrI2NmUSPN8wHenOm+dV3/SBr+21dTWlyMgubo+U+d udoCWbiw1Qyvp7aRYHAiEPDisPh9DLEzGvtnRpw+66II92wH9vmYZ7qFBNY42+pUbY 9k+g52C84z31Wg75W4ezkbHGFJUAtklWMNpN3G5k= Received: from corsair.home (bd231-7-88-127-3-24.fbx.proxad.net [88.127.3.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: fred.konrad@greensocs.com) by greensocs.com (Postfix) with ESMTPSA id 2A5B3389855; Thu, 26 Jan 2017 10:47:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=greensocs.com; s=mail; t=1485424072; bh=zvi7CMQoQU8M4ULtxw6MFkNVxW13UQI777yS8/ZujdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=q0o26FRsE2mKAfajzOqUJMvsrI2NmUSPN8wHenOm+dV3/SBr+21dTWlyMgubo+U+d udoCWbiw1Qyvp7aRYHAiEPDisPh9DLEzGvtnRpw+66II92wH9vmYZ7qFBNY42+pUbY 9k+g52C84z31Wg75W4ezkbHGFJUAtklWMNpN3G5k= From: fred.konrad@greensocs.com To: qemu-devel@nongnu.org Date: Thu, 26 Jan 2017 10:47:35 +0100 Message-Id: <1485424060-12217-6-git-send-email-fred.konrad@greensocs.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1485424060-12217-1-git-send-email-fred.konrad@greensocs.com> References: <1485424060-12217-1-git-send-email-fred.konrad@greensocs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 193.104.36.180 Subject: [Qemu-devel] [PATCH V2 05/10] qdev-monitor: print the device's clock with info qtree X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: edgar.iglesias@xilinx.com, peter.maydell@linaro.org, fred.konrad@greensocs.com, mark.burton@greensocs.com, alistair.francis@xilinx.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: KONRAD Frederic This prints the clock attached to a DeviceState when using "info qtree" monitor command. For example: bus: main-system-bus type System dev: xlnx.zynqmp_crf, id "" gpio-out "sysbus-irq" 1 gpio-out "RST_A9" 4 qemu-clk "dbg_trace" 0.0 qemu-clk "vpll_to_lpd" 12500000.0 qemu-clk "dp_stc_ref" 0.0 qemu-clk "dpll_to_lpd" 12500000.0 qemu-clk "acpu_clk" 0.0 qemu-clk "pcie_ref" 0.0 qemu-clk "topsw_main" 0.0 qemu-clk "topsw_lsbus" 0.0 qemu-clk "dp_audio_ref" 0.0 qemu-clk "sata_ref" 0.0 qemu-clk "dp_video_ref" 1428571.4 qemu-clk "vpll_clk" 50000000.0 qemu-clk "apll_to_lpd" 12500000.0 qemu-clk "dpll_clk" 50000000.0 qemu-clk "gpu_ref" 0.0 qemu-clk "aux_refclk" 0.0 qemu-clk "video_clk" 27000000.0 qemu-clk "gdma_ref" 0.0 qemu-clk "gt_crx_ref_clk" 0.0 qemu-clk "dbg_fdp" 0.0 qemu-clk "apll_clk" 50000000.0 qemu-clk "pss_alt_ref_clk" 0.0 qemu-clk "ddr" 0.0 qemu-clk "pss_ref_clk" 50000000.0 qemu-clk "dpdma_ref" 0.0 qemu-clk "dbg_tstmp" 0.0 mmio 00000000fd1a0000/000000000000010c Signed-off-by: KONRAD Frederic --- include/qemu/qemu-clock.h | 9 +++++++++ qdev-monitor.c | 2 ++ qemu-clock.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/include/qemu/qemu-clock.h b/include/qemu/qemu-clock.h index 45f8766..ccc381c 100644 --- a/include/qemu/qemu-clock.h +++ b/include/qemu/qemu-clock.h @@ -149,4 +149,13 @@ void qemu_clk_set_callback(qemu_clk 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 */ diff --git a/qdev-monitor.c b/qdev-monitor.c index c73410c..8f6bbdf 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -29,6 +29,7 @@ #include "qemu/error-report.h" #include "qemu/help_option.h" #include "sysemu/block-backend.h" +#include "qemu/qemu-clock.h" /* * Aliases were a bad idea from the start. Let's keep them @@ -689,6 +690,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); diff --git a/qemu-clock.c b/qemu-clock.c index 300e38f..b34021c 100644 --- a/qemu-clock.c +++ b/qemu-clock.c @@ -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 @@ -132,6 +133,33 @@ qemu_clk 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) +{ + qemu_clk clk = (qemu_clk)(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->out_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,