aa65f4f338f9b2cb2b47725e1a1a463dc63cd085
[project/bcm63xx/atf.git] / plat / arm / common / arm_err.c
1 /*
2 * Copyright (c) 2015-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 <console.h>
9 #include <debug.h>
10 #include <errno.h>
11 #include <plat_arm.h>
12 #include <platform.h>
13 #include <platform_def.h>
14 #include <stdint.h>
15 #include <v2m_flash.h>
16
17 #pragma weak plat_arm_error_handler
18
19 /*
20 * ARM common implementation for error handler
21 */
22 void __dead2 plat_arm_error_handler(int err)
23 {
24 int ret;
25
26 switch (err) {
27 case -ENOENT:
28 case -EAUTH:
29 /* Image load or authentication error. Erase the ToC */
30 INFO("Erasing FIP ToC from flash...\n");
31 (void)nor_unlock(PLAT_ARM_FIP_BASE);
32 ret = nor_word_program(PLAT_ARM_FIP_BASE, 0);
33 if (ret != 0) {
34 ERROR("Cannot erase ToC\n");
35 } else {
36 INFO("Done\n");
37 }
38 break;
39 default:
40 /* Unexpected error */
41 break;
42 }
43
44 (void)console_flush();
45
46 /* Loop until the watchdog resets the system */
47 for (;;)
48 wfi();
49 }
50
51 void __dead2 plat_error_handler(int err)
52 {
53 plat_arm_error_handler(err);
54 }