All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/arm/virt: support 4 serial ports
@ 2017-10-23 12:27 Jason A. Donenfeld
  2017-10-23 12:35 ` no-reply
  2017-10-23 13:11 ` [Qemu-devel] [Qemu-arm] " Peter Maydell
  0 siblings, 2 replies; 17+ messages in thread
From: Jason A. Donenfeld @ 2017-10-23 12:27 UTC (permalink / raw)
  To: qemu-arm, qemu-devel, qemu-trivial; +Cc: Jason A. Donenfeld

The QEMU man page says:

       -serial dev
           This option can be used several times to
           simulate up to 4 serial ports.

However, the ARM virt machine erroneously only provides 1 serial port.
This patch fixes it by populating 4 of them.

But, unfortunately, this patch doesn't actually work. Sending it to the
list as inspiration for somebody on the ARM team who might be able to do
this more properly.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 hw/arm/virt.c | 45 +++++++++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 9e18b410d7..12b73dfd1e 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -134,11 +134,14 @@ static const MemMapEntry a15memmap[] = {
     [VIRT_GIC_ITS] =            { 0x08080000, 0x00020000 },
     /* This redistributor space allows up to 2*64kB*123 CPUs */
     [VIRT_GIC_REDIST] =         { 0x080A0000, 0x00F60000 },
-    [VIRT_UART] =               { 0x09000000, 0x00001000 },
-    [VIRT_RTC] =                { 0x09010000, 0x00001000 },
-    [VIRT_FW_CFG] =             { 0x09020000, 0x00000018 },
-    [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
-    [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
+    [VIRT_UART + 0] =           { 0x09000000, 0x00001000 },
+    [VIRT_UART + 1] =           { 0x09010000, 0x00001000 },
+    [VIRT_UART + 2] =           { 0x09020000, 0x00001000 },
+    [VIRT_UART + 3] =           { 0x09030000, 0x00001000 },
+    [VIRT_RTC] =                { 0x09040000, 0x00001000 },
+    [VIRT_FW_CFG] =             { 0x09050000, 0x00000018 },
+    [VIRT_GPIO] =               { 0x09060000, 0x00001000 },
+    [VIRT_SECURE_UART] =        { 0x09070000, 0x00001000 },
     [VIRT_MMIO] =               { 0x0a000000, 0x00000200 },
     /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
     [VIRT_PLATFORM_BUS] =       { 0x0c000000, 0x02000000 },
@@ -152,14 +155,17 @@ static const MemMapEntry a15memmap[] = {
 };
 
 static const int a15irqmap[] = {
-    [VIRT_UART] = 1,
-    [VIRT_RTC] = 2,
-    [VIRT_PCIE] = 3, /* ... to 6 */
-    [VIRT_GPIO] = 7,
-    [VIRT_SECURE_UART] = 8,
-    [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 */
+    [VIRT_UART + 0] = 1,
+    [VIRT_UART + 1] = 2,
+    [VIRT_UART + 2] = 3,
+    [VIRT_UART + 3] = 4,
+    [VIRT_RTC] = 5,
+    [VIRT_PCIE] = 6, /* ... to 9 */
+    [VIRT_GPIO] = 10,
+    [VIRT_SECURE_UART] = 11,
+    [VIRT_MMIO] = 19, /* ...to 19 + NUM_VIRTIO_TRANSPORTS - 1 */
+    [VIRT_GIC_V2M] = 51, /* ...to 51 + NUM_GICV2M_SPIS - 1 */
+    [VIRT_PLATFORM_BUS] = 115, /* ...to 115 + PLATFORM_BUS_NUM_IRQS -1 */
 };
 
 static const char *valid_cpus[] = {
@@ -674,12 +680,12 @@ static void create_uart(const VirtMachineState *vms, qemu_irq *pic, int uart,
     qemu_fdt_setprop(vms->fdt, nodename, "clock-names",
                          clocknames, sizeof(clocknames));
 
-    if (uart == VIRT_UART) {
-        qemu_fdt_setprop_string(vms->fdt, "/chosen", "stdout-path", nodename);
-    } 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");
+    } else {
+        qemu_fdt_setprop_string(vms->fdt, "/chosen", "stdout-path", nodename);
     }
 
     g_free(nodename);
@@ -1419,11 +1425,14 @@ 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 + 0, sysmem, serial_hds[0]);
+    create_uart(vms, pic, VIRT_UART + 1, sysmem, serial_hds[1]);
+    create_uart(vms, pic, VIRT_UART + 2, sysmem, serial_hds[2]);
+    create_uart(vms, pic, VIRT_UART + 3, sysmem, serial_hds[3]);
 
     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[4]);
     }
 
     create_rtc(vms, pic);
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-12-10 18:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-23 12:27 [Qemu-devel] [PATCH] hw/arm/virt: support 4 serial ports Jason A. Donenfeld
2017-10-23 12:35 ` no-reply
2017-10-23 13:11 ` [Qemu-devel] [Qemu-arm] " Peter Maydell
2017-10-23 13:48   ` Philippe Mathieu-Daudé
2017-10-24 17:57     ` Jason A. Donenfeld
2017-10-26 13:34       ` Andrew Jones
2017-10-26 14:13         ` Jason A. Donenfeld
2017-10-26 14:36           ` Peter Maydell
2017-10-26 16:15             ` Jason A. Donenfeld
2017-10-26 16:34               ` Peter Maydell
2017-10-26 16:36                 ` Jason A. Donenfeld
2017-10-26 16:41                   ` Peter Maydell
2017-10-26 17:31                     ` Jason A. Donenfeld
2017-12-08 11:49                       ` Peter Maydell
2017-12-08 18:39                         ` Jason A. Donenfeld
2017-12-10 18:15                           ` Peter Maydell
2017-10-23 14:14   ` Jason A. Donenfeld

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.