blob: 1583ee7d1a11ca305309702b8324cfdbe0745d7b [file] [log] [blame]
Soby Mathew7abebe82016-08-08 12:38:52 +01001/*
2 * Copyright (c) 2015-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: x0 - console base address
50 * w1 - Uart clock in Hz
51 * w2 - Baud rate
52 * Out: return 1 on success else 0 on error
53 * Clobber list : x1, x2
54 * -----------------------------------------------
55 */
56func console_core_init
57 /* Check the input base address */
58 cbz x0, core_init_fail
59 /* Check baud rate and uart clock for sanity */
60 cbz w1, core_init_fail
61 cbz w2, core_init_fail
62 /* Insert implementation here */
63 mov w0, #1
64 ret
65core_init_fail:
66 mov w0, wzr
67 ret
68endfunc console_core_init
69
70 /* --------------------------------------------------------
71 * int console_core_putc(int c, uintptr_t base_addr)
72 * Function to output a character over the console. It
73 * returns the character printed on success or -1 on error.
74 * In : w0 - character to be printed
75 * x1 - console base address
76 * Out : return -1 on error else return character.
77 * Clobber list : x2
78 * --------------------------------------------------------
79 */
80func console_core_putc
81 /* Check the input parameter */
82 cbz x1, putc_error
83 /* Insert implementation here */
84 ret
85putc_error:
86 mov w0, #-1
87 ret
88endfunc console_core_putc
89
90 /* ---------------------------------------------
91 * int console_core_getc(uintptr_t base_addr)
92 * Function to get a character from the console.
93 * It returns the character grabbed on success
94 * or -1 on error.
95 * In : x0 - console base address
96 * Clobber list : x0, x1
97 * ---------------------------------------------
98 */
99func console_core_getc
100 cbz x0, getc_error
101 /* Insert implementation here */
102 ret
103getc_error:
104 mov w0, #-1
105 ret
106endfunc console_core_getc