Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 2 | * Copyright (c) 2013-2017, 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 |
Soby Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 13 | .weak plat_crash_console_init |
| 14 | .weak plat_crash_console_putc |
Antonio Nino Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 15 | .weak plat_crash_console_flush |
Soby Mathew | f1785fd | 2014-08-14 12:22:32 +0100 | [diff] [blame] | 16 | .weak plat_reset_handler |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 17 | .weak plat_disable_acp |
Juan Castillo | d1413b2 | 2015-10-05 16:59:38 +0100 | [diff] [blame] | 18 | .weak bl1_plat_prepare_exit |
Juan Castillo | 26ae583 | 2015-09-25 15:41:14 +0100 | [diff] [blame] | 19 | .weak plat_error_handler |
Antonio Nino Diaz | 1f21bcf | 2016-02-01 13:57:25 +0000 | [diff] [blame] | 20 | .weak plat_panic_handler |
Roberto Vargas | bc1ae1f | 2017-09-26 12:53:01 +0100 | [diff] [blame] | 21 | .weak bl2_plat_preload_setup |
| 22 | .weak plat_try_next_boot_source |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 23 | |
Soby Mathew | 70716d6 | 2015-07-13 16:26:11 +0100 | [diff] [blame] | 24 | #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 | */ |
| 41 | func_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 |
| 48 | endfunc_deprecated platform_get_core_pos |
| 49 | #endif |
| 50 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 51 | /* ----------------------------------------------------- |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 52 | * Placeholder function which should be redefined by |
| 53 | * each platform. |
| 54 | * ----------------------------------------------------- |
| 55 | */ |
Andrew Thoelke | 38bde41 | 2014-03-18 13:46:55 +0000 | [diff] [blame] | 56 | func plat_report_exception |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 57 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 58 | endfunc plat_report_exception |
Soby Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 59 | |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 60 | #if MULTI_CONSOLE_API |
Soby Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 61 | /* ----------------------------------------------------- |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 62 | * 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 Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 73 | * ----------------------------------------------------- |
| 74 | */ |
| 75 | func plat_crash_console_init |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 76 | #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 Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 83 | mov x0, #0 |
| 84 | ret |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 85 | #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 Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 92 | endfunc plat_crash_console_init |
Soby Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 93 | |
| 94 | /* ----------------------------------------------------- |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 95 | * void plat_crash_console_putc(int character) |
| 96 | * Output through the normal console by default. |
Soby Mathew | 066f713 | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 97 | * ----------------------------------------------------- |
| 98 | */ |
| 99 | func plat_crash_console_putc |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 100 | b console_putc |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 101 | endfunc plat_crash_console_putc |
Soby Mathew | f1785fd | 2014-08-14 12:22:32 +0100 | [diff] [blame] | 102 | |
| 103 | /* ----------------------------------------------------- |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 104 | * void plat_crash_console_flush(void) |
| 105 | * Flush normal console by default. |
| 106 | * ----------------------------------------------------- |
| 107 | */ |
| 108 | func plat_crash_console_flush |
| 109 | b console_flush |
| 110 | endfunc 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 Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 117 | * ----------------------------------------------------- |
| 118 | */ |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 119 | func plat_crash_console_init |
| 120 | mov x0, #0 |
| 121 | ret |
| 122 | endfunc plat_crash_console_init |
| 123 | |
| 124 | func plat_crash_console_putc |
| 125 | ret |
| 126 | endfunc plat_crash_console_putc |
| 127 | |
Antonio Nino Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 128 | func plat_crash_console_flush |
| 129 | ret |
| 130 | endfunc plat_crash_console_flush |
Julius Werner | aae9bb1 | 2017-09-18 16:49:48 -0700 | [diff] [blame] | 131 | #endif |
Antonio Nino Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 132 | |
| 133 | /* ----------------------------------------------------- |
| 134 | * Placeholder function which should be redefined by |
Masahiro Yamada | 4c165ca | 2016-09-24 18:07:46 +0900 | [diff] [blame] | 135 | * each platform. This function should preserve x19 - x29. |
Soby Mathew | f1785fd | 2014-08-14 12:22:32 +0100 | [diff] [blame] | 136 | * ----------------------------------------------------- |
| 137 | */ |
| 138 | func plat_reset_handler |
| 139 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 140 | endfunc plat_reset_handler |
Soby Mathew | 8e2f287 | 2014-08-14 12:49:05 +0100 | [diff] [blame] | 141 | |
| 142 | /* ----------------------------------------------------- |
| 143 | * Placeholder function which should be redefined by |
| 144 | * each platform. This function is allowed to use |
| 145 | * registers x0 - x17. |
| 146 | * ----------------------------------------------------- |
| 147 | */ |
| 148 | func plat_disable_acp |
| 149 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 150 | endfunc plat_disable_acp |
Juan Castillo | d1413b2 | 2015-10-05 16:59:38 +0100 | [diff] [blame] | 151 | |
| 152 | /* ----------------------------------------------------- |
Sandrine Bailleux | 87322b3 | 2015-11-10 15:01:57 +0000 | [diff] [blame] | 153 | * void bl1_plat_prepare_exit(entry_point_info_t *ep_info); |
Juan Castillo | d1413b2 | 2015-10-05 16:59:38 +0100 | [diff] [blame] | 154 | * Called before exiting BL1. Default: do nothing |
| 155 | * ----------------------------------------------------- |
| 156 | */ |
| 157 | func bl1_plat_prepare_exit |
| 158 | ret |
| 159 | endfunc bl1_plat_prepare_exit |
Juan Castillo | 26ae583 | 2015-09-25 15:41:14 +0100 | [diff] [blame] | 160 | |
| 161 | /* ----------------------------------------------------- |
| 162 | * void plat_error_handler(int err) __dead2; |
| 163 | * Endless loop by default. |
| 164 | * ----------------------------------------------------- |
| 165 | */ |
| 166 | func plat_error_handler |
Sandrine Bailleux | 628198b | 2016-08-18 09:24:40 +0100 | [diff] [blame] | 167 | wfi |
Juan Castillo | 26ae583 | 2015-09-25 15:41:14 +0100 | [diff] [blame] | 168 | b plat_error_handler |
| 169 | endfunc plat_error_handler |
Antonio Nino Diaz | 1f21bcf | 2016-02-01 13:57:25 +0000 | [diff] [blame] | 170 | |
| 171 | /* ----------------------------------------------------- |
| 172 | * void plat_panic_handler(void) __dead2; |
| 173 | * Endless loop by default. |
| 174 | * ----------------------------------------------------- |
| 175 | */ |
| 176 | func plat_panic_handler |
Sandrine Bailleux | 628198b | 2016-08-18 09:24:40 +0100 | [diff] [blame] | 177 | wfi |
Antonio Nino Diaz | 1f21bcf | 2016-02-01 13:57:25 +0000 | [diff] [blame] | 178 | b plat_panic_handler |
| 179 | endfunc plat_panic_handler |
Roberto Vargas | bc1ae1f | 2017-09-26 12:53:01 +0100 | [diff] [blame] | 180 | |
| 181 | /* ----------------------------------------------------- |
| 182 | * Placeholder function which should be redefined by |
| 183 | * each platfrom. |
| 184 | * ----------------------------------------------------- |
| 185 | */ |
| 186 | func bl2_plat_preload_setup |
| 187 | ret |
| 188 | endfunc bl2_plat_preload_setup |
| 189 | |
| 190 | /* ----------------------------------------------------- |
| 191 | * Placeholder function which should be redefined by |
| 192 | * each platfrom. |
| 193 | * ----------------------------------------------------- |
| 194 | */ |
| 195 | func plat_try_next_boot_source |
| 196 | mov x0, #0 |
| 197 | ret |
| 198 | endfunc plat_try_next_boot_source |