1*9c94d3b3SSoby Mathew/* 2*9c94d3b3SSoby Mathew * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. 3*9c94d3b3SSoby Mathew * 4*9c94d3b3SSoby Mathew * Redistribution and use in source and binary forms, with or without 5*9c94d3b3SSoby Mathew * modification, are permitted provided that the following conditions are met: 6*9c94d3b3SSoby Mathew * 7*9c94d3b3SSoby Mathew * Redistributions of source code must retain the above copyright notice, this 8*9c94d3b3SSoby Mathew * list of conditions and the following disclaimer. 9*9c94d3b3SSoby Mathew * 10*9c94d3b3SSoby Mathew * Redistributions in binary form must reproduce the above copyright notice, 11*9c94d3b3SSoby Mathew * this list of conditions and the following disclaimer in the documentation 12*9c94d3b3SSoby Mathew * and/or other materials provided with the distribution. 13*9c94d3b3SSoby Mathew * 14*9c94d3b3SSoby Mathew * Neither the name of ARM nor the names of its contributors may be used 15*9c94d3b3SSoby Mathew * to endorse or promote products derived from this software without specific 16*9c94d3b3SSoby Mathew * prior written permission. 17*9c94d3b3SSoby Mathew * 18*9c94d3b3SSoby Mathew * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19*9c94d3b3SSoby Mathew * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20*9c94d3b3SSoby Mathew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21*9c94d3b3SSoby Mathew * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22*9c94d3b3SSoby Mathew * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*9c94d3b3SSoby Mathew * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*9c94d3b3SSoby Mathew * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*9c94d3b3SSoby Mathew * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*9c94d3b3SSoby Mathew * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*9c94d3b3SSoby Mathew * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*9c94d3b3SSoby Mathew * POSSIBILITY OF SUCH DAMAGE. 29*9c94d3b3SSoby Mathew */ 30*9c94d3b3SSoby Mathew#include <asm_macros.S> 31*9c94d3b3SSoby Mathew 32*9c94d3b3SSoby Mathew /* 33*9c94d3b3SSoby Mathew * This file contains a skeleton console implementation that can 34*9c94d3b3SSoby Mathew * be used as basis for a real console implementation by platforms 35*9c94d3b3SSoby Mathew * that do not contain PL011 hardware. 36*9c94d3b3SSoby Mathew */ 37*9c94d3b3SSoby Mathew 38*9c94d3b3SSoby Mathew .globl console_core_init 39*9c94d3b3SSoby Mathew .globl console_core_putc 40*9c94d3b3SSoby Mathew .globl console_core_getc 41*9c94d3b3SSoby Mathew 42*9c94d3b3SSoby Mathew /* ----------------------------------------------- 43*9c94d3b3SSoby Mathew * int console_core_init(uintptr_t base_addr, 44*9c94d3b3SSoby Mathew * unsigned int uart_clk, unsigned int baud_rate) 45*9c94d3b3SSoby Mathew * Function to initialize the console without a 46*9c94d3b3SSoby Mathew * C Runtime to print debug information. This 47*9c94d3b3SSoby Mathew * function will be accessed by console_init and 48*9c94d3b3SSoby Mathew * crash reporting. 49*9c94d3b3SSoby Mathew * In: x0 - console base address 50*9c94d3b3SSoby Mathew * w1 - Uart clock in Hz 51*9c94d3b3SSoby Mathew * w2 - Baud rate 52*9c94d3b3SSoby Mathew * Out: return 1 on success else 0 on error 53*9c94d3b3SSoby Mathew * Clobber list : x1, x2 54*9c94d3b3SSoby Mathew * ----------------------------------------------- 55*9c94d3b3SSoby Mathew */ 56*9c94d3b3SSoby Mathewfunc console_core_init 57*9c94d3b3SSoby Mathew /* Check the input base address */ 58*9c94d3b3SSoby Mathew cbz x0, core_init_fail 59*9c94d3b3SSoby Mathew /* Check baud rate and uart clock for sanity */ 60*9c94d3b3SSoby Mathew cbz w1, core_init_fail 61*9c94d3b3SSoby Mathew cbz w2, core_init_fail 62*9c94d3b3SSoby Mathew /* Insert implementation here */ 63*9c94d3b3SSoby Mathew mov w0, #1 64*9c94d3b3SSoby Mathew ret 65*9c94d3b3SSoby Mathewcore_init_fail: 66*9c94d3b3SSoby Mathew mov w0, wzr 67*9c94d3b3SSoby Mathew ret 68*9c94d3b3SSoby Mathewendfunc console_core_init 69*9c94d3b3SSoby Mathew 70*9c94d3b3SSoby Mathew /* -------------------------------------------------------- 71*9c94d3b3SSoby Mathew * int console_core_putc(int c, uintptr_t base_addr) 72*9c94d3b3SSoby Mathew * Function to output a character over the console. It 73*9c94d3b3SSoby Mathew * returns the character printed on success or -1 on error. 74*9c94d3b3SSoby Mathew * In : w0 - character to be printed 75*9c94d3b3SSoby Mathew * x1 - console base address 76*9c94d3b3SSoby Mathew * Out : return -1 on error else return character. 77*9c94d3b3SSoby Mathew * Clobber list : x2 78*9c94d3b3SSoby Mathew * -------------------------------------------------------- 79*9c94d3b3SSoby Mathew */ 80*9c94d3b3SSoby Mathewfunc console_core_putc 81*9c94d3b3SSoby Mathew /* Check the input parameter */ 82*9c94d3b3SSoby Mathew cbz x1, putc_error 83*9c94d3b3SSoby Mathew /* Insert implementation here */ 84*9c94d3b3SSoby Mathew ret 85*9c94d3b3SSoby Mathewputc_error: 86*9c94d3b3SSoby Mathew mov w0, #-1 87*9c94d3b3SSoby Mathew ret 88*9c94d3b3SSoby Mathewendfunc console_core_putc 89*9c94d3b3SSoby Mathew 90*9c94d3b3SSoby Mathew /* --------------------------------------------- 91*9c94d3b3SSoby Mathew * int console_core_getc(uintptr_t base_addr) 92*9c94d3b3SSoby Mathew * Function to get a character from the console. 93*9c94d3b3SSoby Mathew * It returns the character grabbed on success 94*9c94d3b3SSoby Mathew * or -1 on error. 95*9c94d3b3SSoby Mathew * In : x0 - console base address 96*9c94d3b3SSoby Mathew * Clobber list : x0, x1 97*9c94d3b3SSoby Mathew * --------------------------------------------- 98*9c94d3b3SSoby Mathew */ 99*9c94d3b3SSoby Mathewfunc console_core_getc 100*9c94d3b3SSoby Mathew cbz x0, getc_error 101*9c94d3b3SSoby Mathew /* Insert implementation here */ 102*9c94d3b3SSoby Mathew ret 103*9c94d3b3SSoby Mathewgetc_error: 104*9c94d3b3SSoby Mathew mov w0, #-1 105*9c94d3b3SSoby Mathew ret 106*9c94d3b3SSoby Mathewendfunc console_core_getc 107