mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-15 09:04:17 +00:00

The legacy console is gone. Re-add the console support based on the multi-console framework. I am still keeping the putc, getc, and flush callbacks in uniphier_console.S to use plat/common/aarch64/crash_console_helpers.S The console registration code already relies on that C environment has been set up. So, I just filled the struct console fields with the callback pointers, then called console_register() directly. I also re-implemented the init function in C to improve the readability. Removing the custom crash console implementation has one disadvantage; we cannot use the crash console on very early crashes because crash_console_helpers.S works only after the console is registered. I can live with this limitation. Tested on my boards, and confirmed this worked like before. Change-Id: Ieab9c849853ff6c525c15ea894a85944f257db59 Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
72 lines
1.5 KiB
ArmAsm
72 lines
1.5 KiB
ArmAsm
/*
|
|
* Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <asm_macros.S>
|
|
#include <drivers/console.h>
|
|
|
|
#include "uniphier_console.h"
|
|
|
|
/*
|
|
* In: w0 - character to be printed
|
|
* x1 - pointer to console structure
|
|
* Out: return the character written (always succeeds)
|
|
* Clobber: x2
|
|
*/
|
|
.globl uniphier_console_putc
|
|
func uniphier_console_putc
|
|
ldr x1, [x1, #CONSOLE_T_DRVDATA]
|
|
|
|
/* Wait until the transmitter FIFO gets empty */
|
|
0: ldr w2, [x1, #UNIPHIER_UART_LSR]
|
|
tbz w2, #UNIPHIER_UART_LSR_THRE_BIT, 0b
|
|
|
|
mov w2, w0
|
|
|
|
1: str w2, [x1, #UNIPHIER_UART_TX]
|
|
|
|
cmp w2, #'\n'
|
|
b.ne 2f
|
|
mov w2, #'\r' /* Append '\r' to '\n' */
|
|
b 1b
|
|
2: ret
|
|
endfunc uniphier_console_putc
|
|
|
|
/*
|
|
* In: x0 - pointer to console structure
|
|
* Out: return the character read, or ERROR_NO_PENDING_CHAR if no character
|
|
is available
|
|
* Clobber: x1
|
|
*/
|
|
.globl uniphier_console_getc
|
|
func uniphier_console_getc
|
|
ldr x0, [x0, #CONSOLE_T_DRVDATA]
|
|
|
|
ldr w1, [x0, #UNIPHIER_UART_LSR]
|
|
tbz w1, #UNIPHIER_UART_LSR_DR_BIT, 0f
|
|
|
|
ldr w0, [x0, #UNIPHIER_UART_RX]
|
|
ret
|
|
|
|
0: mov w0, #ERROR_NO_PENDING_CHAR
|
|
ret
|
|
endfunc uniphier_console_getc
|
|
|
|
/*
|
|
* In: x0 - pointer to console structure
|
|
* Out: return 0 (always succeeds)
|
|
* Clobber: x1
|
|
*/
|
|
.global uniphier_console_flush
|
|
func uniphier_console_flush
|
|
ldr x0, [x0, #CONSOLE_T_DRVDATA]
|
|
|
|
/* wait until the transmitter gets empty */
|
|
0: ldr w1, [x0, #UNIPHIER_UART_LSR]
|
|
tbz w1, #UNIPHIER_UART_LSR_TEMT_BIT, 0b
|
|
|
|
mov w0, #0
|
|
ret
|
|
endfunc uniphier_console_flush
|