Skip to content

Commit

Permalink
libplatsupport: fix CR/LF handling
Browse files Browse the repository at this point in the history
Fix the bug that LF CR is printed instead of CR LF.

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
  • Loading branch information
Axel Heider authored and axel-h committed May 8, 2023
1 parent 3b1177d commit 5e8b634
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions libplatsupport/src/plat/fvp/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ int uart_getchar(ps_chardevice_t *d)

int uart_putchar(ps_chardevice_t *d, int c)
{
while ((*REG_PTR(d->vaddr, UARTFR) & PL011_UARTFR_TXFF) != 0);

*REG_PTR(d->vaddr, UARTDR) = c;
if (c == '\n' && (d->flags & SERIAL_AUTO_CR)) {
uart_putchar(d, '\r');
}

while ((*REG_PTR(d->vaddr, UARTFR) & PL011_UARTFR_TXFF) != 0) {
/* busy loop */
}
*REG_PTR(d->vaddr, UARTDR) = c;

return c;
}

Expand Down
8 changes: 5 additions & 3 deletions libplatsupport/src/plat/hikey/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ int uart_getchar(ps_chardevice_t *d)

int uart_putchar(ps_chardevice_t *d, int c)
{
while ((*REG_PTR(d->vaddr, UARTFR) & PL011_UARTFR_TXFF) != 0);

*REG_PTR(d->vaddr, UARTDR) = c;
if (c == '\n' && (d->flags & SERIAL_AUTO_CR)) {
uart_putchar(d, '\r');
}

while ((*REG_PTR(d->vaddr, UARTFR) & PL011_UARTFR_TXFF) != 0) {
/* busy loop */
}
*REG_PTR(d->vaddr, UARTDR) = c;

return c;
}

Expand Down

0 comments on commit 5e8b634

Please sign in to comment.