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