Soby Mathew | 420cc37 | 2016-03-24 16:52:40 +0000 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 8377ae4 | 2017-02-06 16:03:41 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | 420cc37 | 2016-03-24 16:52:40 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Soby Mathew | 420cc37 | 2016-03-24 16:52:40 +0000 | [diff] [blame] | 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 |
Antonio Nino Diaz | 8377ae4 | 2017-02-06 16:03:41 +0000 | [diff] [blame] | 17 | .globl console_core_flush |
Soby Mathew | 420cc37 | 2016-03-24 16:52:40 +0000 | [diff] [blame] | 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 | */ |
| 33 | func 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 |
| 45 | core_init_fail: |
| 46 | mov r0, #0 |
| 47 | bx lr |
| 48 | endfunc 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 | */ |
| 60 | func console_core_putc |
| 61 | /* Check the input parameter */ |
| 62 | cmp r1, #0 |
| 63 | beq putc_error |
| 64 | /* Insert implementation here */ |
| 65 | bx lr |
| 66 | putc_error: |
| 67 | mov r0, #-1 |
| 68 | bx lr |
| 69 | endfunc 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 | */ |
| 80 | func console_core_getc |
| 81 | cmp r0, #0 |
| 82 | beq getc_error |
| 83 | /* Insert implementation here */ |
| 84 | bx lr |
| 85 | getc_error: |
| 86 | mov r0, #-1 |
| 87 | bx lr |
| 88 | endfunc console_core_getc |
Antonio Nino Diaz | 8377ae4 | 2017-02-06 16:03:41 +0000 | [diff] [blame] | 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 | */ |
| 99 | func console_core_flush |
| 100 | cmp r0, #0 |
| 101 | beq flush_error |
| 102 | /* Insert implementation here */ |
| 103 | mov r0, #0 |
| 104 | bx lr |
| 105 | flush_error: |
| 106 | mov r0, #-1 |
| 107 | bx lr |
| 108 | endfunc console_core_flush |