qemu-arm.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: "Jason A . Donenfeld" <Jason@zx2c4.com>,
	Shannon Zhao <shannon.zhao@linaro.org>
Subject: [Qemu-arm] [PATCH 2/3] hw/arm/virt: Add another UART to the virt board
Date: Fri,  8 Dec 2017 15:02:07 +0000	[thread overview]
Message-ID: <1512745328-5109-3-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1512745328-5109-1-git-send-email-peter.maydell@linaro.org>

Currently we only provide one non-secure UART on the virt
board. This is OK for most purposes, but there are some
use cases where having a second UART would be useful (like
bare-metal testing where you don't really want to have to
probe and set up a PCI device just to have a second comms
channel).

Add a second NS UART to the virt board. This will be the
second serial device if 'secure=no' (the default), and the
third serial device if 'secure=yes'.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/hw/arm/virt.h |  2 ++
 hw/arm/virt.c         | 19 ++++++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index 33b0ff3..685009a 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -72,6 +72,7 @@ enum {
     VIRT_GPIO,
     VIRT_SECURE_UART,
     VIRT_SECURE_MEM,
+    VIRT_UART_2,
 };
 
 typedef struct MemMapEntry {
@@ -85,6 +86,7 @@ typedef struct {
     bool no_its;
     bool no_pmu;
     bool claim_edge_triggered_timers;
+    bool no_second_uart;
 } VirtMachineClass;
 
 typedef struct {
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 543f9bd..e234f55 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -139,6 +139,7 @@ static const MemMapEntry a15memmap[] = {
     [VIRT_FW_CFG] =             { 0x09020000, 0x00000018 },
     [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
     [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
+    [VIRT_UART_2] =             { 0x09050000, 0x00001000 },
     [VIRT_MMIO] =               { 0x0a000000, 0x00000200 },
     /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
     [VIRT_PLATFORM_BUS] =       { 0x0c000000, 0x02000000 },
@@ -157,6 +158,7 @@ static const int a15irqmap[] = {
     [VIRT_PCIE] = 3, /* ... to 6 */
     [VIRT_GPIO] = 7,
     [VIRT_SECURE_UART] = 8,
+    [VIRT_UART_2] = 9,
     [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
     [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */
     [VIRT_PLATFORM_BUS] = 112, /* ...to 112 + PLATFORM_BUS_NUM_IRQS -1 */
@@ -676,7 +678,7 @@ static void create_uart(const VirtMachineState *vms, qemu_irq *pic, int uart,
 
     if (uart == VIRT_UART) {
         qemu_fdt_setprop_string(vms->fdt, "/chosen", "stdout-path", nodename);
-    } else {
+    } else if (uart == VIRT_SECURE_UART) {
         /* Mark as not usable by the normal world */
         qemu_fdt_setprop_string(vms->fdt, nodename, "status", "disabled");
         qemu_fdt_setprop_string(vms->fdt, nodename, "secure-status", "okay");
@@ -1260,6 +1262,7 @@ static void machvirt_init(MachineState *machine)
     int n, virt_max_cpus;
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     bool firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0);
+    int uart_count = 0;
 
     /* We can probe only here because during property set
      * KVM is not available yet
@@ -1419,11 +1422,16 @@ static void machvirt_init(MachineState *machine)
 
     fdt_add_pmu_nodes(vms);
 
-    create_uart(vms, pic, VIRT_UART, sysmem, serial_hds[0]);
+    create_uart(vms, pic, VIRT_UART, sysmem, serial_hds[uart_count++]);
 
     if (vms->secure) {
         create_secure_ram(vms, secure_sysmem);
-        create_uart(vms, pic, VIRT_SECURE_UART, secure_sysmem, serial_hds[1]);
+        create_uart(vms, pic, VIRT_SECURE_UART, secure_sysmem,
+                    serial_hds[uart_count++]);
+    }
+
+    if (!vmc->no_second_uart) {
+        create_uart(vms, pic, VIRT_UART_2, sysmem, serial_hds[uart_count++]);
     }
 
     create_rtc(vms, pic);
@@ -1693,8 +1701,13 @@ static void virt_2_11_instance_init(Object *obj)
 
 static void virt_machine_2_11_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_2_12_options(mc);
     SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_11);
+
+    /* The second NS UART was added in 2.12 */
+    vmc->no_second_uart = true;
 }
 DEFINE_VIRT_MACHINE(2, 11)
 
-- 
2.7.4


  parent reply	other threads:[~2017-12-08 15:02 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-08 15:02 [Qemu-arm] [PATCH 0/3] hw/arm/virt: Add another UART Peter Maydell
2017-12-08 15:02 ` [Qemu-arm] [PATCH 1/3] hw/arm/virt: Add virt-2.12 machine type Peter Maydell
2017-12-12 14:39   ` [Qemu-arm] [Qemu-devel] " Andrew Jones
2018-01-15 12:00     ` Peter Maydell
2017-12-08 15:02 ` Peter Maydell [this message]
2017-12-12  5:55   ` [Qemu-arm] [Qemu-devel] [PATCH 2/3] hw/arm/virt: Add another UART to the virt board Shannon Zhao
2017-12-12 10:45     ` Peter Maydell
2017-12-12 14:25       ` Jason A. Donenfeld
2017-12-12 14:45   ` [Qemu-arm] " Andrew Jones
2017-12-12 14:50     ` Peter Maydell
2017-12-12 15:16       ` Andrew Jones
2017-12-12 15:51         ` [Qemu-arm] " Peter Maydell
2018-05-31  2:12           ` Jason A. Donenfeld
2018-05-31  8:32             ` [Qemu-arm] " Peter Maydell
2018-05-31 11:48               ` Jason A. Donenfeld
2018-05-31 11:57                 ` Peter Maydell
2017-12-12 15:16   ` Andrew Jones
2017-12-08 15:02 ` [Qemu-arm] [PATCH 3/3] hw/arm/virt-acpi-build: Add second UART to ACPI tables Peter Maydell
2017-12-12  5:53   ` [Qemu-devel] " Shannon Zhao
2017-12-12 11:06     ` [Qemu-arm] " Laszlo Ersek
2017-12-12 11:11       ` Peter Maydell
2017-12-12 11:33         ` Laszlo Ersek
2017-12-12 11:44           ` Ard Biesheuvel
2017-12-12 11:59             ` Laszlo Ersek
2017-12-12 12:07               ` Peter Maydell
2017-12-12 12:41                 ` Laszlo Ersek
2017-12-12 12:47                   ` Peter Maydell
2017-12-12 13:28                     ` Laszlo Ersek
2017-12-12 13:56                       ` Ard Biesheuvel
2017-12-12 14:10                         ` [Qemu-arm] " Peter Maydell
2017-12-12 14:12                           ` Ard Biesheuvel
2017-12-12 14:13                             ` Peter Maydell
2017-12-12 14:16                               ` [Qemu-arm] " Ard Biesheuvel
2017-12-12 14:17                                 ` Peter Maydell
2017-12-12 14:31                                   ` Ard Biesheuvel
2017-12-12 14:51                                     ` Andrew Jones
2017-12-12 16:38                                       ` [Qemu-arm] " Laszlo Ersek
2017-12-12 14:18                         ` Andrew Jones
2017-12-12 14:10                       ` [Qemu-arm] " Andrew Jones
2017-12-12 15:09       ` Andrew Jones
2017-12-13 13:56       ` Peter Maydell
2017-12-13 16:01         ` Laszlo Ersek
2017-12-13 16:46           ` Ard Biesheuvel
2017-12-13 16:48             ` Peter Maydell
2017-12-08 15:10 ` [Qemu-arm] [PATCH 0/3] hw/arm/virt: Add another UART Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1512745328-5109-3-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=Jason@zx2c4.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shannon.zhao@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).