• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2016-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: r0 - console base address
27	 *     r1 - Uart clock in Hz
28	 *     r2 - Baud rate
29	 * Out: return 1 on success else 0 on error
30	 * Clobber list : r1, r2
31	 * -----------------------------------------------
32	 */
33func console_core_init
34	/* Check the input base address */
35	cmp	r0, #0
36	beq	core_init_fail
37	/* Check baud rate and uart clock for sanity */
38	cmp	r1, #0
39	beq	core_init_fail
40	cmp	r2, #0
41	beq	core_init_fail
42	/* Insert implementation here */
43	mov	r0, #1
44	bx	lr
45core_init_fail:
46	mov	r0, #0
47	bx	lr
48endfunc console_core_init
49
50	/* --------------------------------------------------------
51	 * int console_core_putc(int c, uintptr_t base_addr)
52	 * Function to output a character over the console. It
53	 * returns the character printed on success or -1 on error.
54	 * In : r0 - character to be printed
55	 *      r1 - console base address
56	 * Out : return -1 on error else return character.
57	 * Clobber list : r2
58	 * --------------------------------------------------------
59	 */
60func console_core_putc
61	/* Check the input parameter */
62	cmp	r1, #0
63	beq	putc_error
64	/* Insert implementation here */
65	bx	lr
66putc_error:
67	mov	r0, #-1
68	bx	lr
69endfunc console_core_putc
70
71	/* ---------------------------------------------
72	 * int console_core_getc(uintptr_t base_addr)
73	 * Function to get a character from the console.
74	 * It returns the character grabbed on success
75	 * or -1 on error.
76	 * In : r0 - console base address
77	 * Clobber list : r0, r1
78	 * ---------------------------------------------
79	 */
80func console_core_getc
81	cmp	r0, #0
82	beq	getc_error
83	/* Insert implementation here */
84	bx	lr
85getc_error:
86	mov	r0, #-1
87	bx	lr
88endfunc console_core_getc
89
90	/* ---------------------------------------------
91	 * int console_core_flush(uintptr_t base_addr)
92	 * Function to force a write of all buffered
93	 * data that hasn't been output.
94	 * In : r0 - console base address
95	 * Out : return -1 on error else return 0.
96	 * Clobber list : r0, r1
97	 * ---------------------------------------------
98	 */
99func console_core_flush
100	cmp	r0, #0
101	beq	flush_error
102	/* Insert implementation here */
103	mov	r0, #0
104	bx	lr
105flush_error:
106	mov	r0, #-1
107	bx	lr
108endfunc console_core_flush
109