[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v8 08/26] emul/ns16x50: implement LCR/LSR registers


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: dmukhin@xxxxxxxx
  • Date: Wed, 11 Nov 2026 11:47:42 -0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 205.220.161.53) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=ford.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ford.com; dkim=pass (signature was verified) header.d=saarlouis.ford.com; dkim=pass (signature was verified) header.d=ford.com; arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=v2kvR+Ec+T4C4PHBWYoq3PynaEwFo2mHifgK03yjxc4=; b=pW8GQFlQNJWLWKtgSIsfwPD9hsb9kf3uMussIlZx9dgIRVuB+XZr/AcQL2kK6gK2KDqa55HOd32b73uwDLfSyZtuVXsdMOe4KX9uZp1wuuD/LW3cpwwqlOXgqfszO01OpmBg0SKchorGM8yfDmSFIjK6EIMt33Bzfqp4omolwWAsUW067oWgtdTqqhNokhWGYu9s0aSTSBTpvEqMONOm2wpBOWz8wYuoy1eDKvCJSrrqY27OeKFzZQhk/13qikM45RESt9JOdVvwlj3qu8wmc/8Yzrw4InqAI/rp6LN6iLcl3qAGq6cjBg1h1YaU+DEeDpjUaw4H6LgghqLEIyzgig==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FfvV/A5cgau6pvB327dnt4A1Cqx0ZbmS8c4sUGXbnBIhfbs6EOjDDz/kAVapCveEO67k6TGiuJtTH43m68O0IpHscFFcqhuOZRW8U5fgyqC+ZoXmept1dQcYJFvAmexCpd7mbHt1jLl9Q+XURIrROjohM6Pp5yZI8ketUBa1nHNb+armEnLtPBPwrrmiTIiRPcGt6kIVlb2ja9jZUWoYu5G1UVM4HvkNgBmpAhX665zzBWAWldMk+aFSjzQytSbhbVK0CX9j9MEgQRDynrqFV2KaS4Im8v264kHNnoZXxscORDPf82b5YgiYLdvNV1kp+3d3nlDVKOvCh70KXTOWNQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=ppford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=selector2-azureford-onmicrosoft-com header.d=azureford.onmicrosoft.com header.i="@azureford.onmicrosoft.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=ppserprodsaar header.d=saarlouis.ford.com header.i="@saarlouis.ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=ppfserpocford header.d=ford.com header.i="@ford.com" header.h="Cc:Content-Transfer-Encoding:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"
  • Cc: andrew.cooper3@xxxxxxxxxx, anthony.perard@xxxxxxxxxx, jbeulich@xxxxxxxx, julien@xxxxxxx, michal.orzel@xxxxxxx, roger@xxxxxxxxxxxxxx, sstabellini@xxxxxxxxxx, xakep.amatop@xxxxxxxxx, dmukhin@xxxxxxx, Denis Mukhin <dmukhin@xxxxxxxx>
  • Delivery-date: Wed, 11 Nov 2026 19:49:47 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Pser-m365-app: SER-APP

From: Denis Mukhin <dmukhin@xxxxxxxx>

Add LCR/LSR registers implementation to the I/O port handler.

Add implementation of ns16x50_dlab_get() and ns16x50_iir_check_lsi().

Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
 xen/common/emul/vuart/ns16x50.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/xen/common/emul/vuart/ns16x50.c b/xen/common/emul/vuart/ns16x50.c
index 7c5cdc99cfa7..e80815ccf6e2 100644
--- a/xen/common/emul/vuart/ns16x50.c
+++ b/xen/common/emul/vuart/ns16x50.c
@@ -64,6 +64,11 @@ do { \
 #define ns16x50_debug(vdev, fmt, args...) \
     ns16x50_log(3, XENLOG_DEBUG, vdev, fmt, ## args)
 
+/*
+ * Helper register definitions.
+ */
+#define UART_LSR_MASK           (UART_LSR_OE | UART_LSR_BI)
+
 /*
  * Number of supported registers in the UART.
  */
@@ -116,7 +121,7 @@ static inline void ns16x50_unlock(struct vuart_ns16x50 
*vdev,
 
 static bool cf_check ns16x50_iir_check_lsi(const struct vuart_ns16x50 *vdev)
 {
-    return false;
+    return vdev->regs[UART_LSR] & UART_LSR_MASK;
 }
 
 static bool cf_check ns16x50_iir_check_rda(const struct vuart_ns16x50 *vdev)
@@ -245,11 +250,16 @@ static int ns16x50_io_write8(
         }
         break;
 
+    case UART_LCR:
+        regs[UART_LCR] = val;
+        break;
+
     /* NB: Firmware (e.g. OVMF) may rely on SCR presence. */
     case UART_SCR:
         regs[UART_SCR] = val;
         break;
 
+    case UART_LSR: /* RO */
     default:
         rc = -EINVAL;
         break;
@@ -346,6 +356,15 @@ static int ns16x50_io_read8(
         val = ns16x50_iir_get(vdev);
         break;
 
+    case UART_LCR:
+        val = regs[UART_LCR];
+        break;
+
+    case UART_LSR:
+        val = regs[UART_LSR];
+        regs[UART_LSR] = val & ~UART_LSR_MASK;
+        break;
+
     case UART_SCR:
         val = regs[UART_SCR];
         break;
@@ -509,6 +528,8 @@ static void ns16x50_reset(struct vuart_ns16x50 *vdev)
     memset(vdev->regs, 0, sizeof(vdev->regs));
     vdev->irq_asserted = false;
 
+    vdev->regs[UART_LSR] = UART_LSR_THRE | UART_LSR_TEMT;
+
     /* NB: report 115200 baud rate. */
     vdev->regs[NS16X50_REGS_NUM + UART_DLL] = divisor & UINT8_MAX;
     vdev->regs[NS16X50_REGS_NUM + UART_DLM] = (divisor >> 8) & UINT8_MAX;
-- 
2.56.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.