All of lore.kernel.org
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: qemu-devel@nongnu.org
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	Sven Schnelle <svens@stackframe.org>,
	Richard Henderson <richard.henderson@linaro.org>,
	Helge Deller <deller@gmx.de>
Subject: [PATCH 2/2] hppa: Fix serial port pass-through
Date: Thu, 26 May 2022 13:19:26 +0200	[thread overview]
Message-ID: <20220526111926.19603-3-deller@gmx.de> (raw)
In-Reply-To: <20220526111926.19603-1-deller@gmx.de>

This fixes the serial ports in the emulation to behave as on original
hardware.

On the real hardware, the LASI UART is serial port #0 and the DINO UART
is serial port #1. This is fixed in SEABIOS_HPPA_VERSION >= 6, which is
why the latest firmware is required.

The serial port addresses in hppa/hppa_hardware.h are swapped and the
file is synced with the version in SeaBIOS-hppa. Please note that this
file is shared between qemu and SeaBIOS-hppa, which is why a comment was
added at the top of the file.

When creating the virtual serial ports the correct port addresses are
now used.

Finally, this patch now allows the user to give:
    -serial mon:stdio -serial /dev/ttyS4
to use emulated ttyS0 in the guest for console output, and pass ttyS4
from the host to ttyS1 in the guest.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 hw/hppa/hppa_hardware.h | 10 ++++++++--
 hw/hppa/machine.c       | 17 +++++++----------
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/hw/hppa/hppa_hardware.h b/hw/hppa/hppa_hardware.h
index 8b6b9222cb..c036d467f3 100644
--- a/hw/hppa/hppa_hardware.h
+++ b/hw/hppa/hppa_hardware.h
@@ -1,4 +1,5 @@
 /* HPPA cores and system support chips.  */
+/* Be aware: This file is shared as-is with seabios-hppa. */

 #ifndef HW_HPPA_HPPA_HARDWARE_H
 #define HW_HPPA_HPPA_HARDWARE_H
@@ -30,13 +31,18 @@
 #define PCI_HPA         DINO_HPA        /* PCI bus */
 #define IDE_HPA         0xf9000000      /* Boot disc controller */

+/* offsets to DINO HPA: */
+#define DINO_PCI_ADDR           0x064
+#define DINO_CONFIG_DATA        0x068
+#define DINO_IO_DATA            0x06c
+
 #define PORT_PCI_CMD    (PCI_HPA + DINO_PCI_ADDR)
 #define PORT_PCI_DATA   (PCI_HPA + DINO_CONFIG_DATA)

 #define FW_CFG_IO_BASE  0xfffa0000

-#define PORT_SERIAL1    (DINO_UART_HPA + 0x800)
-#define PORT_SERIAL2    (LASI_UART_HPA + 0x800)
+#define PORT_SERIAL1    (LASI_UART_HPA + 0x800)
+#define PORT_SERIAL2    (DINO_UART_HPA + 0x800)

 #define HPPA_MAX_CPUS   16      /* max. number of SMP CPUs */
 #define CPU_CLOCK_MHZ   250     /* emulate a 250 MHz CPU */
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index d1e174b1f4..5d23b9e528 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -32,7 +32,7 @@

 #define MAX_IDE_BUS 2

-#define MIN_SEABIOS_HPPA_VERSION 1 /* require at least this fw version */
+#define MIN_SEABIOS_HPPA_VERSION 6 /* require at least this fw version */

 #define HPA_POWER_BUTTON (FIRMWARE_END - 0x10)

@@ -236,18 +236,15 @@ static void machine_hppa_init(MachineState *machine)
     /* Realtime clock, used by firmware for PDC_TOD call. */
     mc146818_rtc_init(isa_bus, 2000, NULL);

-    /* Serial code setup.  */
+    /* Serial ports - Lasi and Dino use a 7.272727 MHz clock. */
     if (serial_hd(0)) {
-        uint32_t addr = DINO_UART_HPA + 0x800;
-        serial_mm_init(addr_space, addr, 0,
-                       qdev_get_gpio_in(dino_dev, DINO_IRQ_RS232INT),
-                       115200, serial_hd(0), DEVICE_BIG_ENDIAN);
+        serial_mm_init(addr_space, LASI_UART_HPA + 0x800, 0,
+                qdev_get_gpio_in(lasi_dev, LASI_IRQ_UART_HPA), 7272727 / 16,
+                serial_hd(0), DEVICE_BIG_ENDIAN);
     }
-
     if (serial_hd(1)) {
-        /* Serial port */
-        serial_mm_init(addr_space, LASI_UART_HPA + 0x800, 0,
-                qdev_get_gpio_in(lasi_dev, LASI_IRQ_UART_HPA), 8000000 / 16,
+        serial_mm_init(addr_space, DINO_UART_HPA + 0x800, 0,
+                qdev_get_gpio_in(dino_dev, DINO_IRQ_RS232INT), 7272727 / 16,
                 serial_hd(1), DEVICE_BIG_ENDIAN);
     }

--
2.35.3



  parent reply	other threads:[~2022-05-26 11:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26 11:19 [PATCH 0/2] " Helge Deller
2022-05-26 11:19 ` [PATCH 1/2] New SeaBIOS-hppa version 6 Helge Deller
2022-05-26 11:19 ` Helge Deller [this message]
2022-05-28  6:36   ` [PATCH 2/2] hppa: Fix serial port pass-through Mark Cave-Ayland
2022-05-28 14:24   ` Peter Maydell
2022-05-28 14:25     ` Peter Maydell
2022-05-28 14:45       ` Helge Deller

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=20220526111926.19603-3-deller@gmx.de \
    --to=deller@gmx.de \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=svens@stackframe.org \
    --subject='Re: [PATCH 2/2] hppa: Fix serial port pass-through' \
    /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

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.