The sun4m machine uses 2 ESCC devices: one for use as normal serial ports and another for use with a Sun keyboard/mouse. The previous ESCC fixes added new code to send the ESCC soft reset sequence for the normal serial ports but failed to do so for the keyboard/mouse serial ports.
This worked fine for OpenBIOS and all of my SPARC32 test images except for my OpenBSD test image which hangs on boot: whilst the OS sends the reset sequence to the normal serial port, it tries to access the Sun keyboard/mouse serial ports without sending the reset sequence first causing it to get stuck in a polling loop waiting for the status register bits to be set correctly.
This patchset updates the kbd_init() function which initialises the ESCC used by the Sun keyboard/mouse so that it now sends the ESCC soft reset sequence to both ports. This ensures that the status register bits are set to their expected reset defaults which allows OpenBSD SPARC32 to boot successfully once again.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Mark Cave-Ayland (2): escc: add speed parameter to kbd_init() for sun keyboard/mouse serial ports escc: initialise sun keyboard/mouse serial ports in kbd_init()
arch/sparc32/openbios.c | 2 +- drivers/escc.c | 4 +++- include/drivers/drivers.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-)
This is in preparation for initialising the keyboard/mouse serial ports before being used by the guest.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- arch/sparc32/openbios.c | 2 +- drivers/escc.c | 2 +- include/drivers/drivers.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/sparc32/openbios.c b/arch/sparc32/openbios.c index 9af4e18..344b744 100644 --- a/arch/sparc32/openbios.c +++ b/arch/sparc32/openbios.c @@ -1029,7 +1029,7 @@ int openbios(void) CONFIG_SERIAL_SPEED); #endif #ifdef CONFIG_DEBUG_CONSOLE_VIDEO - kbd_init(hwdef->ms_kb_base); + kbd_init(hwdef->ms_kb_base, CONFIG_SERIAL_SPEED); #endif #endif
diff --git a/drivers/escc.c b/drivers/escc.c index 0f0d43a..e2d94ae 100644 --- a/drivers/escc.c +++ b/drivers/escc.c @@ -245,7 +245,7 @@ NODE_METHODS(escc_port) = { #ifdef CONFIG_DRIVER_ESCC_SUN static volatile unsigned char *kbd_dev;
-void kbd_init(phys_addr_t base) +void kbd_init(phys_addr_t base, unsigned long speed) { kbd_dev = (unsigned char *)ofmem_map_io(base, 2 * 4); kbd_dev += 4; diff --git a/include/drivers/drivers.h b/include/drivers/drivers.h index 3d6fa12..bbac5f7 100644 --- a/include/drivers/drivers.h +++ b/include/drivers/drivers.h @@ -56,7 +56,7 @@ static inline int has_adb(void) int ob_sbus_init(uint64_t base, int machine_id);
/* arch/sparc32/console.c */ -void kbd_init(uint64_t base); +void kbd_init(uint64_t base, unsigned long speed); #endif #ifdef CONFIG_DRIVER_IDE /* drivers/ide.c */
This ensures that the ESCC software reset sequence is sent to each port before being used by the guest OS. This fixes a bug in OpenBSD SPARC32 which doesn't explicitly reset the keyboard/mouse serial ports causing it to hang when trying to access these devices during boot.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- drivers/escc.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/escc.c b/drivers/escc.c index e2d94ae..6b3b7d7 100644 --- a/drivers/escc.c +++ b/drivers/escc.c @@ -248,6 +248,8 @@ static volatile unsigned char *kbd_dev; void kbd_init(phys_addr_t base, unsigned long speed) { kbd_dev = (unsigned char *)ofmem_map_io(base, 2 * 4); + uart_init_line(kbd_dev, speed, 1); + uart_init_line(kbd_dev, speed, 0); kbd_dev += 4; }
On 27/10/2021 19:38, Mark Cave-Ayland wrote:
The sun4m machine uses 2 ESCC devices: one for use as normal serial ports and another for use with a Sun keyboard/mouse. The previous ESCC fixes added new code to send the ESCC soft reset sequence for the normal serial ports but failed to do so for the keyboard/mouse serial ports.
This worked fine for OpenBIOS and all of my SPARC32 test images except for my OpenBSD test image which hangs on boot: whilst the OS sends the reset sequence to the normal serial port, it tries to access the Sun keyboard/mouse serial ports without sending the reset sequence first causing it to get stuck in a polling loop waiting for the status register bits to be set correctly.
This patchset updates the kbd_init() function which initialises the ESCC used by the Sun keyboard/mouse so that it now sends the ESCC soft reset sequence to both ports. This ensures that the status register bits are set to their expected reset defaults which allows OpenBSD SPARC32 to boot successfully once again.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Mark Cave-Ayland (2): escc: add speed parameter to kbd_init() for sun keyboard/mouse serial ports escc: initialise sun keyboard/mouse serial ports in kbd_init()
arch/sparc32/openbios.c | 2 +- drivers/escc.c | 4 +++- include/drivers/drivers.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-)
Self-nack. It seems that the real SS-5 Sun PROM uses a similar sequence to OpenBSD to initialise the keyboard without sending an explicit reset, so there must be something missing from QEMU's ESCC emulation that can set some of the required status bits.
For that reason it seems better to try and work out what is missing from QEMU and fix it there, leaving the existing code so that OpenBSD can also be used to detect ESCC regressions.
ATB,
Mark.