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