blob: 7214588a6dbd2ebc4799c661f24cc77ba6c24ba9 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Masahiro Yamada2a4fe4f2018-02-01 18:42:24 +09002 * Copyright (c) 2013-2018, 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
Antonio Nino Diaz1f21bcf2016-02-01 13:57:25 +000019 .weak plat_panic_handler
Jeenu Viswambharane834ee12018-04-27 15:17:03 +010020 .weak bl31_plat_enable_mmu
21 .weak bl32_plat_enable_mmu
Achin Gupta4f6ad662013-10-25 09:08:21 +010022
Jeenu Viswambharan9d4c9c12018-05-17 09:52:36 +010023 .weak plat_handle_uncontainable_ea
Jeenu Viswambharan93bc4bd2018-05-17 11:24:01 +010024 .weak plat_handle_double_fault
Jeenu Viswambharan911fcc92018-07-06 16:50:06 +010025 .weak plat_handle_el3_ea
Jeenu Viswambharan9d4c9c12018-05-17 09:52:36 +010026
Soby Mathew70716d62015-07-13 16:26:11 +010027 .globl platform_get_core_pos
28
29#define MPIDR_RES_BIT_MASK 0xff000000
30
Achin Gupta4f6ad662013-10-25 09:08:21 +010031 /* -----------------------------------------------------
Achin Gupta4f6ad662013-10-25 09:08:21 +010032 * Placeholder function which should be redefined by
33 * each platform.
34 * -----------------------------------------------------
35 */
Andrew Thoelke38bde412014-03-18 13:46:55 +000036func plat_report_exception
Achin Gupta4f6ad662013-10-25 09:08:21 +010037 ret
Kévin Petita877c252015-03-24 14:03:57 +000038endfunc plat_report_exception
Soby Mathew066f7132014-07-14 16:57:23 +010039
Julius Werneraae9bb12017-09-18 16:49:48 -070040#if MULTI_CONSOLE_API
Soby Mathew066f7132014-07-14 16:57:23 +010041 /* -----------------------------------------------------
Julius Werneraae9bb12017-09-18 16:49:48 -070042 * int plat_crash_console_init(void)
43 * Use normal console by default. Switch it to crash
44 * mode so serial consoles become active again.
45 * NOTE: This default implementation will only work for
46 * crashes that occur after a normal console (marked
47 * valid for the crash state) has been registered with
48 * the console framework. To debug crashes that occur
49 * earlier, the platform has to override these functions
50 * with an implementation that initializes a console
51 * driver with hardcoded parameters. See
52 * docs/porting-guide.rst for more information.
Soby Mathew066f7132014-07-14 16:57:23 +010053 * -----------------------------------------------------
54 */
55func plat_crash_console_init
Julius Werneraae9bb12017-09-18 16:49:48 -070056#if defined(IMAGE_BL1)
57 /*
58 * BL1 code can possibly crash so early that the data segment is not yet
59 * accessible. Don't risk undefined behavior by trying to run the normal
60 * console framework. Platforms that want to debug BL1 will need to
61 * override this with custom functions that can run from registers only.
62 */
Soby Mathew066f7132014-07-14 16:57:23 +010063 mov x0, #0
64 ret
Julius Werneraae9bb12017-09-18 16:49:48 -070065#else /* IMAGE_BL1 */
66 mov x3, x30
67 mov x0, #CONSOLE_FLAG_CRASH
68 bl console_switch_state
69 mov x0, #1
70 ret x3
71#endif
Kévin Petita877c252015-03-24 14:03:57 +000072endfunc plat_crash_console_init
Soby Mathew066f7132014-07-14 16:57:23 +010073
74 /* -----------------------------------------------------
Julius Werneraae9bb12017-09-18 16:49:48 -070075 * void plat_crash_console_putc(int character)
76 * Output through the normal console by default.
Soby Mathew066f7132014-07-14 16:57:23 +010077 * -----------------------------------------------------
78 */
79func plat_crash_console_putc
Julius Werneraae9bb12017-09-18 16:49:48 -070080 b console_putc
Kévin Petita877c252015-03-24 14:03:57 +000081endfunc plat_crash_console_putc
Soby Mathewf1785fd2014-08-14 12:22:32 +010082
83 /* -----------------------------------------------------
Julius Werneraae9bb12017-09-18 16:49:48 -070084 * void plat_crash_console_flush(void)
85 * Flush normal console by default.
86 * -----------------------------------------------------
87 */
88func plat_crash_console_flush
89 b console_flush
90endfunc plat_crash_console_flush
91
92#else /* MULTI_CONSOLE_API */
93
94 /* -----------------------------------------------------
95 * In the old API these are all no-op stubs that need to
96 * be overridden by the platform to be useful.
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +000097 * -----------------------------------------------------
98 */
Julius Werneraae9bb12017-09-18 16:49:48 -070099func plat_crash_console_init
100 mov x0, #0
101 ret
102endfunc plat_crash_console_init
103
104func plat_crash_console_putc
105 ret
106endfunc plat_crash_console_putc
107
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +0000108func plat_crash_console_flush
109 ret
110endfunc plat_crash_console_flush
Julius Werneraae9bb12017-09-18 16:49:48 -0700111#endif
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +0000112
113 /* -----------------------------------------------------
114 * Placeholder function which should be redefined by
Masahiro Yamada4c165ca2016-09-24 18:07:46 +0900115 * each platform. This function should preserve x19 - x29.
Soby Mathewf1785fd2014-08-14 12:22:32 +0100116 * -----------------------------------------------------
117 */
118func plat_reset_handler
119 ret
Kévin Petita877c252015-03-24 14:03:57 +0000120endfunc plat_reset_handler
Soby Mathew8e2f2872014-08-14 12:49:05 +0100121
122 /* -----------------------------------------------------
123 * Placeholder function which should be redefined by
124 * each platform. This function is allowed to use
125 * registers x0 - x17.
126 * -----------------------------------------------------
127 */
128func plat_disable_acp
129 ret
Kévin Petita877c252015-03-24 14:03:57 +0000130endfunc plat_disable_acp
Juan Castillod1413b22015-10-05 16:59:38 +0100131
132 /* -----------------------------------------------------
Sandrine Bailleux87322b32015-11-10 15:01:57 +0000133 * void bl1_plat_prepare_exit(entry_point_info_t *ep_info);
Juan Castillod1413b22015-10-05 16:59:38 +0100134 * Called before exiting BL1. Default: do nothing
135 * -----------------------------------------------------
136 */
137func bl1_plat_prepare_exit
138 ret
139endfunc bl1_plat_prepare_exit
Juan Castillo26ae5832015-09-25 15:41:14 +0100140
141 /* -----------------------------------------------------
Antonio Nino Diaz1f21bcf2016-02-01 13:57:25 +0000142 * void plat_panic_handler(void) __dead2;
143 * Endless loop by default.
144 * -----------------------------------------------------
145 */
146func plat_panic_handler
Sandrine Bailleux628198b2016-08-18 09:24:40 +0100147 wfi
Antonio Nino Diaz1f21bcf2016-02-01 13:57:25 +0000148 b plat_panic_handler
149endfunc plat_panic_handler
Jeenu Viswambharane834ee12018-04-27 15:17:03 +0100150
151 /* -----------------------------------------------------
152 * void bl31_plat_enable_mmu(uint32_t flags);
153 *
154 * Enable MMU in BL31.
155 * -----------------------------------------------------
156 */
157func bl31_plat_enable_mmu
158 b enable_mmu_direct_el3
159endfunc bl31_plat_enable_mmu
160
161 /* -----------------------------------------------------
162 * void bl32_plat_enable_mmu(uint32_t flags);
163 *
164 * Enable MMU in BL32.
165 * -----------------------------------------------------
166 */
167func bl32_plat_enable_mmu
168 b enable_mmu_direct_el1
169endfunc bl32_plat_enable_mmu
Jeenu Viswambharan9d4c9c12018-05-17 09:52:36 +0100170
171
172 /* -----------------------------------------------------
173 * Platform handler for Uncontainable External Abort.
174 *
175 * x0: EA reason
176 * x1: EA syndrome
177 * -----------------------------------------------------
178 */
179func plat_handle_uncontainable_ea
180 b report_unhandled_exception
181endfunc plat_handle_uncontainable_ea
Jeenu Viswambharan93bc4bd2018-05-17 11:24:01 +0100182
183 /* -----------------------------------------------------
184 * Platform handler for Double Fault.
185 *
186 * x0: EA reason
187 * x1: EA syndrome
188 * -----------------------------------------------------
189 */
190func plat_handle_double_fault
191 b report_unhandled_exception
192endfunc plat_handle_double_fault
Jeenu Viswambharan911fcc92018-07-06 16:50:06 +0100193
194 /* -----------------------------------------------------
195 * Platform handler for EL3 External Abort.
196 * -----------------------------------------------------
197 */
198func plat_handle_el3_ea
199 b report_unhandled_exception
200endfunc plat_handle_el3_ea