From nobody Mon Dec 23 23:04:45 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 ARC-Seal: i=1; a=rsa-sha256; t=1734684462; cv=none; d=zohomail.com; s=zohoarc; b=CiUP5UPkT+GhLIp0qagzdSqgsSMJ8GJhfjGFgkqM5yMybdavcF+8tNf6nYkvj25iiwx+n5VeagK8/cthNKftbI0RFnzzhqYm1rbxGSAWA3/sdEAoKTn21TpJa/E6mPusH+gIJx0YfbAOLc08KhuOLhdtoDz4CjuRoFQurgL5MMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1734684462; h=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=DEWLsEBJEXh8+7vMojttx0v1UhjFc3wSl+wOs7T9sjg=; b=GtOEFA0mrIiHZUGNNTlIniowDDbbpb7iYg5V+sNvZHi83402nvw1r9SRTa/RHSEAjlePvrrBXHKJp61kq8rAZpBDNraxjYVMJS1oOkksuApkxHfT++x1O9u1tVpeYSn+b6NprrD2LAl1HJAjvekXu4yy0qcfSZr2vjaEgx8SYsI= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1734684461959834.0626690576368; Fri, 20 Dec 2024 00:47:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOYel-0004pY-Vw; Fri, 20 Dec 2024 03:46:48 -0500 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 1tOYeh-0004om-Nz; Fri, 20 Dec 2024 03:46:44 -0500 Received: from forward103d.mail.yandex.net ([2a02:6b8:c41:1300:1:45:d181:d103]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOYef-0000nS-1O; Fri, 20 Dec 2024 03:46:43 -0500 Received: from mail-nwsmtp-smtp-production-main-24.klg.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-24.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:4f43:0:640:673c:0]) by forward103d.mail.yandex.net (Yandex) with ESMTPS id 839216001C; Fri, 20 Dec 2024 11:46:23 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-24.klg.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id LkOX0FeOoKo0-GTl7G6FW; Fri, 20 Dec 2024 11:46:22 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maquefel.me; s=mail; t=1734684382; bh=DEWLsEBJEXh8+7vMojttx0v1UhjFc3wSl+wOs7T9sjg=; h=Message-ID:Date:Cc:Subject:To:From; b=RITAACjjkJPFzXzzQeWZGsFOlXZCtLrbBI3AgH/NDuPcmUq1wHIB658Bejm+dh8R8 42hCEpMo3nGDCyMSPr2FcHpQvRbJsTTizmdBY8aGZL32yYNeKx8Q314hKyTzX8WWvb WEcbHkeDxDiRNAqIL6t5jCr2iaOzCE3oevAfflOU= Authentication-Results: mail-nwsmtp-smtp-production-main-24.klg.yp-c.yandex.net; dkim=pass header.i=@maquefel.me From: Nikita Shubin To: Alistair Francis , Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Cc: Nikita Shubin , Nikita Shubin , qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH] hw/char: stm32f2xx_usart: replace print with trace Date: Fri, 20 Dec 2024 11:46:23 +0300 Message-ID: <20241220084623.1889-1-nikita.shubin@maquefel.me> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 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=2a02:6b8:c41:1300:1:45:d181:d103; envelope-from=nikita.shubin@maquefel.me; helo=forward103d.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 @maquefel.me) X-ZM-MESSAGEID: 1734684465796116600 Content-Type: text/plain; charset="utf-8" From: Nikita Shubin Drop debug printing macros and replace them with according trace functions. Signed-off-by: Nikita Shubin --- hw/char/stm32f2xx_usart.c | 47 ++++++++++++++++++--------------------- hw/char/trace-events | 6 +++++ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c index 17b5b1f15f..ca878d0cd6 100644 --- a/hw/char/stm32f2xx_usart.c +++ b/hw/char/stm32f2xx_usart.c @@ -30,17 +30,7 @@ #include "qemu/log.h" #include "qemu/module.h" =20 -#ifndef STM_USART_ERR_DEBUG -#define STM_USART_ERR_DEBUG 0 -#endif - -#define DB_PRINT_L(lvl, fmt, args...) do { \ - if (STM_USART_ERR_DEBUG >=3D lvl) { \ - qemu_log("%s: " fmt, __func__, ## args); \ - } \ -} while (0) - -#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args) +#include "trace.h" =20 static int stm32f2xx_usart_can_receive(void *opaque) { @@ -67,10 +57,11 @@ static void stm32f2xx_update_irq(STM32F2XXUsartState *s) static void stm32f2xx_usart_receive(void *opaque, const uint8_t *buf, int = size) { STM32F2XXUsartState *s =3D opaque; + DeviceState *d =3D DEVICE(s); =20 if (!(s->usart_cr1 & USART_CR1_UE && s->usart_cr1 & USART_CR1_RE)) { /* USART not enabled - drop the chars */ - DB_PRINT("Dropping the chars\n"); + trace_stm32f2xx_usart_drop(d->id); return; } =20 @@ -79,7 +70,7 @@ static void stm32f2xx_usart_receive(void *opaque, const u= int8_t *buf, int size) =20 stm32f2xx_update_irq(s); =20 - DB_PRINT("Receiving: %c\n", s->usart_dr); + trace_stm32f2xx_usart_recieve(d->id, *buf); } =20 static void stm32f2xx_usart_reset(DeviceState *dev) @@ -101,49 +92,55 @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwa= ddr addr, unsigned int size) { STM32F2XXUsartState *s =3D opaque; + DeviceState *d =3D DEVICE(s); uint64_t retvalue; =20 - DB_PRINT("Read 0x%"HWADDR_PRIx"\n", addr); - switch (addr) { case USART_SR: retvalue =3D s->usart_sr; qemu_chr_fe_accept_input(&s->chr); - return retvalue; + break; case USART_DR: - DB_PRINT("Value: 0x%" PRIx32 ", %c\n", s->usart_dr, (char) s->usar= t_dr); retvalue =3D s->usart_dr & 0x3FF; s->usart_sr &=3D ~USART_SR_RXNE; qemu_chr_fe_accept_input(&s->chr); stm32f2xx_update_irq(s); - return retvalue; + break; case USART_BRR: - return s->usart_brr; + retvalue =3D s->usart_brr; + break; case USART_CR1: - return s->usart_cr1; + retvalue =3D s->usart_cr1; + break; case USART_CR2: - return s->usart_cr2; + retvalue =3D s->usart_cr2; + break; case USART_CR3: - return s->usart_cr3; + retvalue =3D s->usart_cr3; + break; case USART_GTPR: - return s->usart_gtpr; + retvalue =3D s->usart_gtpr; + break; default: qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); return 0; } =20 - return 0; + trace_stm32f2xx_usart_read(d->id, size, addr, retvalue); + + return retvalue; } =20 static void stm32f2xx_usart_write(void *opaque, hwaddr addr, uint64_t val64, unsigned int size) { STM32F2XXUsartState *s =3D opaque; + DeviceState *d =3D DEVICE(s); uint32_t value =3D val64; unsigned char ch; =20 - DB_PRINT("Write 0x%" PRIx32 ", 0x%"HWADDR_PRIx"\n", value, addr); + trace_stm32f2xx_usart_write(d->id, size, addr, val64); =20 switch (addr) { case USART_SR: diff --git a/hw/char/trace-events b/hw/char/trace-events index 59e1f734a7..e0a567194c 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -125,3 +125,9 @@ xen_console_unrealize(unsigned int idx) "idx %u" xen_console_realize(unsigned int idx, const char *chrdev) "idx %u chrdev %= s" xen_console_device_create(unsigned int idx) "idx %u" xen_console_device_destroy(unsigned int idx) "idx %u" + +# stm32f2xx_usart.c +stm32f2xx_usart_read(char *id, unsigned size, uint64_t offs, uint64_t val)= " %s size %d offs 0x%02" PRIx64 " -> 0x%02" PRIx64 +stm32f2xx_usart_write(char *id, unsigned size, uint64_t offs, uint64_t val= ) "%s size %d offs 0x%02" PRIx64 " <- 0x%02" PRIx64 +stm32f2xx_usart_drop(char *id) " %s dropping the chars" +stm32f2xx_usart_recieve(char *id, uint8_t chr) " %s receiving %c" --=20 2.45.2