1 /* 2 * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <arch_helpers.h> 8 #include <assert.h> 9 #include <console.h> 10 #include <platform.h> 11 #if RAS_EXTENSION 12 #include <ras.h> 13 #endif 14 #include <xlat_mmu_helpers.h> 15 16 /* 17 * The following platform setup functions are weakly defined. They 18 * provide typical implementations that may be re-used by multiple 19 * platforms but may also be overridden by a platform if required. 20 */ 21 #pragma weak bl31_plat_runtime_setup 22 #if !ERROR_DEPRECATED 23 #pragma weak plat_get_syscnt_freq2 24 #endif /* ERROR_DEPRECATED */ 25 26 #if SDEI_SUPPORT 27 #pragma weak plat_sdei_handle_masked_trigger 28 #pragma weak plat_sdei_validate_entry_point 29 #endif 30 31 #pragma weak plat_ea_handler 32 33 void bl31_plat_runtime_setup(void) 34 { 35 #if MULTI_CONSOLE_API 36 console_switch_state(CONSOLE_FLAG_RUNTIME); 37 #else 38 console_uninit(); 39 #endif 40 } 41 42 /* 43 * Helper function for platform_get_pos() when platform compatibility is 44 * disabled. This is to enable SPDs using the older platform API to continue 45 * to work. 46 */ 47 unsigned int platform_core_pos_helper(unsigned long mpidr) 48 { 49 int idx = plat_core_pos_by_mpidr(mpidr); 50 assert(idx >= 0); 51 return idx; 52 } 53 54 #if !ERROR_DEPRECATED 55 unsigned int plat_get_syscnt_freq2(void) 56 { 57 WARN("plat_get_syscnt_freq() is deprecated\n"); 58 WARN("Please define plat_get_syscnt_freq2()\n"); 59 /* 60 * Suppress deprecated declaration warning in compatibility function 61 */ 62 #pragma GCC diagnostic push 63 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 64 unsigned long long freq = plat_get_syscnt_freq(); 65 #pragma GCC diagnostic pop 66 67 assert(freq >> 32 == 0); 68 69 return (unsigned int)freq; 70 } 71 #endif /* ERROR_DEPRECATED */ 72 73 #if SDEI_SUPPORT 74 /* 75 * Function that handles spurious SDEI interrupts while events are masked. 76 */ 77 void plat_sdei_handle_masked_trigger(uint64_t mpidr, unsigned int intr) 78 { 79 WARN("Spurious SDEI interrupt %u on masked PE %llx\n", intr, mpidr); 80 } 81 82 /* 83 * Default Function to validate SDEI entry point, which returns success. 84 * Platforms may override this with their own validation mechanism. 85 */ 86 int plat_sdei_validate_entry_point(uintptr_t ep, unsigned int client_mode) 87 { 88 return 0; 89 } 90 #endif 91 92 /* RAS functions common to AArch64 ARM platforms */ 93 void plat_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *cookie, 94 void *handle, uint64_t flags) 95 { 96 #if RAS_EXTENSION 97 /* Call RAS EA handler */ 98 int handled = ras_ea_handler(ea_reason, syndrome, cookie, handle, flags); 99 if (handled != 0) 100 return; 101 #endif 102 103 ERROR("Unhandled External Abort received on 0x%lx at EL3!\n", 104 read_mpidr_el1()); 105 ERROR(" exception reason=%u syndrome=0x%llx\n", ea_reason, syndrome); 106 panic(); 107 } 108