1*91f16700Schasinglulu/* 2*91f16700Schasinglulu * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. 3*91f16700Schasinglulu * 4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause 5*91f16700Schasinglulu */ 6*91f16700Schasinglulu#ifndef CONSOLE_MACROS_S 7*91f16700Schasinglulu#define CONSOLE_MACROS_S 8*91f16700Schasinglulu 9*91f16700Schasinglulu#include <drivers/console.h> 10*91f16700Schasinglulu 11*91f16700Schasinglulu/* 12*91f16700Schasinglulu * This macro encapsulates the common setup that has to be done at the end of 13*91f16700Schasinglulu * a console driver's register function. It will register all of the driver's 14*91f16700Schasinglulu * callbacks in the console_t structure and initialize the flags field (by 15*91f16700Schasinglulu * default consoles are enabled for the "boot" and "crash" states, this can be 16*91f16700Schasinglulu * changed after registration with the console_set_scope() function). It ends 17*91f16700Schasinglulu * with a tail call that will include return to the caller. 18*91f16700Schasinglulu * REQUIRES console_t pointer in x0 and a valid return address in x30. 19*91f16700Schasinglulu */ 20*91f16700Schasinglulu .macro finish_console_register _driver, putc=0, getc=0, flush=0 21*91f16700Schasinglulu /* 22*91f16700Schasinglulu * If any of the callback is not specified or set as 0, then the 23*91f16700Schasinglulu * corresponding callback entry in console_t is set to 0. 24*91f16700Schasinglulu */ 25*91f16700Schasinglulu .ifne \putc 26*91f16700Schasinglulu adrp x1, console_\_driver\()_putc 27*91f16700Schasinglulu add x1, x1, :lo12:console_\_driver\()_putc 28*91f16700Schasinglulu str x1, [x0, #CONSOLE_T_PUTC] 29*91f16700Schasinglulu .else 30*91f16700Schasinglulu str xzr, [x0, #CONSOLE_T_PUTC] 31*91f16700Schasinglulu .endif 32*91f16700Schasinglulu 33*91f16700Schasinglulu /* 34*91f16700Schasinglulu * If ENABLE_CONSOLE_GETC support is disabled, but a getc callback is 35*91f16700Schasinglulu * specified nonetheless, the assembler will abort on encountering the 36*91f16700Schasinglulu * CONSOLE_T_GETC macro, which is undefined. 37*91f16700Schasinglulu */ 38*91f16700Schasinglulu .ifne \getc 39*91f16700Schasinglulu adrp x1, console_\_driver\()_getc 40*91f16700Schasinglulu add x1, x1, :lo12:console_\_driver\()_getc 41*91f16700Schasinglulu str x1, [x0, #CONSOLE_T_GETC] 42*91f16700Schasinglulu .else 43*91f16700Schasinglulu#if ENABLE_CONSOLE_GETC 44*91f16700Schasinglulu str xzr, [x0, #CONSOLE_T_GETC] 45*91f16700Schasinglulu#endif 46*91f16700Schasinglulu .endif 47*91f16700Schasinglulu 48*91f16700Schasinglulu .ifne \flush 49*91f16700Schasinglulu adrp x1, console_\_driver\()_flush 50*91f16700Schasinglulu add x1, x1, :lo12:console_\_driver\()_flush 51*91f16700Schasinglulu str x1, [x0, #CONSOLE_T_FLUSH] 52*91f16700Schasinglulu .else 53*91f16700Schasinglulu str xzr, [x0, #CONSOLE_T_FLUSH] 54*91f16700Schasinglulu .endif 55*91f16700Schasinglulu 56*91f16700Schasinglulu mov x1, #(CONSOLE_FLAG_BOOT | CONSOLE_FLAG_CRASH) 57*91f16700Schasinglulu str x1, [x0, #CONSOLE_T_FLAGS] 58*91f16700Schasinglulu b console_register 59*91f16700Schasinglulu .endm 60*91f16700Schasinglulu 61*91f16700Schasinglulu#endif /* CONSOLE_MACROS_S */ 62