19c94d3b3SSoby Mathew/* 273e05284SAntonio Nino Diaz * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. 39c94d3b3SSoby Mathew * 4*82cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 59c94d3b3SSoby Mathew */ 69c94d3b3SSoby Mathew#include <asm_macros.S> 79c94d3b3SSoby Mathew 89c94d3b3SSoby Mathew /* 99c94d3b3SSoby Mathew * This file contains a skeleton console implementation that can 109c94d3b3SSoby Mathew * be used as basis for a real console implementation by platforms 119c94d3b3SSoby Mathew * that do not contain PL011 hardware. 129c94d3b3SSoby Mathew */ 139c94d3b3SSoby Mathew 149c94d3b3SSoby Mathew .globl console_core_init 159c94d3b3SSoby Mathew .globl console_core_putc 169c94d3b3SSoby Mathew .globl console_core_getc 1773e05284SAntonio Nino Diaz .globl console_core_flush 189c94d3b3SSoby Mathew 199c94d3b3SSoby Mathew /* ----------------------------------------------- 209c94d3b3SSoby Mathew * int console_core_init(uintptr_t base_addr, 219c94d3b3SSoby Mathew * unsigned int uart_clk, unsigned int baud_rate) 229c94d3b3SSoby Mathew * Function to initialize the console without a 239c94d3b3SSoby Mathew * C Runtime to print debug information. This 249c94d3b3SSoby Mathew * function will be accessed by console_init and 259c94d3b3SSoby Mathew * crash reporting. 269c94d3b3SSoby Mathew * In: x0 - console base address 279c94d3b3SSoby Mathew * w1 - Uart clock in Hz 289c94d3b3SSoby Mathew * w2 - Baud rate 299c94d3b3SSoby Mathew * Out: return 1 on success else 0 on error 309c94d3b3SSoby Mathew * Clobber list : x1, x2 319c94d3b3SSoby Mathew * ----------------------------------------------- 329c94d3b3SSoby Mathew */ 339c94d3b3SSoby Mathewfunc console_core_init 349c94d3b3SSoby Mathew /* Check the input base address */ 359c94d3b3SSoby Mathew cbz x0, core_init_fail 369c94d3b3SSoby Mathew /* Check baud rate and uart clock for sanity */ 379c94d3b3SSoby Mathew cbz w1, core_init_fail 389c94d3b3SSoby Mathew cbz w2, core_init_fail 399c94d3b3SSoby Mathew /* Insert implementation here */ 409c94d3b3SSoby Mathew mov w0, #1 419c94d3b3SSoby Mathew ret 429c94d3b3SSoby Mathewcore_init_fail: 439c94d3b3SSoby Mathew mov w0, wzr 449c94d3b3SSoby Mathew ret 459c94d3b3SSoby Mathewendfunc console_core_init 469c94d3b3SSoby Mathew 479c94d3b3SSoby Mathew /* -------------------------------------------------------- 489c94d3b3SSoby Mathew * int console_core_putc(int c, uintptr_t base_addr) 499c94d3b3SSoby Mathew * Function to output a character over the console. It 509c94d3b3SSoby Mathew * returns the character printed on success or -1 on error. 519c94d3b3SSoby Mathew * In : w0 - character to be printed 529c94d3b3SSoby Mathew * x1 - console base address 539c94d3b3SSoby Mathew * Out : return -1 on error else return character. 549c94d3b3SSoby Mathew * Clobber list : x2 559c94d3b3SSoby Mathew * -------------------------------------------------------- 569c94d3b3SSoby Mathew */ 579c94d3b3SSoby Mathewfunc console_core_putc 589c94d3b3SSoby Mathew /* Check the input parameter */ 599c94d3b3SSoby Mathew cbz x1, putc_error 609c94d3b3SSoby Mathew /* Insert implementation here */ 619c94d3b3SSoby Mathew ret 629c94d3b3SSoby Mathewputc_error: 639c94d3b3SSoby Mathew mov w0, #-1 649c94d3b3SSoby Mathew ret 659c94d3b3SSoby Mathewendfunc console_core_putc 669c94d3b3SSoby Mathew 679c94d3b3SSoby Mathew /* --------------------------------------------- 689c94d3b3SSoby Mathew * int console_core_getc(uintptr_t base_addr) 699c94d3b3SSoby Mathew * Function to get a character from the console. 709c94d3b3SSoby Mathew * It returns the character grabbed on success 719c94d3b3SSoby Mathew * or -1 on error. 729c94d3b3SSoby Mathew * In : x0 - console base address 739c94d3b3SSoby Mathew * Clobber list : x0, x1 749c94d3b3SSoby Mathew * --------------------------------------------- 759c94d3b3SSoby Mathew */ 769c94d3b3SSoby Mathewfunc console_core_getc 779c94d3b3SSoby Mathew cbz x0, getc_error 789c94d3b3SSoby Mathew /* Insert implementation here */ 799c94d3b3SSoby Mathew ret 809c94d3b3SSoby Mathewgetc_error: 819c94d3b3SSoby Mathew mov w0, #-1 829c94d3b3SSoby Mathew ret 839c94d3b3SSoby Mathewendfunc console_core_getc 8473e05284SAntonio Nino Diaz 8573e05284SAntonio Nino Diaz /* --------------------------------------------- 8673e05284SAntonio Nino Diaz * int console_core_flush(uintptr_t base_addr) 8773e05284SAntonio Nino Diaz * Function to force a write of all buffered 8873e05284SAntonio Nino Diaz * data that hasn't been output. 8973e05284SAntonio Nino Diaz * In : x0 - console base address 9073e05284SAntonio Nino Diaz * Out : return -1 on error else return 0. 9173e05284SAntonio Nino Diaz * Clobber list : x0, x1 9273e05284SAntonio Nino Diaz * --------------------------------------------- 9373e05284SAntonio Nino Diaz */ 9473e05284SAntonio Nino Diazfunc console_core_flush 9573e05284SAntonio Nino Diaz cbz x0, flush_error 9673e05284SAntonio Nino Diaz /* Insert implementation here */ 9773e05284SAntonio Nino Diaz mov w0, #0 9873e05284SAntonio Nino Diaz ret 9973e05284SAntonio Nino Diazflush_error: 10073e05284SAntonio Nino Diaz mov w0, #-1 10173e05284SAntonio Nino Diaz ret 10273e05284SAntonio Nino Diazendfunc console_core_flush 103