From patchwork Thu Nov 9 19:28:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 742603 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:110f:b0:32d:baff:b0ca with SMTP id z15csp1019103wrw; Thu, 9 Nov 2023 11:32:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9An7h/7PMjjO1wdkkvO1QaJ0359Kmr4WCfN1+gxJzztKa0bffzwkeDW0rL4b/wG3YPbBW X-Received: by 2002:ad4:4423:0:b0:66d:5cfe:82a6 with SMTP id e3-20020ad44423000000b0066d5cfe82a6mr353105qvt.27.1699558342208; Thu, 09 Nov 2023 11:32:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699558342; cv=none; d=google.com; s=arc-20160816; b=K/EDiaZGs1sV0KWX6cAWZJTwDtoI5u+5rFD6uVlBxPWoK/GOC+hqQJ/n8L/orBXEec vQRpg2Scm18sWUSCldHSIfLkw8ApxPmzDbNMCoF0qEMStbwh+1UH0BqDZHskrxNMhGxv lz7CFdxHMZcyn3otiS5ZaXWbNLw1LsghY9t14FM8qixx9qYs6b5oMTnOmf3P5pS6md0k dzFr705gqxBPVjvmeZQoojM+YDlF5sGvwvz4QrCAAyf8rqu/O2MtZlcU6u/BduY0R12L nJM1FtVqIKMow3kwqmWP2yf65A9lU/GHmFxmmc+boou+2caECKh99UVAweHTbM4Z+YCZ HACQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TEZCH3t9203jXT8Ca8hiOxWdvxGRGRt32KSzy33l+nU=; fh=Zi/lk1CoRxouROvt4Eod7oP2jg68ZE5jz0tOr4SBE9g=; b=nuZa0pNpb+1grxw6MQdj8nayFEC07K702dmqlpUJHFH/GCMJddJqGGja4EX8VWxzqS D6RfrR+t6+89Oubia+IisvhddiM3zf7P0t9F2ZZ8HmbLecVANJXIO1ZnGmvqfxZA+LLx sjD3APDVECQJesJtd6/4Un6qkh6Qe/Ja+Vb3jepH1ysxEZhHazOREUipHhQ4nC8W2eex A09NuMgpyKpLdKGXnbVqrRym1l8jDbSPE7MDWrqEInhT4bQszWN77L5JUnneSK+Go35f PKTIwMSPl0kyNAAut/3wEAWmPLQcwEM1Z83Xb4LbBSg2/SzU24OaFllXF1Orl4l3GphC QpRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bmUkq/Qi"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s17-20020ad45251000000b00658963f9a46si3338509qvq.277.2023.11.09.11.32.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Nov 2023 11:32:22 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bmUkq/Qi"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r1AiQ-0005yE-AO; Thu, 09 Nov 2023 14:29:22 -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 1r1Ai2-0005RW-B4 for qemu-devel@nongnu.org; Thu, 09 Nov 2023 14:29:02 -0500 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r1Ahy-0005IO-JJ for qemu-devel@nongnu.org; Thu, 09 Nov 2023 14:28:57 -0500 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-9dd6dc9c00cso216021466b.3 for ; Thu, 09 Nov 2023 11:28:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699558133; x=1700162933; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TEZCH3t9203jXT8Ca8hiOxWdvxGRGRt32KSzy33l+nU=; b=bmUkq/QiqQsVxBIPg6upwJ3HanE2T6z3MuOJU7EAhURTKDz+A8kASIlZvFgIf/2orm 99JsS8K6Jt14ckG8Po+nRQSlCqGQtNXk7srx/mVspcrJwbHEOMj0Hzryb7Q3R4WuWRXR md5OGIAGP1z8vcl5j6ZtS9ntO7EmbeClB9+z1CEEHhQBiW1kwtYoSgafe9ujlwCSi9Rm Dq+SgUuICnsQbeo/s+JX7W8ZjtlahgqwzXfIDVX8j1r7cwiQT/VkN8F65huo06+SqBBK F08nR4RGH24P7bYnbgUYsrytZkqxKMI7ISquOsIJEXpfsneQiOVOAdTl9lEpnVlJ6Yab dgGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699558133; x=1700162933; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TEZCH3t9203jXT8Ca8hiOxWdvxGRGRt32KSzy33l+nU=; b=SZ/CLP+53GUX4awM4Gnm6SUGkvKNqKGMn3czyzCEvINF6t6Szhf9R5DCaPSgcfaI7F 2t59B3PblHTXz4+p49DUj0rpQ+hzXBx3VpRyZEf+zruHXJolnEU4V9BKdh6m9NRPPlm8 0KCHgISkaW4dwjj+WS7VzCuPEmIlK//7/puRLFj+ot+Lsbi9tlVGvPi31/9WiRTynLYf WIxijmhGq1RkfZoeEmKU7OsQAqTe5SYpbi5xe5np9Nny+yIRflbzGnrr9rH9b+CCWBPf R/8Pjo3Y1h04UPhMQiBodpMZeOUdCxaDNl8GneWf0EIHzkGU5YFwlgq4nOr0nsx+1Zre qiGw== X-Gm-Message-State: AOJu0YwgPdPHcfdwJ9kIF2qGs8kqprtgnWpbTK/vee6FXMlPj2BGTvBU AoSzrzbU3szKYmwUp4xhyD5oiw/cWB7uWu5KFbeRmg== X-Received: by 2002:a17:907:a0b:b0:9bf:9c58:e91e with SMTP id bb11-20020a1709070a0b00b009bf9c58e91emr4392989ejc.56.1699558132912; Thu, 09 Nov 2023 11:28:52 -0800 (PST) Received: from m1x-phil.lan ([176.187.199.161]) by smtp.gmail.com with ESMTPSA id g2-20020a1709064e4200b009b2c9476726sm2904753ejw.21.2023.11.09.11.28.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Nov 2023 11:28:52 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Gavin Shan , Paolo Bonzini , Mark Cave-Ayland , Peter Maydell , Evgeny Iakovlev , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH-for-8.2 v4 06/10] hw/char/pl011: Warn when using disabled transmitter Date: Thu, 9 Nov 2023 20:28:10 +0100 Message-ID: <20231109192814.95977-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231109192814.95977-1-philmd@linaro.org> References: <20231109192814.95977-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=philmd@linaro.org; helo=mail-ej1-x62d.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, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We shouldn't transmit characters when the full UART or its transmitter is disabled. However we don't want to break the possibly incomplete "my first bare metal assembly program"s, so we choose to simply display a warning when this occurs. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson --- hw/char/pl011.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 30309337b1..9c43cb47bf 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -76,6 +76,10 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define LCR_FEN (1 << 4) #define LCR_BRK (1 << 0) +/* Control Register, UARTCR */ +#define CR_TXE (1 << 8) +#define CR_UARTEN (1 << 0) + static const unsigned char pl011_id_arm[8] = { 0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1 }; static const unsigned char pl011_id_luminary[8] = @@ -151,7 +155,12 @@ static inline void pl011_reset_tx_fifo(PL011State *s) static void pl011_write_txdata(PL011State *s, uint8_t data) { - /* ??? Check if transmitter is enabled. */ + if (!(s->cr & CR_UARTEN)) { + qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled UART\n"); + } + if (!(s->cr & CR_TXE)) { + qemu_log_mask(LOG_GUEST_ERROR, "PL011 data written to disabled TX UART\n"); + } /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */