From patchwork Fri Oct 13 14:11:27 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: 733222 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1489410wrv; Fri, 13 Oct 2023 07:12:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEl/7UZbQfHh5SjleXO2tX8fiaPFYRi5ojERRfYNC6c7VMD6JiepffvNVaMvvGx4SvlIbE0 X-Received: by 2002:a05:620a:4046:b0:775:7fdc:42ac with SMTP id i6-20020a05620a404600b007757fdc42acmr32653148qko.7.1697206369842; Fri, 13 Oct 2023 07:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206369; cv=none; d=google.com; s=arc-20160816; b=DxYxVkQEJ0NL/lqccfZilpkoPXOSIV/EdOsDODi19VI0mBpgP7prXLsoQg4oKLkv+H D5cb1VQ9Et3yMEHPu0Zb/nPnKghu9hUfPxA+cqCJARVOluYF4zo9CBgnuJ8bhYrDjNf6 3tNXiqaOvGWE9CruSso4ENGD2i71zWO/N8P3B9+RI6hmaw9bMEpP9m6tr/IwusOElBDj 2vtuo1M6z8pwRLubGvXO5W0VwhVXcEbXTqfk2rzM4w28ZhlDLkF0vWMxwizwZuudR604 58CUitlW8ydT0EwBm5xzlkDC32+UywRqG6ZEkPXqoQ6xMg62PrJitS4Pc3uXzb5jAyrY H/xA== 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=MusjSs7gXCZ/MKYOlww+3pkKR+FOAC+Wy5x6PlCIutc=; b=iCZM5ZraqjEA1pSe1j/ibU9bHoeIxxZa/QYtGzbVLeigoBRT8RH0R6D4tIfBOUU5fQ wPD8fW7JxmLeU68Q4jtdZNMTsIqrvn9D3ldDdzkXp4I8S3t5u3homD2bfaZckADSpBAx cNjwsJvxQuVyiJzjWFjvX0xutKZyJBlzCOTBG6sl1N+jZpKrGn8sHicZVTU1NCSUtO7a axWhIRjViFfB3I6z6C2/nDelpEZ3bPxqfDJXn2ZtaREP83Ja8cIhVdUy7tyt1L+EY7im 93rMAdNIHzDFsYRAlnPThJ0r2i+7iixUEtKighJj8EI5KgT07OmEcjrvVg57Am12V67x U5QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lxz7tNbJ; 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 c6-20020a05620a268600b0076eeed38118si1269798qkp.131.2023.10.13.07.12.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:12:49 -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=Lxz7tNbJ; 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 1qrItr-0000Rd-I0; Fri, 13 Oct 2023 10:12:23 -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 1qrIto-0000Na-D4 for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:20 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrItm-0004Z1-RZ for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:20 -0400 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5347e657a11so3489425a12.2 for ; Fri, 13 Oct 2023 07:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206337; x=1697811137; 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=Lxz7tNbJotN8Tfrk8q0pfRt/TV0V1hzMBHT+rLxCCnVsrbcgnI68UefH3MGJeljeFs RSaYa5MLJd59AQJIHyxVmXLO7fk2dcvYWVv55XFvwLg8UnaGYOk8xoJ0BKu91cpwzLpC 3OWlJj5i4NefZ79i/M47B2Jhn7mlM5VXkivJhVPaUOGiARv4Ff3EMPv/cUhz0fy8JREO 1Le/KNBcDh82kZ2PoMn022NbFx6D1O2F4+MWK9GONpCqqBjs12E9TdYfrDD0wbVv9Wxm te780/MtOx1HhTMi/TPj1qBwOszgEatFsoA8aiO99DWw6yBnr4oOZJEDS+PZvS3UO1fp Q+qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206337; x=1697811137; 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=iVtzzu0OMADY4iYTWh+9OfYdZMd/1iMOHlum+UoREP7ZWb8FmbZbbv3jDgAwtapwSZ V7gktkKbsqQPZcM9qB1Kys03wUvpliegBXyso05Ov2MXPPx7KjddKEHthL1f3XmSr1uR JWfq8uJwdA9wyOUHHetg7GiD8IVkizyN73PrwB7slokLvgERRHaPVpjmt/EMK6cNH9L7 SJiMjYS0KY4Lt7juKbMcAoDbo3xwOO9A5E6hwmylLRAuvPHqBZ5psr7FbF/K5eTglCIR hRVzhm//ziJZAgSX/PcoDcBjYc6952skZDo9yyqZeOCmi3KROZ0glbd3KtydJwHIll6u z6dA== X-Gm-Message-State: AOJu0YxKbKMd6wLE1jr0029Ff6/VyuvDOr6zyf1HpzJhQaBl2jvxrRAr 7TQH/lgG1joCg/J09nb4kt0SkGXxdSXDVmYgiDk= X-Received: by 2002:a05:6402:35c5:b0:53e:6215:76ee with SMTP id z5-20020a05640235c500b0053e621576eemr229010edc.10.1697206337349; Fri, 13 Oct 2023 07:12:17 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id c25-20020aa7d619000000b0053622a35665sm11366351edr.66.2023.10.13.07.12.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:12:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Evgeny Iakovlev , =?utf-8?q?Marc-Andr=C3=A9_?= =?utf-8?q?Lureau?= , Gavin Shan , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Richard Henderson Subject: [PATCH v3 6/10] hw/char/pl011: Warn when using disabled transmitter Date: Fri, 13 Oct 2023 16:11:27 +0200 Message-ID: <20231013141131.1531-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231013141131.1531-1-philmd@linaro.org> References: <20231013141131.1531-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=philmd@linaro.org; helo=mail-ed1-x533.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=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 */