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