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