xref: /rk3399_ARM-atf/drivers/console/aarch64/skeleton_console.S (revision 73e052846ab4c45194d639ab65b523448a7d7edd)
19c94d3b3SSoby Mathew/*
2*73e05284SAntonio Nino Diaz * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
39c94d3b3SSoby Mathew *
49c94d3b3SSoby Mathew * Redistribution and use in source and binary forms, with or without
59c94d3b3SSoby Mathew * modification, are permitted provided that the following conditions are met:
69c94d3b3SSoby Mathew *
79c94d3b3SSoby Mathew * Redistributions of source code must retain the above copyright notice, this
89c94d3b3SSoby Mathew * list of conditions and the following disclaimer.
99c94d3b3SSoby Mathew *
109c94d3b3SSoby Mathew * Redistributions in binary form must reproduce the above copyright notice,
119c94d3b3SSoby Mathew * this list of conditions and the following disclaimer in the documentation
129c94d3b3SSoby Mathew * and/or other materials provided with the distribution.
139c94d3b3SSoby Mathew *
149c94d3b3SSoby Mathew * Neither the name of ARM nor the names of its contributors may be used
159c94d3b3SSoby Mathew * to endorse or promote products derived from this software without specific
169c94d3b3SSoby Mathew * prior written permission.
179c94d3b3SSoby Mathew *
189c94d3b3SSoby Mathew * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
199c94d3b3SSoby Mathew * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
209c94d3b3SSoby Mathew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
219c94d3b3SSoby Mathew * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
229c94d3b3SSoby Mathew * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
239c94d3b3SSoby Mathew * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
249c94d3b3SSoby Mathew * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
259c94d3b3SSoby Mathew * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
269c94d3b3SSoby Mathew * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
279c94d3b3SSoby Mathew * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
289c94d3b3SSoby Mathew * POSSIBILITY OF SUCH DAMAGE.
299c94d3b3SSoby Mathew */
309c94d3b3SSoby Mathew#include <asm_macros.S>
319c94d3b3SSoby Mathew
329c94d3b3SSoby Mathew	/*
339c94d3b3SSoby Mathew	 * This file contains a skeleton console implementation that can
349c94d3b3SSoby Mathew	 * be used as basis for a real console implementation by platforms
359c94d3b3SSoby Mathew	 * that do not contain PL011 hardware.
369c94d3b3SSoby Mathew	 */
379c94d3b3SSoby Mathew
389c94d3b3SSoby Mathew	.globl	console_core_init
399c94d3b3SSoby Mathew	.globl	console_core_putc
409c94d3b3SSoby Mathew	.globl	console_core_getc
41*73e05284SAntonio Nino Diaz	.globl	console_core_flush
429c94d3b3SSoby Mathew
439c94d3b3SSoby Mathew	/* -----------------------------------------------
449c94d3b3SSoby Mathew	 * int console_core_init(uintptr_t base_addr,
459c94d3b3SSoby Mathew	 * unsigned int uart_clk, unsigned int baud_rate)
469c94d3b3SSoby Mathew	 * Function to initialize the console without a
479c94d3b3SSoby Mathew	 * C Runtime to print debug information. This
489c94d3b3SSoby Mathew	 * function will be accessed by console_init and
499c94d3b3SSoby Mathew	 * crash reporting.
509c94d3b3SSoby Mathew	 * In: x0 - console base address
519c94d3b3SSoby Mathew	 *     w1 - Uart clock in Hz
529c94d3b3SSoby Mathew	 *     w2 - Baud rate
539c94d3b3SSoby Mathew	 * Out: return 1 on success else 0 on error
549c94d3b3SSoby Mathew	 * Clobber list : x1, x2
559c94d3b3SSoby Mathew	 * -----------------------------------------------
569c94d3b3SSoby Mathew	 */
579c94d3b3SSoby Mathewfunc console_core_init
589c94d3b3SSoby Mathew	/* Check the input base address */
599c94d3b3SSoby Mathew	cbz	x0, core_init_fail
609c94d3b3SSoby Mathew	/* Check baud rate and uart clock for sanity */
619c94d3b3SSoby Mathew	cbz	w1, core_init_fail
629c94d3b3SSoby Mathew	cbz	w2, core_init_fail
639c94d3b3SSoby Mathew	/* Insert implementation here */
649c94d3b3SSoby Mathew	mov	w0, #1
659c94d3b3SSoby Mathew	ret
669c94d3b3SSoby Mathewcore_init_fail:
679c94d3b3SSoby Mathew	mov	w0, wzr
689c94d3b3SSoby Mathew	ret
699c94d3b3SSoby Mathewendfunc console_core_init
709c94d3b3SSoby Mathew
719c94d3b3SSoby Mathew	/* --------------------------------------------------------
729c94d3b3SSoby Mathew	 * int console_core_putc(int c, uintptr_t base_addr)
739c94d3b3SSoby Mathew	 * Function to output a character over the console. It
749c94d3b3SSoby Mathew	 * returns the character printed on success or -1 on error.
759c94d3b3SSoby Mathew	 * In : w0 - character to be printed
769c94d3b3SSoby Mathew	 *      x1 - console base address
779c94d3b3SSoby Mathew	 * Out : return -1 on error else return character.
789c94d3b3SSoby Mathew	 * Clobber list : x2
799c94d3b3SSoby Mathew	 * --------------------------------------------------------
809c94d3b3SSoby Mathew	 */
819c94d3b3SSoby Mathewfunc console_core_putc
829c94d3b3SSoby Mathew	/* Check the input parameter */
839c94d3b3SSoby Mathew	cbz	x1, putc_error
849c94d3b3SSoby Mathew	/* Insert implementation here */
859c94d3b3SSoby Mathew	ret
869c94d3b3SSoby Mathewputc_error:
879c94d3b3SSoby Mathew	mov	w0, #-1
889c94d3b3SSoby Mathew	ret
899c94d3b3SSoby Mathewendfunc console_core_putc
909c94d3b3SSoby Mathew
919c94d3b3SSoby Mathew	/* ---------------------------------------------
929c94d3b3SSoby Mathew	 * int console_core_getc(uintptr_t base_addr)
939c94d3b3SSoby Mathew	 * Function to get a character from the console.
949c94d3b3SSoby Mathew	 * It returns the character grabbed on success
959c94d3b3SSoby Mathew	 * or -1 on error.
969c94d3b3SSoby Mathew	 * In : x0 - console base address
979c94d3b3SSoby Mathew	 * Clobber list : x0, x1
989c94d3b3SSoby Mathew	 * ---------------------------------------------
999c94d3b3SSoby Mathew	 */
1009c94d3b3SSoby Mathewfunc console_core_getc
1019c94d3b3SSoby Mathew	cbz	x0, getc_error
1029c94d3b3SSoby Mathew	/* Insert implementation here */
1039c94d3b3SSoby Mathew	ret
1049c94d3b3SSoby Mathewgetc_error:
1059c94d3b3SSoby Mathew	mov	w0, #-1
1069c94d3b3SSoby Mathew	ret
1079c94d3b3SSoby Mathewendfunc console_core_getc
108*73e05284SAntonio Nino Diaz
109*73e05284SAntonio Nino Diaz	/* ---------------------------------------------
110*73e05284SAntonio Nino Diaz	 * int console_core_flush(uintptr_t base_addr)
111*73e05284SAntonio Nino Diaz	 * Function to force a write of all buffered
112*73e05284SAntonio Nino Diaz	 * data that hasn't been output.
113*73e05284SAntonio Nino Diaz	 * In : x0 - console base address
114*73e05284SAntonio Nino Diaz	 * Out : return -1 on error else return 0.
115*73e05284SAntonio Nino Diaz	 * Clobber list : x0, x1
116*73e05284SAntonio Nino Diaz	 * ---------------------------------------------
117*73e05284SAntonio Nino Diaz	 */
118*73e05284SAntonio Nino Diazfunc console_core_flush
119*73e05284SAntonio Nino Diaz	cbz	x0, flush_error
120*73e05284SAntonio Nino Diaz	/* Insert implementation here */
121*73e05284SAntonio Nino Diaz	mov	w0, #0
122*73e05284SAntonio Nino Diaz	ret
123*73e05284SAntonio Nino Diazflush_error:
124*73e05284SAntonio Nino Diaz	mov	w0, #-1
125*73e05284SAntonio Nino Diaz	ret
126*73e05284SAntonio Nino Diazendfunc console_core_flush
127