Skip to contentSkip to conversation

Emulate virtual UART for DOM0 and some UART clean up

PATCH In review Julien Grall 4 participants 17 messages Aug 1, 2013 – Aug 8, 2013 Arm Samsung Exynos

lore
Share & tools
lore
#0 lore raw

v3 cover Emulate virtual UART for DOM0 and some UART clean up

Hi,

This third version of this patch series. It follows the thread
http://patches.linaro.org/18358/ on Linux mailing list.

In some configuration, the kernel can use hardcoded code to access to the UART (for instance early printk). If Xen has stolen the UART for its own use, DOM0 will abort because Xen has not mapped to DOM0 the UART memory.

With this patch series, Xen will "replace" the real UART by a basic virtual UART for DOM0.

For the moment, this patch series is not able to cooperate with early printk in guest kernel.

This patch series also contains clean up for the pl011 and exynos4210 drivers.

For all the changes see the different patches.

Julien Grall (7):
pl011: Move registers' definition in a separate file xen/arm: Use define instead of hardcoded value in debug-pl011 xen/arm: New callback in uart_driver to retrieve serial information xen/arm: Implement a virtual UART
exynos4210: rename UTRSTAT_TX_EMPTY in UTRSTAT_TXFE
exynos4210: Implement vuart_info callback
pl011: Implement vuart_info callback

 xen/arch/arm/Makefile                   |    2 +-
 xen/arch/arm/arm32/debug-exynos4210.inc |    2 +-
 xen/arch/arm/arm32/debug-pl011.inc      |   18 ++--
 xen/arch/arm/domain.c                   |   12 ++-
 xen/arch/arm/io.c                       |    2 +-
 xen/arch/arm/io.h                       |    2 +-
 xen/arch/arm/vpl011.c                   |  152 -------------------------------
 xen/arch/arm/vpl011.h                   |   35 -------
 xen/arch/arm/vuart.c                    |  150 ++++++++++++++++++++++++++++++
 xen/arch/arm/vuart.h                    |   35 +++++++
 xen/drivers/char/exynos4210-uart.c      |   15 +++
 xen/drivers/char/pl011.c                |   63 ++++---------
 xen/drivers/char/serial.c               |    8 ++
 xen/include/asm-arm/domain.h            |   14 +--
 xen/include/asm-arm/exynos4210-uart.h   |    3 +-
 xen/include/asm-arm/pl011-uart.h        |   81 ++++++++++++++++
 xen/include/xen/serial.h                |   13 +++
 17 files changed, 350 insertions(+), 257 deletions(-)
 delete mode 100644 xen/arch/arm/vpl011.c
 delete mode 100644 xen/arch/arm/vpl011.h
 create mode 100644 xen/arch/arm/vuart.c
 create mode 100644 xen/arch/arm/vuart.h
 create mode 100644 xen/include/asm-arm/pl011-uart.h
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v3 1/7 pl011: Move registers' definition in a separate file

---
Changes in v3:
- Add missing s-o-b

---
 xen/drivers/char/pl011.c         |   48 +----------------------
 xen/include/asm-arm/pl011-uart.h |   80 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 47 deletions(-)
 create mode 100644 xen/include/asm-arm/pl011-uart.h
xen/drivers/char/pl011.c +1 -47
index 9456f20..fd87e68 100644
@@ -28,6 +28,7 @@
 #include <asm/device.h>
 #include <xen/mm.h>
 #include <xen/vmap.h>
+#include <asm/pl011-uart.h>
 
 static struct pl011 {
     unsigned int baud, clock_hz, data_bits, parity, stop_bits;
@@ -41,53 +42,6 @@ static struct pl011 {
     /* bool_t probing, intr_works; */
 } pl011_com = {0};
 
-/* PL011 register addresses */
-#define DR     (0x00)
-#define RSR    (0x04)
-#define FR     (0x18)
-#define ILPR   (0x20)
-#define IBRD   (0x24)
-#define FBRD   (0x28)
-#define LCR_H  (0x2c)
-#define CR     (0x30)
-#define IFLS   (0x34)
-#define IMSC   (0x38)
-#define RIS    (0x3c)
-#define MIS    (0x40)
-#define ICR    (0x44)
-#define DMACR  (0x48)
-
-/* CR bits */
-#define RXE    (1<<9) /* Receive enable */
-#define TXE    (1<<8) /* Transmit enable */
-#define UARTEN (1<<0) /* UART enable */
-
-/* FR bits */
-#define TXFE   (1<<7) /* TX FIFO empty */
-#define RXFE   (1<<4) /* RX FIFO empty */
-
-/* LCR_H bits */
-#define SPS    (1<<7) /* Stick parity select */
-#define FEN    (1<<4) /* FIFO enable */
-#define STP2   (1<<3) /* Two stop bits select */
-#define EPS    (1<<2) /* Even parity select */
-#define PEN    (1<<1) /* Parity enable */
-#define BRK    (1<<0) /* Send break */
-
-/* Interrupt bits (IMSC, MIS, ICR) */
-#define OEI   (1<<10) /* Overrun Error interrupt mask */
-#define BEI   (1<<9)  /* Break Error interrupt mask */
-#define PEI   (1<<8)  /* Parity Error interrupt mask */
-#define FEI   (1<<7)  /* Framing Error interrupt mask */
-#define RTI   (1<<6)  /* Receive Timeout interrupt mask */
-#define TXI   (1<<5)  /* Transmit interrupt mask */
-#define RXI   (1<<4)  /* Receive interrupt mask */
-#define DSRMI (1<<3)  /* nUARTDSR Modem interrupt mask */
-#define DCDMI (1<<2)  /* nUARTDCD Modem interrupt mask */
-#define CTSMI (1<<1)  /* nUARTCTS Modem interrupt mask */
-#define RIMI  (1<<0)  /* nUARTRI Modem interrupt mask */
-#define ALLI  OEI|BEI|PEI|FEI|RTI|TXI|RXI|DSRMI|DCDMI|CTSMI|RIMI
-
 /* These parity settings can be ORed directly into the LCR. */
 #define PARITY_NONE  (0)
 #define PARITY_ODD   (PEN)
xen/include/asm-arm/pl011-uart.h new file +80 -0

80 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v3 2/7 xen/arm: Use define instead of hardcoded value in debug-pl011

In reply to Julien Grall
---
 xen/arch/arm/arm32/debug-pl011.inc |   18 ++++++++++--------
 xen/include/asm-arm/pl011-uart.h   |    1 +
 2 files changed, 11 insertions(+), 8 deletions(-)
xen/arch/arm/arm32/debug-pl011.inc +10 -8
index 8b085b8..6a64dbf 100644
@@ -16,19 +16,21 @@
  * GNU General Public License for more details.
  */
 
+#include <asm/pl011-uart.h>
+
 /* PL011 UART initialization
  * rb: register which contains the UART base address
  * rc: scratch register 1
  * rd: scratch register 2 (unused here) */
 .macro early_uart_init rb, rc, rd
         mov   \rc, #(7372800 / EARLY_PRINTK_BAUD % 16)
-        str   \rc, [\rb, #0x28]     /* -> UARTFBRD (Baud divisor fraction) */
+        str   \rc, [\rb, #FBRD]     /* -> UARTFBRD (Baud divisor fraction) */
         mov   \rc, #(7372800 / EARLY_PRINTK_BAUD / 16)
-        str   \rc, [\rb, #0x24]     /* -> UARTIBRD (Baud divisor integer) */
+        str   \rc, [\rb, #IBRD]     /* -> UARTIBRD (Baud divisor integer) */
         mov   \rc, #0x60            /* 8n1 */
-        str   \rc, [\rb, #0x2C]     /* -> UARTLCR_H (Line control) */
-        ldr   \rc, =0x00000301      /* RXE | TXE | UARTEN */
-        str   \rc, [\rb, #0x30]     /* -> UARTCR (Control Register) */
+        str   \rc, [\rb, #LCR_H]     /* -> UARTLCR_H (Line control) */
+        ldr   \rc, =(RXE | TXE | UARTEN)      /* RXE | TXE | UARTEN */
+        str   \rc, [\rb, #CR]     /* -> UARTCR (Control Register) */
 .endm
 
 /* PL011 UART wait UART to be ready to transmit
@@ -36,8 +38,8 @@
  * rc: scratch register */
 .macro early_uart_ready rb, rc
 1:
-        ldr   \rc, [\rb, #0x18]     /* <- UARTFR (Flag register) */
-        tst   \rc, #0x8             /* Check BUSY bit */
+        ldr   \rc, [\rb, #FR]       /* <- UARTFR (Flag register) */
+        tst   \rc, #BUSY             /* Check BUSY bit */
         bne   1b                    /* Wait for the UART to be ready */
 .endm
 
@@ -45,7 +47,7 @@
  * rb: register which contains the UART base address
  * rt: register which contains the character to transmit */
 .macro early_uart_transmit rb, rt
-        str   \rt, [\rb]            /* -> UARTDR (Data Register) */
+        str   \rt, [\rb, #DR]            /* -> UARTDR (Data Register) */
 .endm
 
 /*
xen/include/asm-arm/pl011-uart.h +1 -0
index 8c4edd4..3332c51 100644
@@ -45,6 +45,7 @@
 /* FR bits */
 #define TXFE   (1<<7) /* TX FIFO empty */
 #define RXFE   (1<<4) /* RX FIFO empty */
+#define BUSY   (1<<3) /* Transmit is not complete */
 
 /* LCR_H bits */
 #define SPS    (1<<7) /* Stick parity select */
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v3 3/7 xen/arm: New callback in uart_driver to retrieve serial information

In reply to Julien Grall

There is no way to retrieve basic informations (base address, size, ....) for an UART. This callback will be used later to partially emulate the real UART for DOM0 on ARM.

---
Changes in v3:
- Use paddr_t for the base_address field
Changes in v2:
- Rename the callback to vuart_info

---
 xen/drivers/char/serial.c |    8 ++++++++
 xen/include/xen/serial.h  |   13 +++++++++++++
 2 files changed, 21 insertions(+)
xen/drivers/char/serial.c +8 -0
index e1c3f47..cd0b864 100644
@@ -497,6 +497,14 @@ const struct dt_irq __init *serial_dt_irq(int idx)
     return NULL;
 }
 
+const struct vuart_info *serial_vuart_info(int idx)
+{
+    if ( (idx >= 0) && (idx < ARRAY_SIZE(com)) &&
+         com[idx].driver && com[idx].driver->vuart_info )
+        return com[idx].driver->vuart_info(&com[idx]);
+
+    return NULL;
+}
 
 void serial_suspend(void)
 {
xen/include/xen/serial.h +13 -0
index 9caf776..403e193 100644
@@ -32,6 +32,14 @@ enum serial_port_state {
     serial_initialized
 };
 
+struct vuart_info {
+    paddr_t base_addr;          /* Base address of the UART */
+    unsigned long size;         /* Size of the memory region */
+    unsigned long data_off;     /* Data register offset */
+    unsigned long status_off;   /* Status register offset */
+    unsigned long status;       /* Ready status value */
+};
+
 struct serial_port {
     /* Uart-driver parameters. */
     struct uart_driver *driver;
@@ -74,6 +82,8 @@ struct uart_driver {
     int  (*irq)(struct serial_port *);
     /* Get IRQ device node for this port's serial line: returns NULL if none. */
     const struct dt_irq *(*dt_irq_get)(struct serial_port *);
+    /* Get serial information */
+    const struct vuart_info *(*vuart_info)(struct serial_port *);
 };
 
 /* 'Serial handles' are composed from the following fields. */
@@ -127,6 +137,9 @@ int serial_irq(int idx);
 /* Return irq device node for specified serial port (identified by index). */
 const struct dt_irq *serial_dt_irq(int idx);
 
+/* Retrieve basic UART information to emulate it (base address, size...) */
+const struct vuart_info* serial_vuart_info(int idx);
+
 /* Serial suspend/resume. */
 void serial_suspend(void);
 void serial_resume(void);
Signature · 1 line
1.7.10.4
Reviewed-by on v3 3/7
#4 lore raw

Re: [PATCH v3 3/7] xen/arm: New callback in uart_driver to retrieve serial information

Quoted 5 lines · Julien Grall

There is no way to retrieve basic informations (base address, size, ....) for an UART. This callback will be used later to partially emulate the real UART for DOM0 on ARM.

Acked-by on v3 3/7
#5 lore raw

Re: [PATCH v3 3/7] xen/arm: New callback in uart_driver to retrieve serial information

In reply to Julien Grall
Quoted 6 lines · Julien Grall

There is no way to retrieve basic informations (base address, size, ....) for an UART. This callback will be used later to partially emulate the real UART for DOM0 on ARM.

Quoted 2 lines

---

#6 lore raw

PATCH v3 4/7 xen/arm: Implement a virtual UART

In reply to Julien Grall

This code is based on the previous vuart0 implementation. Unlike the latter, it's intend to replace UART stolen by XEN to DOM0 via dtuart=... on its command line.

It's useful when the kernel is compiled with early printk enabled or for a single platform. Most of the time, the hardcoded code to handle the UART will need 2 registers: status and data, the others registers can be implemented as RAZ/WI.

This commit will also drop support of early printk (based on vexpress pl011) in the guest.

---
Changes in v3:
- Fix typo
- Don't use "current" in vuart_print_char
- Remove unnecessary cast
- Update changeset
Changes in v2:
- Merge and update comments
- Use the renamed callback

---
 xen/arch/arm/Makefile        |    2 +-
 xen/arch/arm/domain.c        |   12 ++--
 xen/arch/arm/io.c            |    2 +-
 xen/arch/arm/io.h            |    2 +-
 xen/arch/arm/vpl011.c        |  152 ------------------------------------------
 xen/arch/arm/vpl011.h        |   35 ----------
 xen/arch/arm/vuart.c         |  150 +++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/vuart.h         |   35 ++++++++++
 xen/include/asm-arm/domain.h |   14 ++--
 9 files changed, 204 insertions(+), 200 deletions(-)
 delete mode 100644 xen/arch/arm/vpl011.c
 delete mode 100644 xen/arch/arm/vpl011.h
 create mode 100644 xen/arch/arm/vuart.c
 create mode 100644 xen/arch/arm/vuart.h
xen/arch/arm/Makefile +1 -1
index 5c13a65..003ac84 100644
@@ -27,7 +27,7 @@ obj-y += shutdown.o
 obj-y += traps.o
 obj-y += vgic.o
 obj-y += vtimer.o
-obj-y += vpl011.o
+obj-y += vuart.o
 obj-y += hvm.o
 obj-y += device.o
 obj-y += decode.o
xen/arch/arm/domain.c +8 -4
index 4e9cece..cb0424d 100644
@@ -32,7 +32,7 @@
 
 #include <asm/gic.h>
 #include "vtimer.h"
-#include "vpl011.h"
+#include "vuart.h"
 
 DEFINE_PER_CPU(struct vcpu *, curr_vcpu);
 
@@ -525,8 +525,12 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)
     if ( (rc = vcpu_domain_init(d)) != 0 )
         goto fail;
 
-    /* Domain 0 gets a real UART not an emulated one */
-    if ( d->domain_id && (rc = domain_uart0_init(d)) != 0 )
+    /*
+     * Virtual UART is only used by linux early printk and decompress code.
+     * Only use it for dom0 because the linux kernel may not support
+     * multi-platform.
+     */
+    if ( (d->domain_id == 0) && (rc = domain_vuart_init(d)) )
         goto fail;
 
     return 0;
@@ -542,7 +546,7 @@ void arch_domain_destroy(struct domain *d)
 {
     p2m_teardown(d);
     domain_vgic_free(d);
-    domain_uart0_free(d);
+    domain_vuart_free(d);
     free_xenheap_page(d->shared_info);
 }
 
xen/arch/arm/io.c +1 -1
index ad28c26..a6db00b 100644
@@ -25,7 +25,7 @@
 static const struct mmio_handler *const mmio_handlers[] =
 {
     &vgic_distr_mmio_handler,
-    &uart0_mmio_handler,
+    &vuart_mmio_handler,
 };
 #define MMIO_HANDLER_NR ARRAY_SIZE(mmio_handlers)
 
xen/arch/arm/io.h +1 -1
index 661dce1..8d252c0 100644
@@ -41,7 +41,7 @@ struct mmio_handler {
 };
 
 extern const struct mmio_handler vgic_distr_mmio_handler;
-extern const struct mmio_handler uart0_mmio_handler;
+extern const struct mmio_handler vuart_mmio_handler;
 
 extern int handle_mmio(mmio_info_t *info);
 
xen/arch/arm/vpl011.c deleted +0 -152

152 lines not on this page · raw message

xen/arch/arm/vpl011.h deleted +0 -35
deleted file mode 100644
index f0d0a82..0000000
@@ -1,35 +0,0 @@
-/*
- * xen/arch/arm/vpl011.h
- *
- * ARM PL011 Emulation Support
- *
- * Ian Campbell <[email protected]>
- * Copyright (c) 2012 Citrix Systems.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#ifndef __ARCH_ARM_VPL011_H__
-#define __ARCH_ARM_VPL011_H__
-
-extern int domain_uart0_init(struct domain *d);
-extern void domain_uart0_free(struct domain *d);
-
-#endif
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
xen/arch/arm/vuart.c new file +150 -0

150 lines not on this page · raw message

xen/arch/arm/vuart.h new file +35 -0
new file mode 100644
index 0000000..9445e50
@@ -0,0 +1,35 @@
+/* 
+ * xen/arch/arm/vuart.h
+ *
+ * Virtual UART Emulation Support
+ *
+ * Ian Campbell <[email protected]>
+ * Copyright (c) 2012 Citrix Systems.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __ARCH_ARM_VUART_H__
+#define __ARCH_ARM_VUART_H__
+
+int domain_vuart_init(struct domain *d);
+void domain_vuart_free(struct domain *d);
+
+#endif /* __ARCH_ARM_VUART_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/include/asm-arm/domain.h +8 -6
index 89f88f6..67bfbbc 100644
@@ -8,6 +8,7 @@
 #include <asm/p2m.h>
 #include <asm/vfp.h>
 #include <public/hvm/params.h>
+#include <xen/serial.h>
 
 /* Represents state corresponding to a block of 32 interrupts */
 struct vgic_irq_rank {
@@ -103,12 +104,13 @@ struct arch_domain
         paddr_t cbase; /* CPU base address */
     } vgic;
 
-    struct vpl011 {
-#define VPL011_BUF_SIZE 128
-        char                  *buf;
-        int                    idx;
-        spinlock_t             lock;
-    } uart0;
+    struct vuart {
+#define VUART_BUF_SIZE 128
+        char                        *buf;
+        int                         idx;
+        const struct vuart_info     *info;
+        spinlock_t                  lock;
+    } vuart;
 
 }  __cacheline_aligned;
 
Signature · 1 line
1.7.10.4
Reviewed-by on v3 4/7
#7 lore raw

Re: [PATCH v3 4/7] xen/arm: Implement a virtual UART

Quoted 9 lines · Julien Grall

This code is based on the previous vuart0 implementation. Unlike the latter, it's intend to replace UART stolen by XEN to DOM0 via dtuart=... on its command line.

It's useful when the kernel is compiled with early printk enabled or for a single platform. Most of the time, the hardcoded code to handle the UART will need 2 registers: status and data, the others registers can be implemented as RAZ/WI.

Quoted 4 lines

This commit will also drop support of early printk (based on vexpress pl011) in the guest.

#8 lore raw

PATCH v3 5/7 exynos4210: rename UTRSTAT_TX_EMPTY in UTRSTAT_TXFE

In reply to Julien Grall

---
Changes in v2:
- Missing s-o-b
- Align comment

---
 xen/arch/arm/arm32/debug-exynos4210.inc |    2 +-
 xen/include/asm-arm/exynos4210-uart.h   |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/arm32/debug-exynos4210.inc +1 -1
index d746c35..39f2db3 100644
@@ -56,7 +56,7 @@
 .macro early_uart_ready rb rc
 1:
         ldr   \rc, [\rb, #UTRSTAT]   /* <- UTRSTAT (Flag register) */
-        tst   \rc, #UTRSTAT_TX_EMPTY /* Check BUSY bit */
+        tst   \rc, #UTRSTAT_TXFE     /* Check BUSY bit */
         beq   1b                     /* Wait for the UART to be ready */
 .endm
 
xen/include/asm-arm/exynos4210-uart.h +1 -1
index 330e1c0..bd9a4be 100644
@@ -87,7 +87,7 @@
 #define UFSTAT_RX_COUNT_MASK    (0xff << UFSTAT_RX_COUNT_SHIFT)
 
 /* UTRSTAT */
-#define UTRSTAT_TX_EMPTY        (1 << 1)
+#define UTRSTAT_TXFE            (1 << 1)
 
 /* URHX */
 #define URXH_DATA_MASK  (0xff)
Signature · 1 line
1.7.10.4
#9 lore raw

PATCH v3 6/7 exynos4210: Implement vuart_info callback

In reply to Julien Grall

---
Changes v2:
- Use the renamed callback

---
 xen/drivers/char/exynos4210-uart.c    |   15 +++++++++++++++
 xen/include/asm-arm/exynos4210-uart.h |    1 +
 2 files changed, 16 insertions(+)
xen/drivers/char/exynos4210-uart.c +15 -0
index f7971da..9b34f92 100644
@@ -33,6 +33,7 @@ static struct exynos4210_uart {
     struct dt_irq irq;
     void *regs;
     struct irqaction irqaction;
+    struct vuart_info vuart;
 } exynos4210_com = {0};
 
 /* These parity settings can be ORed directly into the ULCON. */
@@ -281,6 +282,13 @@ static const struct dt_irq __init *exynos4210_uart_dt_irq(struct serial_port *po
     return &uart->irq;
 }
 
+static const struct vuart_info *exynos4210_vuart_info(struct serial_port *port)
+{
+    struct exynos4210_uart *uart = port->uart;
+
+    return &uart->vuart;
+}
+
 static struct uart_driver __read_mostly exynos4210_uart_driver = {
     .init_preirq  = exynos4210_uart_init_preirq,
     .init_postirq = exynos4210_uart_init_postirq,
@@ -292,6 +300,7 @@ static struct uart_driver __read_mostly exynos4210_uart_driver = {
     .getc         = exynos4210_uart_getc,
     .irq          = exynos4210_uart_irq,
     .dt_irq_get   = exynos4210_uart_dt_irq,
+    .vuart_info   = exynos4210_vuart_info,
 };
 
 /* TODO: Parse UART config from the command line */
@@ -337,6 +346,12 @@ static int __init exynos4210_uart_init(struct dt_device_node *dev,
         return res;
     }
 
+    uart->vuart.base_addr = addr;
+    uart->vuart.size = size;
+    uart->vuart.data_off = UTXH;
+    uart->vuart.status_off = UTRSTAT;
+    uart->vuart.status = UTRSTAT_TXE | UTRSTAT_TXFE;
+
     /* Register with generic serial driver. */
     serial_register_uart(SERHND_DTUART, &exynos4210_uart_driver, uart);
 
xen/include/asm-arm/exynos4210-uart.h +1 -0
index bd9a4be..e2ab4a4 100644
@@ -88,6 +88,7 @@
 
 /* UTRSTAT */
 #define UTRSTAT_TXFE            (1 << 1)
+#define UTRSTAT_TXE             (1 << 2)
 
 /* URHX */
 #define URXH_DATA_MASK  (0xff)
Signature · 1 line
1.7.10.4
#10 lore raw

PATCH v3 7/7 pl011: Implement vuart_info callback

In reply to Julien Grall

---
Changes in v2:
- Use the renamed callback

---
 xen/drivers/char/pl011.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)
xen/drivers/char/pl011.c +15 -0
index fd87e68..05d034f 100644
@@ -36,6 +36,7 @@ static struct pl011 {
     void __iomem *regs;
     /* UART with IRQ line: interrupt-driven I/O. */
     struct irqaction irqaction;
+    struct vuart_info vuart;
     /* /\* UART with no IRQ line: periodically-polled I/O. *\/ */
     /* struct timer timer; */
     /* unsigned int timeout_ms; */
@@ -190,6 +191,13 @@ static const struct dt_irq __init *pl011_dt_irq(struct serial_port *port)
     return &uart->irq;
 }
 
+static const struct vuart_info *pl011_vuart(struct serial_port *port)
+{
+    struct pl011 *uart = port->uart;
+
+    return &uart->vuart;
+}
+
 static struct uart_driver __read_mostly pl011_driver = {
     .init_preirq  = pl011_init_preirq,
     .init_postirq = pl011_init_postirq,
@@ -201,6 +209,7 @@ static struct uart_driver __read_mostly pl011_driver = {
     .getc         = pl011_getc,
     .irq          = pl011_irq,
     .dt_irq_get   = pl011_dt_irq,
+    .vuart_info   = pl011_vuart,
 };
 
 /* TODO: Parse UART config from the command line */
@@ -248,6 +257,12 @@ static int __init pl011_uart_init(struct dt_device_node *dev,
         return res;
     }
 
+    uart->vuart.base_addr = addr;
+    uart->vuart.size = size;
+    uart->vuart.data_off = DR;
+    uart->vuart.status_off = FR;
+    uart->vuart.status = 0;
+
     /* Register with generic serial driver. */
     serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
 
Signature · 1 line
1.7.10.4
#11 lore raw
In reply to Julien Grall
Quoted 43 lines · Julien Grall

Hi,

This third version of this patch series. It follows the thread
http://patches.linaro.org/18358/ on Linux mailing list.

In some configuration, the kernel can use hardcoded code to access to the UART (for instance early printk). If Xen has stolen the UART for its own use, DOM0 will abort because Xen has not mapped to DOM0 the UART memory.

With this patch series, Xen will "replace" the real UART by a basic virtual UART for DOM0.

For the moment, this patch series is not able to cooperate with early printk in guest kernel.

This patch series also contains clean up for the pl011 and exynos4210 drivers.

For all the changes see the different patches.

Julien Grall (7):
pl011: Move registers' definition in a separate file xen/arm: Use define instead of hardcoded value in debug-pl011 xen/arm: New callback in uart_driver to retrieve serial information xen/arm: Implement a virtual UART
exynos4210: rename UTRSTAT_TX_EMPTY in UTRSTAT_TXFE
exynos4210: Implement vuart_info callback
pl011: Implement vuart_info callback

 xen/arch/arm/Makefile                   |    2 +-
 xen/arch/arm/arm32/debug-exynos4210.inc |    2 +-
 xen/arch/arm/arm32/debug-pl011.inc      |   18 ++--
 xen/arch/arm/domain.c                   |   12 ++-
 xen/arch/arm/io.c                       |    2 +-
 xen/arch/arm/io.h                       |    2 +-
 xen/arch/arm/vpl011.c                   |  152 -------------------------------
 xen/arch/arm/vpl011.h                   |   35 -------
 xen/arch/arm/vuart.c                    |  150 ++++++++++++++++++++++++++++++
 xen/arch/arm/vuart.h                    |   35 +++++++
 xen/drivers/char/exynos4210-uart.c      |   15 +++
 xen/drivers/char/pl011.c                |   63 ++++---------
 xen/drivers/char/serial.c               |    8 ++
 xen/include/asm-arm/domain.h            |   14 +--
 xen/include/asm-arm/exynos4210-uart.h   |    3 +-
Quoted 9 lines
 xen/include/asm-arm/pl011-uart.h        |   81 ++++++++++++++++
 xen/include/xen/serial.h                |   13 +++
 17 files changed, 350 insertions(+), 257 deletions(-)
 delete mode 100644 xen/arch/arm/vpl011.c
 delete mode 100644 xen/arch/arm/vpl011.h
 create mode 100644 xen/arch/arm/vuart.c
 create mode 100644 xen/arch/arm/vuart.h
 create mode 100644 xen/include/asm-arm/pl011-uart.h

I forgot to add this patch in the series:
http://patches.linaro.org/18710/. It didn't change since the previous version.

Signature · 1 line
Julien
#12 lore raw
Quoted 3 lines · Julien Grall

I forgot to add this patch in the series:
http://patches.linaro.org/18710/. It didn't change since the previous version.

Based on the reject I got with patch 1/7 I think this should be inserted at the front of the series?

Unfortunately it although I got a direct CC it didn't seem to make it to the list (e.g. it's not at http://bugs.xenproject.org/xen/mid/%
[email protected]%3E/raw) which means I have trouble finding a non-mangled copy to apply.

Could you resend just this one patch please?

Ian.

#13 lore raw
Quoted 8 lines · Ian Campbell
Quoted 3 lines · Julien Grall

I forgot to add this patch in the series:
http://patches.linaro.org/18710/. It didn't change since the previous version.

Based on the reject I got with patch 1/7 I think this should be inserted at the front of the series?

Quoted 6 lines

Unfortunately it although I got a direct CC it didn't seem to make it to the list (e.g. it's not at http://bugs.xenproject.org/xen/mid/%
[email protected]%3E/raw) which means I have trouble finding a non-mangled copy to apply.

Could you resend just this one patch please?

Don't worry about this -- I found a suitable one which seemed to apply.

Ian.

#14 lore raw
In reply to Julien Grall
Quoted 5 lines · Julien Grall
Quoted 4 lines · Julien Grall

Hi,

This third version of this patch series. It follows the thread
http://patches.linaro.org/18358/ on Linux mailing list.

I applied this precursor and #1 and #2 from this series.

#3 needs Keir's ack since it touches common code. I don't think I can apply anything from #4 onwards without that.

Ian.

#15 lore raw
Quoted 8 lines · Ian Campbell
Quoted 5 lines · Julien Grall
Quoted 4 lines · Julien Grall

Hi,

This third version of this patch series. It follows the thread
http://patches.linaro.org/18358/ on Linux mailing list.

I applied this precursor and #1 and #2 from this series.

Thanks.

Quoted 2 lines

#3 needs Keir's ack since it touches common code. I don't think I can apply anything from #4 onwards without that.

Right. The other patches can't compile without the #3.

Signature · 1 line
Julien