blob: 383874e6cd06fbbffc530a34342b50ca44917b29 [file] [log] [blame]
Soby Mathew420cc372016-03-24 16:52:40 +00001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
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
41
42 /* -----------------------------------------------
43 * int console_core_init(uintptr_t base_addr,
44 * unsigned int uart_clk, unsigned int baud_rate)
45 * Function to initialize the console without a
46 * C Runtime to print debug information. This
47 * function will be accessed by console_init and
48 * crash reporting.
49 * In: r0 - console base address
50 * r1 - Uart clock in Hz
51 * r2 - Baud rate
52 * Out: return 1 on success else 0 on error
53 * Clobber list : r1, r2
54 * -----------------------------------------------
55 */
56func console_core_init
57 /* Check the input base address */
58 cmp r0, #0
59 beq core_init_fail
60 /* Check baud rate and uart clock for sanity */
61 cmp r1, #0
62 beq core_init_fail
63 cmp r2, #0
64 beq core_init_fail
65 /* Insert implementation here */
66 mov r0, #1
67 bx lr
68core_init_fail:
69 mov r0, #0
70 bx lr
71endfunc console_core_init
72
73 /* --------------------------------------------------------
74 * int console_core_putc(int c, uintptr_t base_addr)
75 * Function to output a character over the console. It
76 * returns the character printed on success or -1 on error.
77 * In : r0 - character to be printed
78 * r1 - console base address
79 * Out : return -1 on error else return character.
80 * Clobber list : r2
81 * --------------------------------------------------------
82 */
83func console_core_putc
84 /* Check the input parameter */
85 cmp r1, #0
86 beq putc_error
87 /* Insert implementation here */
88 bx lr
89putc_error:
90 mov r0, #-1
91 bx lr
92endfunc console_core_putc
93
94 /* ---------------------------------------------
95 * int console_core_getc(uintptr_t base_addr)
96 * Function to get a character from the console.
97 * It returns the character grabbed on success
98 * or -1 on error.
99 * In : r0 - console base address
100 * Clobber list : r0, r1
101 * ---------------------------------------------
102 */
103func console_core_getc
104 cmp r0, #0
105 beq getc_error
106 /* Insert implementation here */
107 bx lr
108getc_error:
109 mov r0, #-1
110 bx lr
111endfunc console_core_getc