From patchwork Thu Nov 9 19:28:08 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: 742601 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:110f:b0:32d:baff:b0ca with SMTP id z15csp1018286wrw; Thu, 9 Nov 2023 11:30:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGbiBkUPTefka9SIjh0O3ZF7M+2ebRydOTko2j3GY8W7ZtPCBjBl1G2zmvzqmUZfywdoRL X-Received: by 2002:a05:6122:2027:b0:49e:1eca:f84d with SMTP id l39-20020a056122202700b0049e1ecaf84dmr2561380vkd.14.1699558235863; Thu, 09 Nov 2023 11:30:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699558235; cv=none; d=google.com; s=arc-20160816; b=HEa3rd//Rnj1j9JyTqeQgHRECLeqRK5X2yYQ0iw7Vi3dzQskpYo/JsGt6/HSst2pd+ i7u8Fsbwk3M1SSTQNfPuII3oYBRbCI/s1J3HeupFUjTj703hM1gVnjo20T5JojoJi4Bt z7GFJEpbTIejCl21OICf0F2ZK+H6goplf7vzC6ku8k07IqC7XkR+WfzVFRTvwFBp14Jl EwWuWhRj7qCAiAg4hGgK5/jp9LPr+K7inP1j8O2YUAZUMfHgEnfK1j2CfnLqHdksDWbp 7VxN+EP8Fou7DH2JmiQMh8tzApH05g0ERsIAyL8lkNx3v5LVxMojEQJPPMCi1lpCB7Q1 oBOw== 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=4RcEaeq0Z+56TpsJGBFP08HsnS3amqPkJQB4mf707C8=; fh=DIg4VbvV6UsIVtjymVavUODq0hsDWu0+XvIrfuGsGdI=; b=N1DZknOg+h0nuPDt1vXO64lhLHx0PPfsLo5ZyWWUVrtbWJDwWR9zXcHghvS02SkDGm 1gk2L8vNocw+VQ2+qhcI7+DAfBcd3OygCbLOO9QdHRD1uU+ZID3545YtM1OL/7C9CE7a UcYPKztEhNng4HHlIgiNeNJAmQFryv7WXTkNL6WJewD/39YxlAHA/+D9wI6O0Tfh043n tn4UZcVhLKDGFqHR7OUJubALL0HxTHPehI9V9KKZXu7fbxxOPdiiLFbRNiapVOmGVUD9 25CEO8T7l1SYu9akMO0LSGnMmko/+CyBstgI+fYjMdOIdVTtc1wARLVKul07kmynZ3js Ho3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aZ1o6QiN; 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 m12-20020ad44a0c000000b0064f72cc4bdasi3372247qvz.575.2023.11.09.11.30.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Nov 2023 11:30:35 -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=aZ1o6QiN; 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 1r1Ahs-0005FY-4u; Thu, 09 Nov 2023 14:28: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 1r1Ahp-0005Ez-Ae for qemu-devel@nongnu.org; Thu, 09 Nov 2023 14:28:45 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r1Ahm-0005HS-H9 for qemu-devel@nongnu.org; Thu, 09 Nov 2023 14:28:43 -0500 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-54553e4888bso1752534a12.2 for ; Thu, 09 Nov 2023 11:28:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699558121; x=1700162921; 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=4RcEaeq0Z+56TpsJGBFP08HsnS3amqPkJQB4mf707C8=; b=aZ1o6QiNBdtXS2EHkgqglPT6KqQ7ZPqlUY/+jTJP8kvgZJ0PMZwuTzBQE8OCxZNPHr gVuuN/MXif6I+a2X49syDP+LOidM3rUMkNX8rbh+QcjWgx2kOLk8z4Uj5m0tnu2ylQCw vIpTn6c1StNYCnWhJJfo/vjrw2ldBFuQejOoHtmTT5U6GK74NrjMzE0QcwzFzQ1kkjiK N4x7qbjw0n3dkwvdYOdMtaTh77EH1uptHdrfPIVtNlXuMgN205sev3acaF+BFVaIWVR5 cLqfWsOlnu/Nmp12d5plTIDI0q6JwoYJE6I5FKU0EKbr++WUkG9cBoe8FRM6jQ2VwytJ 5X3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699558121; x=1700162921; 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=4RcEaeq0Z+56TpsJGBFP08HsnS3amqPkJQB4mf707C8=; b=lk+shYdnytl7WjuhcxiIOCwKn4YyV+z9/TSacSmOuWVGbEsxBANGlVM/e7XhghHbWf t2aAZolqeBOyirNhukzWHSIsOAxJOSVDnt91lsQzouVWlz+uiTYP732nfzeMk97Jqu34 4EWu+cSvkeH4jy11UcXBkq/R0kZErQRNvE+s1+Bgb0E7WYqEtjEUDaDwPJSA+td2P9Jl wAB3JPWsCaLDRc9D508bnZSG/JiDKmZ0vkmR3t35M9wJHhF5SqVSEbrxmN1qnEP4EikE oKqRmhOR75HtJu/5HiD59udkSTnvIRiH4hO1uX5KxzR7YsN8S3J323DhapJPZ+c/VwFk X65A== X-Gm-Message-State: AOJu0YwJJHx1lBRnKfhgQL5Wy5rXz4cRV551VuDXpwy9b41WIep7qAOx 18+0H1H0Phi+ln4taGCunHjBSwAQZieWCaQgdI7r/w== X-Received: by 2002:a05:6402:358c:b0:545:5601:4148 with SMTP id y12-20020a056402358c00b0054556014148mr3310692edc.7.1699558120928; Thu, 09 Nov 2023 11:28:40 -0800 (PST) Received: from m1x-phil.lan ([176.187.199.161]) by smtp.gmail.com with ESMTPSA id n18-20020a05640204d200b0054554a7bbedsm181784edw.24.2023.11.09.11.28.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Nov 2023 11:28:40 -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?= Subject: [PATCH-for-8.2 v4 04/10] hw/char/pl011: Extract pl011_write_txdata() from pl011_write() Date: Thu, 9 Nov 2023 20:28:08 +0100 Message-ID: <20231109192814.95977-5-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::536; envelope-from=philmd@linaro.org; helo=mail-ed1-x536.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 When implementing FIFO, this code will become more complex. Start by factoring it out to a new pl011_write_txdata() function. No functional change intended. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée --- hw/char/pl011.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 1f07c7b021..1cb9015ea2 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -149,6 +149,17 @@ static inline void pl011_reset_tx_fifo(PL011State *s) s->flags |= PL011_FLAG_TXFE; } +static void pl011_write_txdata(PL011State *s, uint8_t data) +{ + /* ??? Check if transmitter is enabled. */ + + /* XXX this blocks entire thread. Rewrite to use + * qemu_chr_fe_write and background I/O callbacks */ + qemu_chr_fe_write_all(&s->chr, &data, 1); + s->int_level |= INT_TX; + pl011_update(s); +} + static uint64_t pl011_read(void *opaque, hwaddr offset, unsigned size) { @@ -262,19 +273,13 @@ static void pl011_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { PL011State *s = (PL011State *)opaque; - unsigned char ch; trace_pl011_write(offset, value, pl011_regname(offset)); switch (offset >> 2) { case 0: /* UARTDR */ - /* ??? Check if transmitter is enabled. */ - ch = value; - /* XXX this blocks entire thread. Rewrite to use - * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&s->chr, &ch, 1); - s->int_level |= INT_TX; - pl011_update(s); + s->readbuff = value; + pl011_write_txdata(s, value); break; case 1: /* UARTRSR/UARTECR */ s->rsr = 0;