From nobody Tue Feb 10 11:13:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1757365938; cv=none; d=zohomail.com; s=zohoarc; b=erbBS4KbvY7br2sm73u0M8CZiJVbuyaUxxGQyqRe9MrTXyQjmnO1oXQaCK/M8OZaoDqPN0+5vDUuPX1VA4LfVXrKL9MuYVQY9HoklIex8aTNW3rENh1/6tHO08Pr0xycpewcQGKk1aR8T3R2OI1gJYoHT/u9bO454+odQDVjgLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757365938; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NWRpmqJhOTOIY3zhSnhQ9LFHXgJeUqzoWYVvV58DwuQ=; b=nRK7asdR2ENAX7KfcNRz3AaQ22DcFzPd56WxTG7CkuhKn4y/1Ce5CuS2jSKusCVWcHruqjX3fXEtmoIQ/v/Vo9xapvbEk0/hOY3aWbY02w9ozMS4sjZGpL1uHUs137FC0F0PZUFHWuCy0w4XSowETZ77vLhsYWRnq8xJj93NOFk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1757365938603396.38456889655004; Mon, 8 Sep 2025 14:12:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1115537.1462115 (Exim 4.92) (envelope-from ) id 1uvj9a-0008QR-3e; Mon, 08 Sep 2025 21:11:58 +0000 Received: by outflank-mailman (output) from mailman id 1115537.1462115; Mon, 08 Sep 2025 21:11:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uvj9Z-0008QI-To; Mon, 08 Sep 2025 21:11:57 +0000 Received: by outflank-mailman (input) for mailman id 1115537; Mon, 08 Sep 2025 21:11:56 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uvj9Y-0008DO-Su for xen-devel@lists.xenproject.org; Mon, 08 Sep 2025 21:11:56 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1uvj9Y-000FSp-1Q; Mon, 08 Sep 2025 21:11:56 +0000 Received: from [19.12.91.86] (helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uvj9Y-000gKu-1d; Mon, 08 Sep 2025 21:11:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From; bh=NWRpmqJhOTOIY3zhSnhQ9LFHXgJeUqzoWYVvV58DwuQ=; b=QfQCzboiEv5kPwQ8hac1qgJUSu WVT/GvMWfIpHz9k78XZcH5ZjiWa0/w3fE0w+ifdBNX1vYlvmkYN8zxvgnmrnS2TiEmvpU/jAlGYK/ b9CiyvuZljKoLIOkOO2Gpspcp9y58R1u42i8fEpj4L12/LRDZvmH5oK4A7FCJrLVpx8Q=; From: dmukhin@xen.org To: xen-devel@lists.xenproject.org Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v7 04/16] emul/ns16x50: implement DLL/DLM registers Date: Mon, 8 Sep 2025 14:11:37 -0700 Message-ID: <20250908211149.279143-5-dmukhin@ford.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250908211149.279143-1-dmukhin@ford.com> References: <20250908211149.279143-1-dmukhin@ford.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1757365941386124100 Content-Type: text/plain; charset="utf-8" From: Denis Mukhin =20 Add DLL/DLM registers emulation. DLL/DLM registers report hardcoded 115200 baud rate to the guest OS. Add stub for ns16x50_dlab_get() helper. Signed-off-by: Denis Mukhin Reviewed-by: Mykola Kvach --- Changes since v6: - added default registers handling for non-DLL/DLM accesses - used UINT8_MAX --- xen/common/emul/vuart/ns16x50.c | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/xen/common/emul/vuart/ns16x50.c b/xen/common/emul/vuart/ns16x5= 0.c index a3bdf9f415ca..da8583a1dc93 100644 --- a/xen/common/emul/vuart/ns16x50.c +++ b/xen/common/emul/vuart/ns16x50.c @@ -96,8 +96,22 @@ static uint8_t ns16x50_dlab_get(const struct vuart_ns16x= 50 *vdev) static int ns16x50_io_write8( struct vuart_ns16x50 *vdev, uint32_t reg, uint8_t *data) { + uint8_t *regs =3D vdev->regs; + uint8_t val =3D *data; int rc =3D 0; =20 + if ( ns16x50_dlab_get(vdev) && (reg =3D=3D UART_DLL || reg =3D=3D UART= _DLM) ) + regs[NS16X50_REGS_NUM + reg] =3D val; + else + { + switch ( reg ) + { + default: + rc =3D -EINVAL; + break; + } + } + return rc; } =20 @@ -108,8 +122,16 @@ static int ns16x50_io_write8( static int ns16x50_io_write16( struct vuart_ns16x50 *vdev, uint32_t reg, uint16_t *data) { + uint16_t val =3D *data; int rc =3D -EINVAL; =20 + if ( ns16x50_dlab_get(vdev) && reg =3D=3D UART_DLL ) + { + vdev->regs[NS16X50_REGS_NUM + UART_DLL] =3D val & UINT8_MAX; + vdev->regs[NS16X50_REGS_NUM + UART_DLM] =3D (val >> 8) & UINT8_MAX; + rc =3D 0; + } + return rc; } =20 @@ -145,9 +167,22 @@ static int ns16x50_io_write( static int ns16x50_io_read8( struct vuart_ns16x50 *vdev, uint32_t reg, uint8_t *data) { + uint8_t *regs =3D vdev->regs; uint8_t val =3D UINT8_MAX; int rc =3D 0; =20 + if ( ns16x50_dlab_get(vdev) && (reg =3D=3D UART_DLL || reg =3D=3D UART= _DLM) ) + val =3D regs[NS16X50_REGS_NUM + reg]; + else + { + switch ( reg ) + { + default: + rc =3D -EINVAL; + break; + } + } + *data =3D val; =20 return rc; @@ -162,6 +197,13 @@ static int ns16x50_io_read16( uint16_t val =3D UINT16_MAX; int rc =3D -EINVAL; =20 + if ( ns16x50_dlab_get(vdev) && reg =3D=3D UART_DLL ) + { + val =3D vdev->regs[NS16X50_REGS_NUM + UART_DLM] << 8 | + vdev->regs[NS16X50_REGS_NUM + UART_DLL]; + rc =3D 0; + } + *data =3D val; =20 return rc; @@ -278,12 +320,17 @@ out: =20 static int ns16x50_init(void *arg) { + const uint16_t divisor =3D (UART_CLOCK_HZ / 115200) >> 4; struct vuart_ns16x50 *vdev =3D arg; const struct vuart_info *info =3D vdev->info; struct domain *d =3D vdev->owner; =20 ASSERT(vdev); =20 + /* NB: report 115200 baud rate. */ + vdev->regs[NS16X50_REGS_NUM + UART_DLL] =3D divisor & UINT8_MAX; + vdev->regs[NS16X50_REGS_NUM + UART_DLM] =3D (divisor >> 8) & UINT8_MAX; + register_portio_handler(d, info->base_addr, info->size, ns16x50_io_han= dle); =20 return 0; --=20 2.51.0