Soby Mathew | 7abebe8 | 2016-08-08 12:38:52 +0100 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 8377ae4 | 2017-02-06 16:03:41 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | 7abebe8 | 2016-08-08 12:38:52 +0100 | [diff] [blame] | 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 |
Antonio Nino Diaz | 8377ae4 | 2017-02-06 16:03:41 +0000 | [diff] [blame] | 41 | .globl console_core_flush |
Soby Mathew | 7abebe8 | 2016-08-08 12:38:52 +0100 | [diff] [blame] | 42 | |
| 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: x0 - console base address |
| 51 | * w1 - Uart clock in Hz |
| 52 | * w2 - Baud rate |
| 53 | * Out: return 1 on success else 0 on error |
| 54 | * Clobber list : x1, x2 |
| 55 | * ----------------------------------------------- |
| 56 | */ |
| 57 | func console_core_init |
| 58 | /* Check the input base address */ |
| 59 | cbz x0, core_init_fail |
| 60 | /* Check baud rate and uart clock for sanity */ |
| 61 | cbz w1, core_init_fail |
| 62 | cbz w2, core_init_fail |
| 63 | /* Insert implementation here */ |
| 64 | mov w0, #1 |
| 65 | ret |
| 66 | core_init_fail: |
| 67 | mov w0, wzr |
| 68 | ret |
| 69 | endfunc console_core_init |
| 70 | |
| 71 | /* -------------------------------------------------------- |
| 72 | * int console_core_putc(int c, uintptr_t base_addr) |
| 73 | * Function to output a character over the console. It |
| 74 | * returns the character printed on success or -1 on error. |
| 75 | * In : w0 - character to be printed |
| 76 | * x1 - console base address |
| 77 | * Out : return -1 on error else return character. |
| 78 | * Clobber list : x2 |
| 79 | * -------------------------------------------------------- |
| 80 | */ |
| 81 | func console_core_putc |
| 82 | /* Check the input parameter */ |
| 83 | cbz x1, putc_error |
| 84 | /* Insert implementation here */ |
| 85 | ret |
| 86 | putc_error: |
| 87 | mov w0, #-1 |
| 88 | ret |
| 89 | endfunc console_core_putc |
| 90 | |
| 91 | /* --------------------------------------------- |
| 92 | * int console_core_getc(uintptr_t base_addr) |
| 93 | * Function to get a character from the console. |
| 94 | * It returns the character grabbed on success |
| 95 | * or -1 on error. |
| 96 | * In : x0 - console base address |
| 97 | * Clobber list : x0, x1 |
| 98 | * --------------------------------------------- |
| 99 | */ |
| 100 | func console_core_getc |
| 101 | cbz x0, getc_error |
| 102 | /* Insert implementation here */ |
| 103 | ret |
| 104 | getc_error: |
| 105 | mov w0, #-1 |
| 106 | ret |
| 107 | endfunc console_core_getc |
Antonio Nino Diaz | 8377ae4 | 2017-02-06 16:03:41 +0000 | [diff] [blame] | 108 | |
| 109 | /* --------------------------------------------- |
| 110 | * int console_core_flush(uintptr_t base_addr) |
| 111 | * Function to force a write of all buffered |
| 112 | * data that hasn't been output. |
| 113 | * In : x0 - console base address |
| 114 | * Out : return -1 on error else return 0. |
| 115 | * Clobber list : x0, x1 |
| 116 | * --------------------------------------------- |
| 117 | */ |
| 118 | func console_core_flush |
| 119 | cbz x0, flush_error |
| 120 | /* Insert implementation here */ |
| 121 | mov w0, #0 |
| 122 | ret |
| 123 | flush_error: |
| 124 | mov w0, #-1 |
| 125 | ret |
| 126 | endfunc console_core_flush |