From patchwork Fri Oct 13 14:11:28 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: 733229 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1489987wrv; Fri, 13 Oct 2023 07:13:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+liiJR+xxtxeygxisYtNIsPgUijkeaw7PIMO8u6yyjJfYipx/9bTJcgdl/41Xq+Jd+FcW X-Received: by 2002:ac8:7f49:0:b0:417:b975:6d85 with SMTP id g9-20020ac87f49000000b00417b9756d85mr406278qtk.5.1697206432280; Fri, 13 Oct 2023 07:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697206432; cv=none; d=google.com; s=arc-20160816; b=TtQPBCmBr1he88HtLXR4STqGro/OXpUhZutnSnwUoeoCAZKNl1TkrY1xTOYgMwqdZ2 s3plYL4v+wawmo7plBFp/SonXWFq1Dcgev6whuXIjsCRCU+6N2HIRP9uygJ6SdW13uAR nzmSjMV60TdRnuqA+EZBxjiRaQC+RwxPEhNv1ED/lttyS4Mvv58N2rv3WS3vznvNjTqI 8+bBowi3lL2DRMdlHPbtcJboqr7NRjTGzK2EPrSXn010HyfeqChMkSSVz+s7e8v88u04 jP3g6ML5sVhR1Kl2C/XCUVg1ZYR9DJ7icWgn42p4wo2KYUZQ4BbeUuOkeOjXP2sY41bQ M9jw== 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=FHrHAGB/EmMRyrEmXuczDQ4ZEQoq+gXqneExLSOiqGU=; fh=MusjSs7gXCZ/MKYOlww+3pkKR+FOAC+Wy5x6PlCIutc=; b=d/l9/StoJwYKB1PYzeeqFC6yDUihoalKwCx92a9BZ5AztFvL+FWmoqhBitQE0mStdH D+ghF2AUfhXOJikn+softVairpp7B5gKjw5vB4w6AQoo69ESVEztnK4Ah3OwRNeLKxG9 RUFrcjvQxBxrAXIlQTFggX/OLNjEwVamHj2nwBNcZOhcyA0IMk7mVhY/JJ8N/HptvKqI 6x8zy+dkfFUtDQGnMDttYMpTOCi54DrBA05OoBtcGryg/mZBeiUnRnXoTaU4cQOshkx7 KNyjCIp/jLXpKcdgJuqz6ukAbI/B2b0ljfjZYNXpBoAkjE+usGZhZCU4K/hIqZq98zmD XKPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l4LTrDoI; 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 w14-20020ac87e8e000000b00411838ef9d3si1213970qtj.552.2023.10.13.07.13.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Oct 2023 07:13:52 -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=l4LTrDoI; 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 1qrIu5-0000e4-Bw; Fri, 13 Oct 2023 10:12:37 -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 1qrItu-0000Uo-RH for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:27 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrItt-0004aD-EO for qemu-devel@nongnu.org; Fri, 13 Oct 2023 10:12:26 -0400 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-53d8320f0easo3615077a12.3 for ; Fri, 13 Oct 2023 07:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697206343; x=1697811143; 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=FHrHAGB/EmMRyrEmXuczDQ4ZEQoq+gXqneExLSOiqGU=; b=l4LTrDoIAZJWVT43yCCbr8T2C1CHBzuzb2SiOp3AyEzBEaeJ42bWEaFTZaSb8eScH7 rt5uFQj3PJwUlK9APa/hOw4slO5UIE+WtgIlDvgbqNWIkvuCmMMBr4qXsSfrgTCAs36c TT1CzS49gZ8CFN3xYAeqUqGQoPhRFX7IxB5uaQQ4UtdStENGf6R/kT4ORkfhcPqiSM0f uyWjIapXEbKFYmLUsLG3ZGQB+4j5V/OV/fURZPR3XjKtLFy15fVgJYJ2FK3FVLlWsyNS yPtB6EPOugQMTp0U+EX8r2aqfmsd992IJT2OujTV6+6UQHIGa08UOwxEUdaSVbO8q44O 5/1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697206343; x=1697811143; 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=FHrHAGB/EmMRyrEmXuczDQ4ZEQoq+gXqneExLSOiqGU=; b=YZrPpss1fhffsKCUEpgjzVcEvNS2WGQe7g4sC6ntAXTISfzU+h6d6BSH/0nc8BYIDD qrJlBcpEcN0AUc0L/c7paPHjYZCJW3Tc8bj+JjBXNolvMPKBfOGP5BN1Fh6AAwIiFqrl wN/qqjMTzpcvBc2z3i/6RMujFIsqIzKoV82SCfMyK7Qx+O8fRhFABLYy6OdAtXW1t/Sr 0ShRnxpa2MofHyFve/i+Y6av5du+UbBIqRpb3GvZLMQgZRC6qUM8o9SLZtPuSAJ4YcZf tXCRqbbcuhHLJtYxa9ViXfAkfZMr8IVeZYr/KVPiODsm1thUryUc4fg1Y/ZudZvL5cGQ UXWQ== X-Gm-Message-State: AOJu0Yyl1iwO7x+idL1EYRMC2JgRAnbDfGIDYld/0PD51rmXE1YYRFPj K9HLvTO7k2b9KUmoesL3Mld9ZH3NN3n96fqHNPY= X-Received: by 2002:a50:ef0d:0:b0:522:2782:537 with SMTP id m13-20020a50ef0d000000b0052227820537mr23076679eds.15.1697206343741; Fri, 13 Oct 2023 07:12:23 -0700 (PDT) Received: from m1x-phil.lan ([176.172.118.168]) by smtp.gmail.com with ESMTPSA id r19-20020a056402035300b00522828d438csm11613766edw.7.2023.10.13.07.12.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Oct 2023 07:12:23 -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 7/10] hw/char/pl011: Check if receiver is enabled Date: Fri, 13 Oct 2023 16:11:28 +0200 Message-ID: <20231013141131.1531-8-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::532; envelope-from=philmd@linaro.org; helo=mail-ed1-x532.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 Do not receive characters when UART or receiver are disabled. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- TODO: Understand Richard comment from v2: this doesn't fall under "my first assembly program" because it isn't part of "Hello, World"? --- hw/char/pl011.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 9c43cb47bf..ca931be139 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -77,6 +77,7 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) #define LCR_BRK (1 << 0) /* Control Register, UARTCR */ +#define CR_RXE (1 << 9) #define CR_TXE (1 << 8) #define CR_UARTEN (1 << 0) @@ -359,9 +360,11 @@ static void pl011_write(void *opaque, hwaddr offset, static int pl011_can_receive(void *opaque) { PL011State *s = (PL011State *)opaque; - int r; + int r = 0; - r = s->read_count < pl011_get_fifo_depth(s); + if ((s->cr & CR_UARTEN) && (s->cr & CR_RXE)) { + r = s->read_count < pl011_get_fifo_depth(s); + } trace_pl011_can_receive(s->lcr, s->read_count, r); return r; }