blob: 852675277efae5c4c4c9ebb449ddc7a8deb8574c [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +00002 * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Achin Gupta4f6ad662013-10-25 09:08:21 +01005 */
6
7#include <arch.h>
Andrew Thoelke38bde412014-03-18 13:46:55 +00008#include <asm_macros.S>
Julius Werneraae9bb12017-09-18 16:49:48 -07009#include <console.h>
Dan Handleyed6ff952014-05-14 17:44:19 +010010#include <platform_def.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +010011
Achin Gupta4f6ad662013-10-25 09:08:21 +010012 .weak plat_report_exception
Soby Mathew066f7132014-07-14 16:57:23 +010013 .weak plat_crash_console_init
14 .weak plat_crash_console_putc
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +000015 .weak plat_crash_console_flush
Soby Mathewf1785fd2014-08-14 12:22:32 +010016 .weak plat_reset_handler
Soby Mathew8e2f2872014-08-14 12:49:05 +010017 .weak plat_disable_acp
Juan Castillod1413b22015-10-05 16:59:38 +010018 .weak bl1_plat_prepare_exit
Juan Castillo26ae5832015-09-25 15:41:14 +010019 .weak plat_error_handler
Antonio Nino Diaz1f21bcf2016-02-01 13:57:25 +000020 .weak plat_panic_handler
Roberto Vargasbc1ae1f2017-09-26 12:53:01 +010021 .weak bl2_plat_preload_setup
22 .weak plat_try_next_boot_source
Achin Gupta4f6ad662013-10-25 09:08:21 +010023
Soby Mathew70716d62015-07-13 16:26:11 +010024#if !ENABLE_PLAT_COMPAT
25 .globl platform_get_core_pos
26
27#define MPIDR_RES_BIT_MASK 0xff000000
28
29 /* ------------------------------------------------------------------
30 * int platform_get_core_pos(int mpidr)
31 * Returns the CPU index of the CPU specified by mpidr. This is
32 * defined when platform compatibility is disabled to enable Trusted
33 * Firmware components like SPD using the old platform API to work.
34 * This API is deprecated and it assumes that the mpidr specified is
35 * that of a valid and present CPU. Instead, plat_my_core_pos()
36 * should be used for CPU index of the current CPU and
37 * plat_core_pos_by_mpidr() should be used for CPU index of a
38 * CPU specified by its mpidr.
39 * ------------------------------------------------------------------
40 */
41func_deprecated platform_get_core_pos
42 bic x0, x0, #MPIDR_RES_BIT_MASK
43 mrs x1, mpidr_el1
44 bic x1, x1, #MPIDR_RES_BIT_MASK
45 cmp x0, x1
46 beq plat_my_core_pos
47 b platform_core_pos_helper
48endfunc_deprecated platform_get_core_pos
49#endif
50
Achin Gupta4f6ad662013-10-25 09:08:21 +010051 /* -----------------------------------------------------
Achin Gupta4f6ad662013-10-25 09:08:21 +010052 * Placeholder function which should be redefined by
53 * each platform.
54 * -----------------------------------------------------
55 */
Andrew Thoelke38bde412014-03-18 13:46:55 +000056func plat_report_exception
Achin Gupta4f6ad662013-10-25 09:08:21 +010057 ret
Kévin Petita877c252015-03-24 14:03:57 +000058endfunc plat_report_exception
Soby Mathew066f7132014-07-14 16:57:23 +010059
Julius Werneraae9bb12017-09-18 16:49:48 -070060#if MULTI_CONSOLE_API
Soby Mathew066f7132014-07-14 16:57:23 +010061 /* -----------------------------------------------------
Julius Werneraae9bb12017-09-18 16:49:48 -070062 * int plat_crash_console_init(void)
63 * Use normal console by default. Switch it to crash
64 * mode so serial consoles become active again.
65 * NOTE: This default implementation will only work for
66 * crashes that occur after a normal console (marked
67 * valid for the crash state) has been registered with
68 * the console framework. To debug crashes that occur
69 * earlier, the platform has to override these functions
70 * with an implementation that initializes a console
71 * driver with hardcoded parameters. See
72 * docs/porting-guide.rst for more information.
Soby Mathew066f7132014-07-14 16:57:23 +010073 * -----------------------------------------------------
74 */
75func plat_crash_console_init
Julius Werneraae9bb12017-09-18 16:49:48 -070076#if defined(IMAGE_BL1)
77 /*
78 * BL1 code can possibly crash so early that the data segment is not yet
79 * accessible. Don't risk undefined behavior by trying to run the normal
80 * console framework. Platforms that want to debug BL1 will need to
81 * override this with custom functions that can run from registers only.
82 */
Soby Mathew066f7132014-07-14 16:57:23 +010083 mov x0, #0
84 ret
Julius Werneraae9bb12017-09-18 16:49:48 -070085#else /* IMAGE_BL1 */
86 mov x3, x30
87 mov x0, #CONSOLE_FLAG_CRASH
88 bl console_switch_state
89 mov x0, #1
90 ret x3
91#endif
Kévin Petita877c252015-03-24 14:03:57 +000092endfunc plat_crash_console_init
Soby Mathew066f7132014-07-14 16:57:23 +010093
94 /* -----------------------------------------------------
Julius Werneraae9bb12017-09-18 16:49:48 -070095 * void plat_crash_console_putc(int character)
96 * Output through the normal console by default.
Soby Mathew066f7132014-07-14 16:57:23 +010097 * -----------------------------------------------------
98 */
99func plat_crash_console_putc
Julius Werneraae9bb12017-09-18 16:49:48 -0700100 b console_putc
Kévin Petita877c252015-03-24 14:03:57 +0000101endfunc plat_crash_console_putc
Soby Mathewf1785fd2014-08-14 12:22:32 +0100102
103 /* -----------------------------------------------------
Julius Werneraae9bb12017-09-18 16:49:48 -0700104 * void plat_crash_console_flush(void)
105 * Flush normal console by default.
106 * -----------------------------------------------------
107 */
108func plat_crash_console_flush
109 b console_flush
110endfunc plat_crash_console_flush
111
112#else /* MULTI_CONSOLE_API */
113
114 /* -----------------------------------------------------
115 * In the old API these are all no-op stubs that need to
116 * be overridden by the platform to be useful.
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +0000117 * -----------------------------------------------------
118 */
Julius Werneraae9bb12017-09-18 16:49:48 -0700119func plat_crash_console_init
120 mov x0, #0
121 ret
122endfunc plat_crash_console_init
123
124func plat_crash_console_putc
125 ret
126endfunc plat_crash_console_putc
127
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +0000128func plat_crash_console_flush
129 ret
130endfunc plat_crash_console_flush
Julius Werneraae9bb12017-09-18 16:49:48 -0700131#endif
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +0000132
133 /* -----------------------------------------------------
134 * Placeholder function which should be redefined by
Masahiro Yamada4c165ca2016-09-24 18:07:46 +0900135 * each platform. This function should preserve x19 - x29.
Soby Mathewf1785fd2014-08-14 12:22:32 +0100136 * -----------------------------------------------------
137 */
138func plat_reset_handler
139 ret
Kévin Petita877c252015-03-24 14:03:57 +0000140endfunc plat_reset_handler
Soby Mathew8e2f2872014-08-14 12:49:05 +0100141
142 /* -----------------------------------------------------
143 * Placeholder function which should be redefined by
144 * each platform. This function is allowed to use
145 * registers x0 - x17.
146 * -----------------------------------------------------
147 */
148func plat_disable_acp
149 ret
Kévin Petita877c252015-03-24 14:03:57 +0000150endfunc plat_disable_acp
Juan Castillod1413b22015-10-05 16:59:38 +0100151
152 /* -----------------------------------------------------
Sandrine Bailleux87322b32015-11-10 15:01:57 +0000153 * void bl1_plat_prepare_exit(entry_point_info_t *ep_info);
Juan Castillod1413b22015-10-05 16:59:38 +0100154 * Called before exiting BL1. Default: do nothing
155 * -----------------------------------------------------
156 */
157func bl1_plat_prepare_exit
158 ret
159endfunc bl1_plat_prepare_exit
Juan Castillo26ae5832015-09-25 15:41:14 +0100160
161 /* -----------------------------------------------------
162 * void plat_error_handler(int err) __dead2;
163 * Endless loop by default.
164 * -----------------------------------------------------
165 */
166func plat_error_handler
Sandrine Bailleux628198b2016-08-18 09:24:40 +0100167 wfi
Juan Castillo26ae5832015-09-25 15:41:14 +0100168 b plat_error_handler
169endfunc plat_error_handler
Antonio Nino Diaz1f21bcf2016-02-01 13:57:25 +0000170
171 /* -----------------------------------------------------
172 * void plat_panic_handler(void) __dead2;
173 * Endless loop by default.
174 * -----------------------------------------------------
175 */
176func plat_panic_handler
Sandrine Bailleux628198b2016-08-18 09:24:40 +0100177 wfi
Antonio Nino Diaz1f21bcf2016-02-01 13:57:25 +0000178 b plat_panic_handler
179endfunc plat_panic_handler
Roberto Vargasbc1ae1f2017-09-26 12:53:01 +0100180
181 /* -----------------------------------------------------
182 * Placeholder function which should be redefined by
183 * each platfrom.
184 * -----------------------------------------------------
185 */
186func bl2_plat_preload_setup
187 ret
188endfunc bl2_plat_preload_setup
189
190 /* -----------------------------------------------------
191 * Placeholder function which should be redefined by
192 * each platfrom.
193 * -----------------------------------------------------
194 */
195func plat_try_next_boot_source
196 mov x0, #0
197 ret
198endfunc plat_try_next_boot_source