|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v8 08/26] emul/ns16x50: implement LCR/LSR registers
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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |