blob: c9ad12cc4fa25ba3944a892df69093eaa22969f0 [file] [log] [blame]
Antonio Nino Diaz4bac0452018-10-16 14:32:34 +01001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7/*
8 * If a platform wishes to use the functions in this file it has to be added to
9 * the Makefile of the platform. It is not included in the common Makefile.
10 */
11
12#include <asm_macros.S>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000013#include <drivers/console.h>
Antonio Nino Diaz4bac0452018-10-16 14:32:34 +010014
15 .globl plat_crash_console_init
16 .globl plat_crash_console_putc
17 .globl plat_crash_console_flush
18
19#if MULTI_CONSOLE_API
20
21 /* -----------------------------------------------------
22 * int plat_crash_console_init(void)
23 * Use normal console by default. Switch it to crash
24 * mode so serial consoles become active again.
25 * NOTE: This default implementation will only work for
26 * crashes that occur after a normal console (marked
27 * valid for the crash state) has been registered with
28 * the console framework. To debug crashes that occur
29 * earlier, the platform has to override these functions
30 * with an implementation that initializes a console
31 * driver with hardcoded parameters. See
32 * docs/porting-guide.rst for more information.
33 * -----------------------------------------------------
34 */
35func plat_crash_console_init
36#if defined(IMAGE_BL1)
37 /*
38 * BL1 code can possibly crash so early that the data segment is not yet
39 * accessible. Don't risk undefined behavior by trying to run the normal
40 * console framework. Platforms that want to debug BL1 will need to
41 * override this with custom functions that can run from registers only.
42 */
43 mov r0, #0
44 bx lr
45#else /* IMAGE_BL1 */
46 mov r3, lr
47 mov r0, #CONSOLE_FLAG_CRASH
48 bl console_switch_state
49 mov r0, #1
50 bx r3
51#endif
52endfunc plat_crash_console_init
53
54 /* -----------------------------------------------------
55 * void plat_crash_console_putc(int character)
56 * Output through the normal console by default.
57 * -----------------------------------------------------
58 */
59func plat_crash_console_putc
60 b console_putc
61endfunc plat_crash_console_putc
62
63 /* -----------------------------------------------------
64 * void plat_crash_console_flush(void)
65 * Flush normal console by default.
66 * -----------------------------------------------------
67 */
68func plat_crash_console_flush
69 b console_flush
70endfunc plat_crash_console_flush
71
72#else /* MULTI_CONSOLE_API */
73
74 /* -----------------------------------------------------
75 * In the old API these are all no-op stubs that need to
76 * be overridden by the platform to be useful.
77 * -----------------------------------------------------
78 */
79func plat_crash_console_init
80 mov r0, #0
81 bx lr
82endfunc plat_crash_console_init
83
84func plat_crash_console_putc
85 bx lr
86endfunc plat_crash_console_putc
87
88func plat_crash_console_flush
89 bx lr
90endfunc plat_crash_console_flush
91
92#endif