From nobody Wed Feb 5 15:49:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1737106063; cv=none; d=zohomail.com; s=zohoarc; b=SgFTeOrPnjoFvIJGZxbPdRDOZFh25boMM2JSftcmQMyU9g0j52LvG73Ch5WDngqniuycoxZVXPk22LMh7tiGwvnggf8xMcS2+UZBMm1PWCbjBj4JHy6+1DErqYkJuSq8MAB+CVC64sYGkrB9Ba1Vv/sshO9/pqCW6CYJNe1pIis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737106063; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yQ+sUuwc6C6WWkzJforxNjfkV4dPtivna2iSl2/kOD4=; b=kfpFNFQfKPrpxylMi7SwnB+jlBO9Xik/tsFjqd76mOpoC1U08l/6kJYVv0UYEHpCFnCHEXzDl8jyPxweWDOUGpNhjj9l+zhzy6JXpiFNryFeV4ZKuOViAQ+dojMEVkpG2GvhlMN9ABLWqgX24Y16/XCLLrmQ8XYOdfBD0g63DrI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17371060637371.3633377043297514; Fri, 17 Jan 2025 01:27:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tYidI-0002ZF-9K; Fri, 17 Jan 2025 04:27:16 -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 1tYidG-0002YO-3B for qemu-devel@nongnu.org; Fri, 17 Jan 2025 04:27:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYidE-0003Px-Jc for qemu-devel@nongnu.org; Fri, 17 Jan 2025 04:27:13 -0500 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-651-rXBIGrUcMWWtmO5d2d66iw-1; Fri, 17 Jan 2025 04:27:10 -0500 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-aaf8396f65fso202721966b.0 for ; Fri, 17 Jan 2025 01:27:10 -0800 (PST) Received: from [192.168.10.3] ([176.206.124.70]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab384fcec76sm136223366b.184.2025.01.17.01.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 01:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737106031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yQ+sUuwc6C6WWkzJforxNjfkV4dPtivna2iSl2/kOD4=; b=fHmQsLqdhuOqKEAMTdC5g+3PtgKB+qdnndMoRWZ6n8bgwY4S1iKuubPoogMJ/lAQ9CDKNV U975eK+vmovwH+EA6ycwwy3ZCk1+XYpA6hxedN3XJaSNV0GxjLef5ee2TVyZFjdbn0JOh9 lF6/GhKzYm2YMYvTMerCCPOIjtnUGcQ= X-MC-Unique: rXBIGrUcMWWtmO5d2d66iw-1 X-Mimecast-MFC-AGG-ID: rXBIGrUcMWWtmO5d2d66iw X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737106028; x=1737710828; 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=yQ+sUuwc6C6WWkzJforxNjfkV4dPtivna2iSl2/kOD4=; b=DvHNCzCJHZTlJEr8ByVXYXkpWD0r0LJ4Pd42kYLqege4BAW43Gg8NgxC2HP4hyhXEn KP4wYSr3hXerXfBAm75gWbl1zLc4rH6/lfcVS7ClNGKoHFXogx9Drq1isVP+gkekCCtQ PYeXx4a4x7AexlRbzY3BPGIgSANuzzrM7ywhVGEJeXq/9Ftad32Fo5jghPQVx/B1jrUJ ondkPzH6arrexKQXXGaiUhkyL0/psq964SXgwLcmnwRepGOqOap2kYdtcoARK0ofM9WT hDfOzkBYF6LmeOvOvcuLzHHYhgWBd+UzjNB0+gEnZ/AKZnOVzgNnGKedJ358SOcsubhw +xMw== X-Gm-Message-State: AOJu0YzFWCFvR1cZtbpuYwH7vIt/Ku2/Qog+7GrLMDzrOIefE+Z1vkQ/ p+t+xSPgfsxwGsOv1mg/+udshq56XAQn+35GqZeF2Ab0vubqG0107axC0qWuZSh0QC1NcqvbEmR xbF1wwOcZ+vSyXqW+h5iJLRUioJftzR21iCKN/9JJ9ewV5HEVUnrEFxTMMx/Lq/FkY3CwDvSEgU QtJ++12YjET1DwiwINcrMtCWzRkH2xz+qqH8ZFjjg= X-Gm-Gg: ASbGnct/J0UMbxxQTP5qwMd9181GV4DLGACH/WOS3tUDyRbX5/hMB9zpqvILejikV9g gfvdfNbXFOt7wB6XZS4umV8cApnW5Y1OI++kBFxThTmE6mCPOKeV+BimHtj9jBTuXyxrySltuss n3MXuhiy9BiCo8aEMZbIhHi2Ms+nvmUsGCHQVQtBSbt8SK3ZstzXHYu6AsidEz7QsdweqdOy08T rFFgzoXUr/DNZivSvXf6hZUx+tA2kB0MOqAXS03WlUbp7HTxGnUbvTp0++6 X-Received: by 2002:a17:907:2cc7:b0:aa6:9ee3:e51f with SMTP id a640c23a62f3a-ab38b377762mr207322666b.41.1737106028345; Fri, 17 Jan 2025 01:27:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgFxSLGX9Q61z3o5ZA4AS2wJlP8GSEz8jJmPmXVBKvBnkZo5ZLjwrAObdov9L/LckRkqw2Gw== X-Received: by 2002:a17:907:2cc7:b0:aa6:9ee3:e51f with SMTP id a640c23a62f3a-ab38b377762mr207319966b.41.1737106027825; Fri, 17 Jan 2025 01:27:07 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-rust@nongnu.org Subject: [PATCH 04/10] rust: pl011: extract CharBackend receive logic into a separate function Date: Fri, 17 Jan 2025 10:26:51 +0100 Message-ID: <20250117092657.1051233-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250117092657.1051233-1-pbonzini@redhat.com> References: <20250117092657.1051233-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.093, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1737106064265019000 Content-Type: text/plain; charset="utf-8" Prepare for moving all references to the registers and the FIFO into a separate struct. Signed-off-by: Paolo Bonzini Reviewed-by: Zhao Liu --- rust/hw/char/pl011/src/device.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/devi= ce.rs index 6d662865182..2e8707aef97 100644 --- a/rust/hw/char/pl011/src/device.rs +++ b/rust/hw/char/pl011/src/device.rs @@ -6,7 +6,7 @@ use std::{ ffi::CStr, ops::ControlFlow, - os::raw::{c_int, c_uint, c_void}, + os::raw::{c_int, c_void}, }; =20 use qemu_api::{ @@ -480,6 +480,12 @@ pub fn can_receive(&self) -> bool { self.read_count < self.fifo_depth() } =20 + pub fn receive(&mut self, ch: u32) { + if !self.loopback_enabled() { + self.put_fifo(ch) + } + } + pub fn event(&mut self, event: QEMUChrEvent) { if event =3D=3D bindings::QEMUChrEvent::CHR_EVENT_BREAK && !self.l= oopback_enabled() { self.put_fifo(registers::Data::BREAK.into()); @@ -505,7 +511,7 @@ pub fn fifo_depth(&self) -> u32 { 1 } =20 - pub fn put_fifo(&mut self, value: c_uint) { + pub fn put_fifo(&mut self, value: u32) { let depth =3D self.fifo_depth(); assert!(depth > 0); let slot =3D (self.read_pos + self.read_count) & (depth - 1); @@ -615,12 +621,9 @@ pub fn write(&mut self, offset: hwaddr, value: u64) { unsafe { debug_assert!(!opaque.is_null()); let mut state =3D NonNull::new_unchecked(opaque.cast::= ()); - if state.as_ref().loopback_enabled() { - return; - } if size > 0 { debug_assert!(!buf.is_null()); - state.as_mut().put_fifo(c_uint::from(buf.read_volatile())) + state.as_mut().receive(u32::from(buf.read_volatile())); } } } --=20 2.47.1