• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6#include <asm_macros.S>
7
8	/*
9	 * This file contains a skeleton console implementation that can
10	 * be used as basis for a real console implementation by platforms
11	 * that do not contain PL011 hardware.
12	 */
13
14	.globl	console_core_init
15	.globl	console_core_putc
16	.globl	console_core_getc
17	.globl	console_core_flush
18
19	/* -----------------------------------------------
20	 * int console_core_init(uintptr_t base_addr,
21	 * unsigned int uart_clk, unsigned int baud_rate)
22	 * Function to initialize the console without a
23	 * C Runtime to print debug information. This
24	 * function will be accessed by console_init and
25	 * crash reporting.
26	 * In: x0 - console base address
27	 *     w1 - Uart clock in Hz
28	 *     w2 - Baud rate
29	 * Out: return 1 on success else 0 on error
30	 * Clobber list : x1, x2
31	 * -----------------------------------------------
32	 */
33func console_core_init
34	/* Check the input base address */
35	cbz	x0, core_init_fail
36	/* Check baud rate and uart clock for sanity */
37	cbz	w1, core_init_fail
38	cbz	w2, core_init_fail
39	/* Insert implementation here */
40	mov	w0, #1
41	ret
42core_init_fail:
43	mov	w0, wzr
44	ret
45endfunc console_core_init
46
47	/* --------------------------------------------------------
48	 * int console_core_putc(int c, uintptr_t base_addr)
49	 * Function to output a character over the console. It
50	 * returns the character printed on success or -1 on error.
51	 * In : w0 - character to be printed
52	 *      x1 - console base address
53	 * Out : return -1 on error else return character.
54	 * Clobber list : x2
55	 * --------------------------------------------------------
56	 */
57func console_core_putc
58	/* Check the input parameter */
59	cbz	x1, putc_error
60	/* Insert implementation here */
61	ret
62putc_error:
63	mov	w0, #-1
64	ret
65endfunc console_core_putc
66
67	/* ---------------------------------------------
68	 * int console_core_getc(uintptr_t base_addr)
69	 * Function to get a character from the console.
70	 * It returns the character grabbed on success
71	 * or -1 on error.
72	 * In : x0 - console base address
73	 * Clobber list : x0, x1
74	 * ---------------------------------------------
75	 */
76func console_core_getc
77	cbz	x0, getc_error
78	/* Insert implementation here */
79	ret
80getc_error:
81	mov	w0, #-1
82	ret
83endfunc console_core_getc
84
85	/* ---------------------------------------------
86	 * int console_core_flush(uintptr_t base_addr)
87	 * Function to force a write of all buffered
88	 * data that hasn't been output.
89	 * In : x0 - console base address
90	 * Out : return -1 on error else return 0.
91	 * Clobber list : x0, x1
92	 * ---------------------------------------------
93	 */
94func console_core_flush
95	cbz	x0, flush_error
96	/* Insert implementation here */
97	mov	w0, #0
98	ret
99flush_error:
100	mov	w0, #-1
101	ret
102endfunc console_core_flush
103