1/* 2 * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7#include <arch.h> 8#include <asm_macros.S> 9#include <console.h> 10#include <platform_def.h> 11 12 .weak plat_report_exception 13 .weak plat_crash_console_init 14 .weak plat_crash_console_putc 15 .weak plat_crash_console_flush 16 .weak plat_reset_handler 17 .weak plat_disable_acp 18 .weak bl1_plat_prepare_exit 19 .weak plat_error_handler 20 .weak plat_panic_handler 21 .weak bl2_plat_preload_setup 22 .weak plat_try_next_boot_source 23 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 */ 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 51 /* ----------------------------------------------------- 52 * Placeholder function which should be redefined by 53 * each platform. 54 * ----------------------------------------------------- 55 */ 56func plat_report_exception 57 ret 58endfunc plat_report_exception 59 60#if MULTI_CONSOLE_API 61 /* ----------------------------------------------------- 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. 73 * ----------------------------------------------------- 74 */ 75func plat_crash_console_init 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 */ 83 mov x0, #0 84 ret 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 92endfunc plat_crash_console_init 93 94 /* ----------------------------------------------------- 95 * void plat_crash_console_putc(int character) 96 * Output through the normal console by default. 97 * ----------------------------------------------------- 98 */ 99func plat_crash_console_putc 100 b console_putc 101endfunc plat_crash_console_putc 102 103 /* ----------------------------------------------------- 104 * 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. 117 * ----------------------------------------------------- 118 */ 119func 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 128func plat_crash_console_flush 129 ret 130endfunc plat_crash_console_flush 131#endif 132 133 /* ----------------------------------------------------- 134 * Placeholder function which should be redefined by 135 * each platform. This function should preserve x19 - x29. 136 * ----------------------------------------------------- 137 */ 138func plat_reset_handler 139 ret 140endfunc plat_reset_handler 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 */ 148func plat_disable_acp 149 ret 150endfunc plat_disable_acp 151 152 /* ----------------------------------------------------- 153 * void bl1_plat_prepare_exit(entry_point_info_t *ep_info); 154 * Called before exiting BL1. Default: do nothing 155 * ----------------------------------------------------- 156 */ 157func bl1_plat_prepare_exit 158 ret 159endfunc bl1_plat_prepare_exit 160 161 /* ----------------------------------------------------- 162 * void plat_error_handler(int err) __dead2; 163 * Endless loop by default. 164 * ----------------------------------------------------- 165 */ 166func plat_error_handler 167 wfi 168 b plat_error_handler 169endfunc plat_error_handler 170 171 /* ----------------------------------------------------- 172 * void plat_panic_handler(void) __dead2; 173 * Endless loop by default. 174 * ----------------------------------------------------- 175 */ 176func plat_panic_handler 177 wfi 178 b plat_panic_handler 179endfunc plat_panic_handler 180 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 199