From nobody Mon Nov 25 09:29:06 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1715177683; cv=none; d=zohomail.com; s=zohoarc; b=Cl2iiAJ1jqdMJcnWo7EuvlIxdpx0xeXiIpIEwvKq1jE8PB6CEXk9vZX1RW8/8kZBKxYy8aNU5eWZXanyqwcey02UJyuASLJShPH5/H234GBnfk1w0VpWiL1FausCVzY7vO0pTWUE29IAQyIgDRGIiJ7eE6yI6RX35BlitS4Z6gU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715177683; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bPs0zsG9VK2wQ8xgMVPcc5ZG9na1Q66b8plpnDmTE4Q=; b=m+JOLZzQ7yfKUdETVSMeWJZVSXUR6zMgtVuvYAn79tFoz9+yNnM6ISDq0JFk4Efk+KgaLhQ1Ei2z+Sr/LjLzONTs6zKBJY6eajK7JAv/eVrHepSKVu7T8IpIlF4t6Vw/tH9hbjyVI25fSmdsNwW27Gles+mqIR3YFflCuHdnVic= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715177683430829.6966327346786; Wed, 8 May 2024 07:14:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4i3H-0001Dl-BY; Wed, 08 May 2024 10:13:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s4i3D-0001DL-Vt for qemu-devel@nongnu.org; Wed, 08 May 2024 10:13:44 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4i38-0004NL-Bd for qemu-devel@nongnu.org; Wed, 08 May 2024 10:13:43 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-34da35cd01cso4078367f8f.2 for ; Wed, 08 May 2024 07:13:37 -0700 (PDT) Received: from m1x-phil.lan (sar95-h02-176-184-10-250.dsl.sta.abo.bbox.fr. [176.184.10.250]) by smtp.gmail.com with ESMTPSA id d9-20020adff2c9000000b0034dd56189e8sm15448242wrp.22.2024.05.08.07.13.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 May 2024 07:13:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715177616; x=1715782416; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bPs0zsG9VK2wQ8xgMVPcc5ZG9na1Q66b8plpnDmTE4Q=; b=kNstpwFXfFa0JcEjWS3AuJQMfdll8UMKEVXLc6z8T6KehKhDCd5kqf/MDPsVisArYK HkK734C8+67MmF7TbFP9nXlzF53WBy42x7iYiwpLWepHxy7C56G3SMyFyBjMMLYaij5q AwTTQ12Sub4cUdxxt3SLUif8EQDekrJgJw0wxXykpcNcTh2O4WsK0BFsOFm0nK0RwXTx 5TPVrJwJtnuXAbmTmJft06VqDkCfqn7DHc4FWQwlxOQZLLca8PznU4CNzyBRDfMx+bl1 jb4AKkZMd5mHPl0kW+ncEwJDJu3LkeGB4UBqUDSlCJGHBa/L9Xe8K5FSK3q47pLitIyO Na/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715177616; x=1715782416; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bPs0zsG9VK2wQ8xgMVPcc5ZG9na1Q66b8plpnDmTE4Q=; b=eXMkoqrHn+1l+2GjNekESazq4RSyIY7NmWz5TgN+gaGx6uioIc2PTKe7Z/r3wWKr8+ q9GyZBZfxYFzWHcchIAfAIGY+91MpHDEXkHwRtdB6zlCMOf0FlO+ce0eI9RunjY3JsRo 4uP96IzmDVDrBxDJ3NGzMBnXmYiy8iTBQsZ8SNieIZ2iMf1dq7+dcH+E8v2HZsmTauV6 pgPEDEXoPVTUnASsoOUQ29pcPH0FD32q34WsOkF72Cgz+AzgcfAh7UVUhP9FrM3qUybd mbcQPtVA684wwU/8JaHn8Wms+wed0veWcwU6SQZgJS5JP2kDymeEsXvE1n2eZpePSEOt w6iA== X-Gm-Message-State: AOJu0YwDX2EbGlz7tW5lhPmDEyW0TjQYj7YhSyUx74qVYIwPsTDLEiuN IYb9XVfK8I+jwm5wfX+69sGNiwcBs9IqBvf+W2mZd9IcGEX/UP9WRoRds5mH26uGRbomIoCM+tw 4 X-Google-Smtp-Source: AGHT+IFeFJ2JGx/ZmqmnLWoV4naAhKN//95DH/a/FJRlmyvlekEZnDKLAFljJJrZeKdNfWFT4+eRbQ== X-Received: by 2002:a05:6000:1104:b0:34f:96ba:ca3f with SMTP id ffacd0b85a97d-34fca621dbcmr3321638f8f.53.1715177616129; Wed, 08 May 2024 07:13:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Luc Michel , Peter Maydell , Damien Hedde , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?In=C3=A8s=20Varhol?= Subject: [PATCH] hw/clock: Expose 'freq-hz' QOM property Date: Wed, 8 May 2024 16:13:33 +0200 Message-ID: <20240508141333.44610-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1715177685066100001 Expose the clock frequency via the QOM 'freq-hz' property, as it might be useful for QTests. HMP example: $ qemu-system-mips -S -monitor stdio -M mipssim (qemu) qom-get /machine/cpu-refclk freq-hz 12000000 Inspired-by: In=C3=A8s Varhol Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/clock.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/core/clock.c b/hw/core/clock.c index e212865307..55f86ef483 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -13,6 +13,7 @@ =20 #include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qapi/visitor.h" #include "hw/clock.h" #include "trace.h" =20 @@ -158,6 +159,14 @@ bool clock_set_mul_div(Clock *clk, uint32_t multiplier= , uint32_t divider) return true; } =20 +static void clock_prop_freq_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Clock *clk =3D CLOCK(obj); + uint64_t freq_hz =3D clock_get_hz(clk); + visit_type_uint64(v, name, &freq_hz, errp); +} + static void clock_initfn(Object *obj) { Clock *clk =3D CLOCK(obj); @@ -166,6 +175,9 @@ static void clock_initfn(Object *obj) clk->divider =3D 1; =20 QLIST_INIT(&clk->children); + + object_property_add(obj, "freq-hz", "uint64", + clock_prop_freq_get, NULL, NULL, NULL); } =20 static void clock_finalizefn(Object *obj) --=20 2.41.0