From patchwork Wed Sep 11 12:13:54 2024 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: 827413 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp765611wrc; Wed, 11 Sep 2024 05:24:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUuSqbvSmDvPa2dhfxa5jB11upOwL3vfW5PUKVkrj6hYt9ggpUrdTAH2vezj3PSqbFU1keXPQ==@linaro.org X-Google-Smtp-Source: AGHT+IEnZN/l6eoBOD6VTYnSx2/G4Ax7HYI92CD9IJbXxdxWkHm92BZQ2RLnPGnduVKZtybeoZ9u X-Received: by 2002:a05:690c:1e:b0:6d6:94b2:f3e4 with SMTP id 00721157ae682-6dba6dc04b8mr27467217b3.26.1726057473669; Wed, 11 Sep 2024 05:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726057473; cv=none; d=google.com; s=arc-20240605; b=XXMKjuXk0vsRcSvUxUj4OoAj37b9KnnUnQ85cZqTdD2aktXVhpuErHxAS9EvLkklFG kwwjDBv46jvde1t9571Na4PrsDF/lPlkgsliSRNJQB47pdSEuabc/tPSfEM7Z6hmj4XE AIsQCBFk1G/SvCOBbW3ztQH8Ce+LH6muEL+Gsvb+4QQQF5cCcYpR4de1gW3Lg0XotLUC 7Z7WHivfFov58NNv3NsmGXmAIkCNGWJwz3BF4PgcibqPv3k6gJpoJd4oB4IAG/baSfH8 dWCjirVmr4SgATSyBOcG7gR+or+V9908Bw97cQAQMXiOY5EyGZFot7Q2nCe6HFaB8/1B fUdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=YeNvT7txJznOF0zd6v7UUyaauDX8I3k5a8TXKDaI5uY=; fh=4WA+gbDFoaZkyeo77Q5pmSG9YuLZK0MrGi6Or5WXoyo=; b=AeXnnval5Mm5ho378+BzM+xIWD5lPe9rU5qsQO66KmMch8uuIlBmUCnSk17jdOijko 38+MqTCJiF2GIaKBvnLYrWl7s5mNmJu3LZan5DaqaurzfOvmIvLEpJYGVLlcSBOc7wbo SzOPyTWnpO0rvhHXFYoBI4jG3e6fExVysLFe4gbM3q8OA2eJe4ILGXh/ris286cHuADN JTCyPQqk5AhvUKuzYhLLVqVAlHa9BWbhFiQG9uBsIyornwLMuGrRRHMcHVymoCuj7GZL DDE5OE9mEsU7B2UO/KnwGv+nw6nigkyUSeo34vPQPnGN97JZKQ4u4RLzRbOD1i4/ZUn+ 4f9Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Skn9Uu+x; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a9a7a47b4fsi1013463585a.501.2024.09.11.05.24.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Sep 2024 05:24:33 -0700 (PDT) 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=Skn9Uu+x; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soMIs-000587-DO; Wed, 11 Sep 2024 08:18:34 -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 1soMI5-0001xR-OK for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:17:58 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1soMI3-0007Zt-Qx for qemu-devel@nongnu.org; Wed, 11 Sep 2024 08:17:45 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-374c8cef906so4596179f8f.2 for ; Wed, 11 Sep 2024 05:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726057058; x=1726661858; 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=YeNvT7txJznOF0zd6v7UUyaauDX8I3k5a8TXKDaI5uY=; b=Skn9Uu+xhlyAByc5cc9hfAOs5wvgdQNq/ML2tqtgKrqwQuPdOmaf0fvc5XqFDUhfzE VIERsDFkGK7Js0Inn2uUR3hZt/L4lo8cwr0fDVjuCNBIT0ydpI3lL+o7y4u8qkDdGFyw UrmabdLcTtHgG3af1/Jy82m6FD0AJtR9sBKel9/8WsNh37Gmx8RKEdoa4G8g0i3XpCW/ pTZTrxdjnuqU6DM1EE6wKSJ6plTLem4fdnCfoo4kExeRcKOXuw5TFPxYH9IqZQIzS5JN 6W1Gf6cvapD7+gtouZi4jiWTx5D06hljCrm7LoN3eWEX+b7YCD38NBtpRKX0toG42Pfu G4NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726057058; x=1726661858; 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=YeNvT7txJznOF0zd6v7UUyaauDX8I3k5a8TXKDaI5uY=; b=C93ysjSs0Q7e5YWVjjBySf4/d6wMWkJhIXagJP8Xc1TCB584TeOUso0fZp+M/uJFVj hUKfqHpOF/QN8jizNCHW1DTg1COK/O15Laueg9NPo/RUvMYUC2L79Vny9o21i0AUaEcN X0Sxo1SAP99O/3UvEUeC/Q46aK09u92VJQgIxLEl3iYT2OEnKpnZza7aIl5b0kNUkZcB SjtlxaTYVaYsp/xhyeF9i7E+rYU/hPfdkNw+rsJDpWgXJylR9BwunPuiBhecrptmqXK4 dd2UzACzyXThQOiFibY5AAsMgF9FHonEokqr15yKJ8G9xr5X8y95De3y08uvMY8hWXXx tCLw== X-Gm-Message-State: AOJu0Yz0uBgwqE2sTP1Jg4wa/4M63xieGVUgosL+iJHD03Ey+ZWVdO3U 4mz5613y9NLl9dSdCRDCjZt2BkX2qofl4Ks2tRfzDAQG0pRKw9sklRhhHALPQI2ZcwJE30SiNse b X-Received: by 2002:a5d:5545:0:b0:374:c269:df6e with SMTP id ffacd0b85a97d-378895ddf36mr10972331f8f.25.1726057058481; Wed, 11 Sep 2024 05:17:38 -0700 (PDT) Received: from m1x-phil.lan ([176.187.196.107]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378956d37a1sm11389072f8f.77.2024.09.11.05.17.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Sep 2024 05:17:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , Richard Henderson Subject: [PULL 29/56] hw/char/pl011: Warn when using disabled transmitter Date: Wed, 11 Sep 2024 14:13:54 +0200 Message-ID: <20240911121422.52585-30-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240911121422.52585-1-philmd@linaro.org> References: <20240911121422.52585-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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 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+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 Message-Id: <20240719181041.49545-9-philmd@linaro.org> --- 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 26d391a16d..9c045d3709 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -85,7 +85,9 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define CR_OUT1 (1 << 12) #define CR_RTS (1 << 11) #define CR_DTR (1 << 10) +#define CR_TXE (1 << 8) #define CR_LBE (1 << 7) +#define CR_UARTEN (1 << 0) /* Integer Baud Rate Divider, UARTIBRD */ #define IBRD_MASK 0x3f @@ -223,7 +225,14 @@ static void pl011_loopback_tx(PL011State *s, uint32_t value) 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