blob: 0b60bc750896292b20648435e9640187917cf2aa [file] [log] [blame]
Soby Mathew420cc372016-03-24 16:52:40 +00001/*
Antonio Nino Diaz8377ae42017-02-06 16:03:41 +00002 * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
Soby Mathew420cc372016-03-24 16:52:40 +00003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30#include <asm_macros.S>
31
32 /*
33 * This file contains a skeleton console implementation that can
34 * be used as basis for a real console implementation by platforms
35 * that do not contain PL011 hardware.
36 */
37
38 .globl console_core_init
39 .globl console_core_putc
40 .globl console_core_getc
Antonio Nino Diaz8377ae42017-02-06 16:03:41 +000041 .globl console_core_flush
Soby Mathew420cc372016-03-24 16:52:40 +000042
43 /* -----------------------------------------------
44 * int console_core_init(uintptr_t base_addr,
45 * unsigned int uart_clk, unsigned int baud_rate)
46 * Function to initialize the console without a
47 * C Runtime to print debug information. This
48 * function will be accessed by console_init and
49 * crash reporting.
50 * In: r0 - console base address
51 * r1 - Uart clock in Hz
52 * r2 - Baud rate
53 * Out: return 1 on success else 0 on error
54 * Clobber list : r1, r2
55 * -----------------------------------------------
56 */
57func console_core_init
58 /* Check the input base address */
59 cmp r0, #0
60 beq core_init_fail
61 /* Check baud rate and uart clock for sanity */
62 cmp r1, #0
63 beq core_init_fail
64 cmp r2, #0
65 beq core_init_fail
66 /* Insert implementation here */
67 mov r0, #1
68 bx lr
69core_init_fail:
70 mov r0, #0
71 bx lr
72endfunc console_core_init
73
74 /* --------------------------------------------------------
75 * int console_core_putc(int c, uintptr_t base_addr)
76 * Function to output a character over the console. It
77 * returns the character printed on success or -1 on error.
78 * In : r0 - character to be printed
79 * r1 - console base address
80 * Out : return -1 on error else return character.
81 * Clobber list : r2
82 * --------------------------------------------------------
83 */
84func console_core_putc
85 /* Check the input parameter */
86 cmp r1, #0
87 beq putc_error
88 /* Insert implementation here */
89 bx lr
90putc_error:
91 mov r0, #-1
92 bx lr
93endfunc console_core_putc
94
95 /* ---------------------------------------------
96 * int console_core_getc(uintptr_t base_addr)
97 * Function to get a character from the console.
98 * It returns the character grabbed on success
99 * or -1 on error.
100 * In : r0 - console base address
101 * Clobber list : r0, r1
102 * ---------------------------------------------
103 */
104func console_core_getc
105 cmp r0, #0
106 beq getc_error
107 /* Insert implementation here */
108 bx lr
109getc_error:
110 mov r0, #-1
111 bx lr
112endfunc console_core_getc
Antonio Nino Diaz8377ae42017-02-06 16:03:41 +0000113
114 /* ---------------------------------------------
115 * int console_core_flush(uintptr_t base_addr)
116 * Function to force a write of all buffered
117 * data that hasn't been output.
118 * In : r0 - console base address
119 * Out : return -1 on error else return 0.
120 * Clobber list : r0, r1
121 * ---------------------------------------------
122 */
123func console_core_flush
124 cmp r0, #0
125 beq flush_error
126 /* Insert implementation here */
127 mov r0, #0
128 bx lr
129flush_error:
130 mov r0, #-1
131 bx lr
132endfunc console_core_flush