blob: d3ffcaf1923d0e1ef8151aa71a7b0083b8c42994 [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
Antonio Nino Diaz6b0968e2018-10-17 16:49:26 +010013#if !ERROR_DEPRECATED
Soby Mathew066f7132014-07-14 16:57:23 +010014 .weak plat_crash_console_init
15 .weak plat_crash_console_putc
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +000016 .weak plat_crash_console_flush
Antonio Nino Diaz6b0968e2018-10-17 16:49:26 +010017#endif
Soby Mathewf1785fd2014-08-14 12:22:32 +010018 .weak plat_reset_handler
Soby Mathew8e2f2872014-08-14 12:49:05 +010019 .weak plat_disable_acp
Juan Castillod1413b22015-10-05 16:59:38 +010020 .weak bl1_plat_prepare_exit
Antonio Nino Diaz1f21bcf2016-02-01 13:57:25 +000021 .weak plat_panic_handler
Jeenu Viswambharane834ee12018-04-27 15:17:03 +010022 .weak bl31_plat_enable_mmu
23 .weak bl32_plat_enable_mmu
Achin Gupta4f6ad662013-10-25 09:08:21 +010024
Jeenu Viswambharan9d4c9c12018-05-17 09:52:36 +010025 .weak plat_handle_uncontainable_ea
Jeenu Viswambharan93bc4bd2018-05-17 11:24:01 +010026 .weak plat_handle_double_fault
Jeenu Viswambharan911fcc92018-07-06 16:50:06 +010027 .weak plat_handle_el3_ea
Jeenu Viswambharan9d4c9c12018-05-17 09:52:36 +010028
Soby Mathew70716d62015-07-13 16:26:11 +010029 .globl platform_get_core_pos
30
31#define MPIDR_RES_BIT_MASK 0xff000000
32
Achin Gupta4f6ad662013-10-25 09:08:21 +010033 /* -----------------------------------------------------
Achin Gupta4f6ad662013-10-25 09:08:21 +010034 * Placeholder function which should be redefined by
35 * each platform.
36 * -----------------------------------------------------
37 */
Andrew Thoelke38bde412014-03-18 13:46:55 +000038func plat_report_exception
Achin Gupta4f6ad662013-10-25 09:08:21 +010039 ret
Kévin Petita877c252015-03-24 14:03:57 +000040endfunc plat_report_exception
Soby Mathew066f7132014-07-14 16:57:23 +010041
Antonio Nino Diaz6b0968e2018-10-17 16:49:26 +010042#if !ERROR_DEPRECATED
Julius Werneraae9bb12017-09-18 16:49:48 -070043#if MULTI_CONSOLE_API
Soby Mathew066f7132014-07-14 16:57:23 +010044 /* -----------------------------------------------------
Julius Werneraae9bb12017-09-18 16:49:48 -070045 * int plat_crash_console_init(void)
46 * Use normal console by default. Switch it to crash
47 * mode so serial consoles become active again.
48 * NOTE: This default implementation will only work for
49 * crashes that occur after a normal console (marked
50 * valid for the crash state) has been registered with
51 * the console framework. To debug crashes that occur
52 * earlier, the platform has to override these functions
53 * with an implementation that initializes a console
54 * driver with hardcoded parameters. See
55 * docs/porting-guide.rst for more information.
Soby Mathew066f7132014-07-14 16:57:23 +010056 * -----------------------------------------------------
57 */
58func plat_crash_console_init
Julius Werneraae9bb12017-09-18 16:49:48 -070059#if defined(IMAGE_BL1)
60 /*
61 * BL1 code can possibly crash so early that the data segment is not yet
62 * accessible. Don't risk undefined behavior by trying to run the normal
63 * console framework. Platforms that want to debug BL1 will need to
64 * override this with custom functions that can run from registers only.
65 */
Soby Mathew066f7132014-07-14 16:57:23 +010066 mov x0, #0
67 ret
Julius Werneraae9bb12017-09-18 16:49:48 -070068#else /* IMAGE_BL1 */
69 mov x3, x30
70 mov x0, #CONSOLE_FLAG_CRASH
71 bl console_switch_state
72 mov x0, #1
73 ret x3
74#endif
Kévin Petita877c252015-03-24 14:03:57 +000075endfunc plat_crash_console_init
Soby Mathew066f7132014-07-14 16:57:23 +010076
77 /* -----------------------------------------------------
Julius Werneraae9bb12017-09-18 16:49:48 -070078 * void plat_crash_console_putc(int character)
79 * Output through the normal console by default.
Soby Mathew066f7132014-07-14 16:57:23 +010080 * -----------------------------------------------------
81 */
82func plat_crash_console_putc
Julius Werneraae9bb12017-09-18 16:49:48 -070083 b console_putc
Kévin Petita877c252015-03-24 14:03:57 +000084endfunc plat_crash_console_putc
Soby Mathewf1785fd2014-08-14 12:22:32 +010085
86 /* -----------------------------------------------------
Julius Werneraae9bb12017-09-18 16:49:48 -070087 * void plat_crash_console_flush(void)
88 * Flush normal console by default.
89 * -----------------------------------------------------
90 */
91func plat_crash_console_flush
92 b console_flush
93endfunc plat_crash_console_flush
94
95#else /* MULTI_CONSOLE_API */
96
97 /* -----------------------------------------------------
98 * In the old API these are all no-op stubs that need to
99 * be overridden by the platform to be useful.
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +0000100 * -----------------------------------------------------
101 */
Julius Werneraae9bb12017-09-18 16:49:48 -0700102func plat_crash_console_init
103 mov x0, #0
104 ret
105endfunc plat_crash_console_init
106
107func plat_crash_console_putc
108 ret
109endfunc plat_crash_console_putc
110
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +0000111func plat_crash_console_flush
112 ret
113endfunc plat_crash_console_flush
Julius Werneraae9bb12017-09-18 16:49:48 -0700114#endif
Antonio Nino Diaz6b0968e2018-10-17 16:49:26 +0100115#endif /* ERROR_DEPRECATED */
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +0000116
117 /* -----------------------------------------------------
118 * Placeholder function which should be redefined by
Masahiro Yamada4c165ca2016-09-24 18:07:46 +0900119 * each platform. This function should preserve x19 - x29.
Soby Mathewf1785fd2014-08-14 12:22:32 +0100120 * -----------------------------------------------------
121 */
122func plat_reset_handler
123 ret
Kévin Petita877c252015-03-24 14:03:57 +0000124endfunc plat_reset_handler
Soby Mathew8e2f2872014-08-14 12:49:05 +0100125
126 /* -----------------------------------------------------
127 * Placeholder function which should be redefined by
128 * each platform. This function is allowed to use
129 * registers x0 - x17.
130 * -----------------------------------------------------
131 */
132func plat_disable_acp
133 ret
Kévin Petita877c252015-03-24 14:03:57 +0000134endfunc plat_disable_acp
Juan Castillod1413b22015-10-05 16:59:38 +0100135
136 /* -----------------------------------------------------
Sandrine Bailleux87322b32015-11-10 15:01:57 +0000137 * void bl1_plat_prepare_exit(entry_point_info_t *ep_info);
Juan Castillod1413b22015-10-05 16:59:38 +0100138 * Called before exiting BL1. Default: do nothing
139 * -----------------------------------------------------
140 */
141func bl1_plat_prepare_exit
142 ret
143endfunc bl1_plat_prepare_exit
Juan Castillo26ae5832015-09-25 15:41:14 +0100144
145 /* -----------------------------------------------------
Antonio Nino Diaz1f21bcf2016-02-01 13:57:25 +0000146 * void plat_panic_handler(void) __dead2;
147 * Endless loop by default.
148 * -----------------------------------------------------
149 */
150func plat_panic_handler
Sandrine Bailleux628198b2016-08-18 09:24:40 +0100151 wfi
Antonio Nino Diaz1f21bcf2016-02-01 13:57:25 +0000152 b plat_panic_handler
153endfunc plat_panic_handler
Jeenu Viswambharane834ee12018-04-27 15:17:03 +0100154
155 /* -----------------------------------------------------
156 * void bl31_plat_enable_mmu(uint32_t flags);
157 *
158 * Enable MMU in BL31.
159 * -----------------------------------------------------
160 */
161func bl31_plat_enable_mmu
162 b enable_mmu_direct_el3
163endfunc bl31_plat_enable_mmu
164
165 /* -----------------------------------------------------
166 * void bl32_plat_enable_mmu(uint32_t flags);
167 *
168 * Enable MMU in BL32.
169 * -----------------------------------------------------
170 */
171func bl32_plat_enable_mmu
172 b enable_mmu_direct_el1
173endfunc bl32_plat_enable_mmu
Jeenu Viswambharan9d4c9c12018-05-17 09:52:36 +0100174
175
176 /* -----------------------------------------------------
177 * Platform handler for Uncontainable External Abort.
178 *
179 * x0: EA reason
180 * x1: EA syndrome
181 * -----------------------------------------------------
182 */
183func plat_handle_uncontainable_ea
184 b report_unhandled_exception
185endfunc plat_handle_uncontainable_ea
Jeenu Viswambharan93bc4bd2018-05-17 11:24:01 +0100186
187 /* -----------------------------------------------------
188 * Platform handler for Double Fault.
189 *
190 * x0: EA reason
191 * x1: EA syndrome
192 * -----------------------------------------------------
193 */
194func plat_handle_double_fault
195 b report_unhandled_exception
196endfunc plat_handle_double_fault
Jeenu Viswambharan911fcc92018-07-06 16:50:06 +0100197
198 /* -----------------------------------------------------
199 * Platform handler for EL3 External Abort.
200 * -----------------------------------------------------
201 */
202func plat_handle_el3_ea
203 b report_unhandled_exception
204endfunc plat_handle_el3_ea