blob: f8d3129523cf1ed5abf8e3f93d20c8392618c4c2 [file] [log] [blame]
Dan Handleydff8e472014-05-16 14:08:45 +01001/*
Soby Mathewa6f340f2018-01-09 14:36:14 +00002 * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
Dan Handleydff8e472014-05-16 14:08:45 +01003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Dan Handleydff8e472014-05-16 14:08:45 +01005 */
Jeenu Viswambharanb7cb1332017-10-16 08:43:14 +01006
Soby Mathew5c8babc2015-07-13 16:26:11 +01007#include <assert.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +00008
9#include <arch_helpers.h>
10#include <drivers/console.h>
Jeenu Viswambharan362599e2017-12-08 15:38:21 +000011#if RAS_EXTENSION
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000012#include <lib/extensions/ras.h>
Jeenu Viswambharan362599e2017-12-08 15:38:21 +000013#endif
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000014#include <lib/xlat_tables/xlat_mmu_helpers.h>
15#include <plat/common/platform.h>
Dan Handleydff8e472014-05-16 14:08:45 +010016
17/*
Soby Mathew78e61612015-12-09 11:28:43 +000018 * The following platform setup functions are weakly defined. They
Dan Handleydff8e472014-05-16 14:08:45 +010019 * provide typical implementations that may be re-used by multiple
20 * platforms but may also be overridden by a platform if required.
21 */
Soby Mathew78e61612015-12-09 11:28:43 +000022#pragma weak bl31_plat_runtime_setup
Dan Handleydff8e472014-05-16 14:08:45 +010023
Jeenu Viswambharanb7cb1332017-10-16 08:43:14 +010024#if SDEI_SUPPORT
25#pragma weak plat_sdei_handle_masked_trigger
26#pragma weak plat_sdei_validate_entry_point
27#endif
28
Jeenu Viswambharan76454ab2017-11-30 12:54:15 +000029#pragma weak plat_ea_handler
30
Soby Mathew78e61612015-12-09 11:28:43 +000031void bl31_plat_runtime_setup(void)
32{
Julius Werner9536bae2017-07-31 18:15:11 -070033 console_switch_state(CONSOLE_FLAG_RUNTIME);
Soby Mathew78e61612015-12-09 11:28:43 +000034}
35
Soby Mathew5c8babc2015-07-13 16:26:11 +010036/*
37 * Helper function for platform_get_pos() when platform compatibility is
38 * disabled. This is to enable SPDs using the older platform API to continue
39 * to work.
40 */
41unsigned int platform_core_pos_helper(unsigned long mpidr)
42{
43 int idx = plat_core_pos_by_mpidr(mpidr);
44 assert(idx >= 0);
45 return idx;
46}
Antonio Nino Diazd4486392016-05-18 16:53:31 +010047
Jeenu Viswambharanb7cb1332017-10-16 08:43:14 +010048#if SDEI_SUPPORT
49/*
50 * Function that handles spurious SDEI interrupts while events are masked.
51 */
52void plat_sdei_handle_masked_trigger(uint64_t mpidr, unsigned int intr)
53{
Masahiro Yamada0a2d5b42018-02-02 15:09:36 +090054 WARN("Spurious SDEI interrupt %u on masked PE %llx\n", intr, mpidr);
Jeenu Viswambharanb7cb1332017-10-16 08:43:14 +010055}
56
57/*
58 * Default Function to validate SDEI entry point, which returns success.
59 * Platforms may override this with their own validation mechanism.
60 */
61int plat_sdei_validate_entry_point(uintptr_t ep, unsigned int client_mode)
62{
63 return 0;
64}
65#endif
Jeenu Viswambharan76454ab2017-11-30 12:54:15 +000066
67/* RAS functions common to AArch64 ARM platforms */
68void plat_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *cookie,
69 void *handle, uint64_t flags)
70{
Jeenu Viswambharan362599e2017-12-08 15:38:21 +000071#if RAS_EXTENSION
72 /* Call RAS EA handler */
73 int handled = ras_ea_handler(ea_reason, syndrome, cookie, handle, flags);
74 if (handled != 0)
75 return;
76#endif
77
Jeenu Viswambharan76454ab2017-11-30 12:54:15 +000078 ERROR("Unhandled External Abort received on 0x%lx at EL3!\n",
79 read_mpidr_el1());
Jeenu Viswambharane1040aa2018-05-15 16:18:40 +010080 ERROR(" exception reason=%u syndrome=0x%llx\n", ea_reason, syndrome);
Jeenu Viswambharan76454ab2017-11-30 12:54:15 +000081 panic();
82}