Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Masahiro Yamada | 2a4fe4f | 2018-02-01 18:42:24 +0900 | [diff] [blame] | 2 | * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
Andrew Thoelke | 38bde41 | 2014-03-18 13:46:55 +0000 | [diff] [blame] | 8 | #include <asm_macros.S> |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 9 | #include <console.h> |
Dan Handley | ed6ff95 | 2014-05-14 17:44:19 +0100 | [diff] [blame] | 10 | #include <platform_def.h> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 11 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 12 | .weak plat_report_exception |
Antonio Nino Diaz | 6b0968e | 2018-10-17 16:49:26 +0100 | [diff] [blame] | 13 | #if !ERROR_DEPRECATED |
Soby Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 14 | .weak plat_crash_console_init |
| 15 | .weak plat_crash_console_putc |
Antonio Nino Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 16 | .weak plat_crash_console_flush |
Antonio Nino Diaz | 6b0968e | 2018-10-17 16:49:26 +0100 | [diff] [blame] | 17 | #endif |
Soby Mathew | f1785fd | 2014-08-14 12:22:32 +0100 | [diff] [blame] | 18 | .weak plat_reset_handler |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 19 | .weak plat_disable_acp |
Juan Castillo | d1413b2 | 2015-10-05 16:59:38 +0100 | [diff] [blame] | 20 | .weak bl1_plat_prepare_exit |
Antonio Nino Diaz | 1f21bcf | 2016-02-01 13:57:25 +0000 | [diff] [blame] | 21 | .weak plat_panic_handler |
Jeenu Viswambharan | e834ee1 | 2018-04-27 15:17:03 +0100 | [diff] [blame] | 22 | .weak bl31_plat_enable_mmu |
| 23 | .weak bl32_plat_enable_mmu |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 24 | |
Jeenu Viswambharan | 9d4c9c1 | 2018-05-17 09:52:36 +0100 | [diff] [blame] | 25 | .weak plat_handle_uncontainable_ea |
Jeenu Viswambharan | 93bc4bd | 2018-05-17 11:24:01 +0100 | [diff] [blame] | 26 | .weak plat_handle_double_fault |
Jeenu Viswambharan | 911fcc9 | 2018-07-06 16:50:06 +0100 | [diff] [blame] | 27 | .weak plat_handle_el3_ea |
Jeenu Viswambharan | 9d4c9c1 | 2018-05-17 09:52:36 +0100 | [diff] [blame] | 28 | |
Soby Mathew | 70716d6 | 2015-07-13 16:26:11 +0100 | [diff] [blame] | 29 | .globl platform_get_core_pos |
| 30 | |
| 31 | #define MPIDR_RES_BIT_MASK 0xff000000 |
| 32 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 33 | /* ----------------------------------------------------- |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 34 | * Placeholder function which should be redefined by |
| 35 | * each platform. |
| 36 | * ----------------------------------------------------- |
| 37 | */ |
Andrew Thoelke | 38bde41 | 2014-03-18 13:46:55 +0000 | [diff] [blame] | 38 | func plat_report_exception |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 39 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 40 | endfunc plat_report_exception |
Soby Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 41 | |
Antonio Nino Diaz | 6b0968e | 2018-10-17 16:49:26 +0100 | [diff] [blame] | 42 | #if !ERROR_DEPRECATED |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 43 | #if MULTI_CONSOLE_API |
Soby Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 44 | /* ----------------------------------------------------- |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 45 | * 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 Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 56 | * ----------------------------------------------------- |
| 57 | */ |
| 58 | func plat_crash_console_init |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 59 | #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 Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 66 | mov x0, #0 |
| 67 | ret |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 68 | #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 Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 75 | endfunc plat_crash_console_init |
Soby Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 76 | |
| 77 | /* ----------------------------------------------------- |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 78 | * void plat_crash_console_putc(int character) |
| 79 | * Output through the normal console by default. |
Soby Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 80 | * ----------------------------------------------------- |
| 81 | */ |
| 82 | func plat_crash_console_putc |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 83 | b console_putc |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 84 | endfunc plat_crash_console_putc |
Soby Mathew | f1785fd | 2014-08-14 12:22:32 +0100 | [diff] [blame] | 85 | |
| 86 | /* ----------------------------------------------------- |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 87 | * void plat_crash_console_flush(void) |
| 88 | * Flush normal console by default. |
| 89 | * ----------------------------------------------------- |
| 90 | */ |
| 91 | func plat_crash_console_flush |
| 92 | b console_flush |
| 93 | endfunc 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 Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 100 | * ----------------------------------------------------- |
| 101 | */ |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 102 | func plat_crash_console_init |
| 103 | mov x0, #0 |
| 104 | ret |
| 105 | endfunc plat_crash_console_init |
| 106 | |
| 107 | func plat_crash_console_putc |
| 108 | ret |
| 109 | endfunc plat_crash_console_putc |
| 110 | |
Antonio Nino Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 111 | func plat_crash_console_flush |
| 112 | ret |
| 113 | endfunc plat_crash_console_flush |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 114 | #endif |
Antonio Nino Diaz | 6b0968e | 2018-10-17 16:49:26 +0100 | [diff] [blame] | 115 | #endif /* ERROR_DEPRECATED */ |
Antonio Nino Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 116 | |
| 117 | /* ----------------------------------------------------- |
| 118 | * Placeholder function which should be redefined by |
Masahiro Yamada | 4c165ca | 2016-09-24 18:07:46 +0900 | [diff] [blame] | 119 | * each platform. This function should preserve x19 - x29. |
Soby Mathew | f1785fd | 2014-08-14 12:22:32 +0100 | [diff] [blame] | 120 | * ----------------------------------------------------- |
| 121 | */ |
| 122 | func plat_reset_handler |
| 123 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 124 | endfunc plat_reset_handler |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 125 | |
| 126 | /* ----------------------------------------------------- |
| 127 | * Placeholder function which should be redefined by |
| 128 | * each platform. This function is allowed to use |
| 129 | * registers x0 - x17. |
| 130 | * ----------------------------------------------------- |
| 131 | */ |
| 132 | func plat_disable_acp |
| 133 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 134 | endfunc plat_disable_acp |
Juan Castillo | d1413b2 | 2015-10-05 16:59:38 +0100 | [diff] [blame] | 135 | |
| 136 | /* ----------------------------------------------------- |
Sandrine Bailleux | 87322b3 | 2015-11-10 15:01:57 +0000 | [diff] [blame] | 137 | * void bl1_plat_prepare_exit(entry_point_info_t *ep_info); |
Juan Castillo | d1413b2 | 2015-10-05 16:59:38 +0100 | [diff] [blame] | 138 | * Called before exiting BL1. Default: do nothing |
| 139 | * ----------------------------------------------------- |
| 140 | */ |
| 141 | func bl1_plat_prepare_exit |
| 142 | ret |
| 143 | endfunc bl1_plat_prepare_exit |
Juan Castillo | 26ae583 | 2015-09-25 15:41:14 +0100 | [diff] [blame] | 144 | |
| 145 | /* ----------------------------------------------------- |
Antonio Nino Diaz | 1f21bcf | 2016-02-01 13:57:25 +0000 | [diff] [blame] | 146 | * void plat_panic_handler(void) __dead2; |
| 147 | * Endless loop by default. |
| 148 | * ----------------------------------------------------- |
| 149 | */ |
| 150 | func plat_panic_handler |
Sandrine Bailleux | 628198b | 2016-08-18 09:24:40 +0100 | [diff] [blame] | 151 | wfi |
Antonio Nino Diaz | 1f21bcf | 2016-02-01 13:57:25 +0000 | [diff] [blame] | 152 | b plat_panic_handler |
| 153 | endfunc plat_panic_handler |
Jeenu Viswambharan | e834ee1 | 2018-04-27 15:17:03 +0100 | [diff] [blame] | 154 | |
| 155 | /* ----------------------------------------------------- |
| 156 | * void bl31_plat_enable_mmu(uint32_t flags); |
| 157 | * |
| 158 | * Enable MMU in BL31. |
| 159 | * ----------------------------------------------------- |
| 160 | */ |
| 161 | func bl31_plat_enable_mmu |
| 162 | b enable_mmu_direct_el3 |
| 163 | endfunc bl31_plat_enable_mmu |
| 164 | |
| 165 | /* ----------------------------------------------------- |
| 166 | * void bl32_plat_enable_mmu(uint32_t flags); |
| 167 | * |
| 168 | * Enable MMU in BL32. |
| 169 | * ----------------------------------------------------- |
| 170 | */ |
| 171 | func bl32_plat_enable_mmu |
| 172 | b enable_mmu_direct_el1 |
| 173 | endfunc bl32_plat_enable_mmu |
Jeenu Viswambharan | 9d4c9c1 | 2018-05-17 09:52:36 +0100 | [diff] [blame] | 174 | |
| 175 | |
| 176 | /* ----------------------------------------------------- |
| 177 | * Platform handler for Uncontainable External Abort. |
| 178 | * |
| 179 | * x0: EA reason |
| 180 | * x1: EA syndrome |
| 181 | * ----------------------------------------------------- |
| 182 | */ |
| 183 | func plat_handle_uncontainable_ea |
| 184 | b report_unhandled_exception |
| 185 | endfunc plat_handle_uncontainable_ea |
Jeenu Viswambharan | 93bc4bd | 2018-05-17 11:24:01 +0100 | [diff] [blame] | 186 | |
| 187 | /* ----------------------------------------------------- |
| 188 | * Platform handler for Double Fault. |
| 189 | * |
| 190 | * x0: EA reason |
| 191 | * x1: EA syndrome |
| 192 | * ----------------------------------------------------- |
| 193 | */ |
| 194 | func plat_handle_double_fault |
| 195 | b report_unhandled_exception |
| 196 | endfunc plat_handle_double_fault |
Jeenu Viswambharan | 911fcc9 | 2018-07-06 16:50:06 +0100 | [diff] [blame] | 197 | |
| 198 | /* ----------------------------------------------------- |
| 199 | * Platform handler for EL3 External Abort. |
| 200 | * ----------------------------------------------------- |
| 201 | */ |
| 202 | func plat_handle_el3_ea |
| 203 | b report_unhandled_exception |
| 204 | endfunc plat_handle_el3_ea |