blob: 55e7abbfcab8cce8f44259484214d68490c5e73a [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>
13#include <console.h>
14
15 .globl plat_crash_console_init
16 .globl plat_crash_console_putc
17 .globl plat_crash_console_flush
18
Julius Werner351ba732018-11-20 13:02:27 -080019#if !MULTI_CONSOLE_API
20#error "This crash console implementation only works with the MULTI_CONSOLE_API!"
21#endif
Antonio Nino Diaz4bac0452018-10-16 14:32:34 +010022
23 /* -----------------------------------------------------
24 * int plat_crash_console_init(void)
25 * Use normal console by default. Switch it to crash
26 * mode so serial consoles become active again.
27 * NOTE: This default implementation will only work for
28 * crashes that occur after a normal console (marked
29 * valid for the crash state) has been registered with
30 * the console framework. To debug crashes that occur
31 * earlier, the platform has to override these functions
32 * with an implementation that initializes a console
33 * driver with hardcoded parameters. See
34 * docs/porting-guide.rst for more information.
35 * -----------------------------------------------------
36 */
37func plat_crash_console_init
38#if defined(IMAGE_BL1)
39 /*
40 * BL1 code can possibly crash so early that the data segment is not yet
41 * accessible. Don't risk undefined behavior by trying to run the normal
42 * console framework. Platforms that want to debug BL1 will need to
43 * override this with custom functions that can run from registers only.
44 */
45 mov x0, #0
46 ret
47#else /* IMAGE_BL1 */
48 mov x3, x30
49 mov x0, #CONSOLE_FLAG_CRASH
50 bl console_switch_state
51 mov x0, #1
52 ret x3
53#endif
54endfunc plat_crash_console_init
55
56 /* -----------------------------------------------------
57 * void plat_crash_console_putc(int character)
58 * Output through the normal console by default.
59 * -----------------------------------------------------
60 */
61func plat_crash_console_putc
62 b console_putc
63endfunc plat_crash_console_putc
64
65 /* -----------------------------------------------------
66 * void plat_crash_console_flush(void)
67 * Flush normal console by default.
68 * -----------------------------------------------------
69 */
70func plat_crash_console_flush
71 b console_flush
72endfunc plat_crash_console_flush