EtchedPixels / FUZIX

FuzixOS: Because Small Is Beautiful
Other
2.18k stars 272 forks source link

devtty: fix backspace echo not working properly with ASCI #971

Closed ra1fh closed 1 year ago

ra1fh commented 1 year ago

When backspace is read from the serial line, tty_inproc() will echo this back as "\b \b". This happens in interrupt context, so tty_putc_maywait() will not call tty_writeready(). On SC111, the space character got dropped because ASCI was still transmitting the first \b character. So only "\b\b" was transmitted on the serial port.

This was revealed by commit a56be113 ("sc111: now we have boot parameters don't hardware turbo mode"), which moved the DCNTL setup into a boot option, keeping DCNTL at the RomWBW/SCM default of 0 memory wait states on SC111. A minimum of 2 memory wait states is required on my SC111 to slow the CPU down to give ASCI enough time to transmit subsequent characters sent via tty_putc().

The check for TDRE in ASCI_STAT before writing to ASCI_TDR is present on several platforms already. Adding the check to all platforms that don't have it yet.

EtchedPixels commented 1 year ago

Unfortunately this is not the fix. There needs to be a bit of queuing or state to track pending erase. For backspace it's not hard but doing line delete either needs the old unix behaviour of a newline or something smarter.

Otherwise you end up hanging on the serial in the interrupt.

It's on the list of things to tackle properly at some point for platforms without serial queues.

ra1fh commented 1 year ago

I should have called this workaround rather than fix :-) I understand that spinning in interrupt is not as designed, but until there is a serial queue this might be better than dropping characters.