blob: 50ac1963a6679ac2262b32b9dd912f6b670d5a13 [file] [log] [blame]
Antonio Nino Diaz1d036682019-03-27 15:23:59 +00001/*
2 * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <asm_macros.S>
8#include <drivers/console.h>
9
10 .globl console_init
11 .globl console_putc
12 .globl console_getc
13 .globl console_try_getc
14 .globl console_flush
15
16 /* -----------------------------------------------
17 * int console_init(uintptr_t base_addr,
18 * unsigned int uart_clk, unsigned int baud_rate)
19 * Function to initialize the console without a
20 * C Runtime to print debug information. It saves
21 * the console base to the data section.
22 * In: x0 - Console base address
23 * w1 - Uart clock in Hz
24 * w2 - Baud rate
25 * Out: w0 - Return 1 on success, 0 on error.
26 * Clobber list : x1 - x3
27 * -----------------------------------------------
28 */
29func console_init
30 mov w0, #1
31 ret
32endfunc console_init
33
34 /* ---------------------------------------------
35 * int console_putc(int c)
36 * Function to output a character over the
37 * console. It returns the character printed on
38 * success or an error code.
39 * In : x0 - Character to be printed
40 * Out : w0 - Input character or error code.
41 * Clobber list : x1, x2
42 * ---------------------------------------------
43 */
44func console_putc
45 /* Return the printed characted, which is in x0 */
46 ret
47endfunc console_putc
48
49 /* ---------------------------------------------
50 * int console_getc(void)
51 * Function to get a character from the console.
52 * It returns the character grabbed on success
53 * or an error code on error. This function is
54 * blocking, it waits until there is an
55 * available character to return.
56 * Out : w0 - Return character or error code.
57 * Clobber list : x0 - x3
58 * ---------------------------------------------
59 */
60func console_getc
61 mov w0, #ERROR_NO_VALID_CONSOLE
62 ret
63endfunc console_getc
64
65 /* ---------------------------------------------
66 * int console_try_getc(void)
67 * Function to get a character from the console.
68 * It returns the character grabbed on success
69 * or an error code on error. This function is
70 * non-blocking, it returns immediately.
71 * Out : w0 - Return character or error code.
72 * Clobber list : x0, x1
73 * ---------------------------------------------
74 */
75func console_try_getc
76 mov w0, #ERROR_NO_PENDING_CHAR
77 ret
78endfunc console_try_getc
79
80 /* ---------------------------------------------
81 * int console_flush(void)
82 * Function to force a write of all buffered
83 * data that hasn't been output. It returns 0
84 * upon successful completion, otherwise it
85 * returns an error code.
86 * Out: w0 - Error code or 0.
87 * Clobber list : x0, x1
88 * ---------------------------------------------
89 */
90func console_flush
91 mov w0, #0
92 ret
93endfunc console_flush