1*7b56928aSSoby Mathew /* 2*7b56928aSSoby Mathew * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. 3*7b56928aSSoby Mathew * 4*7b56928aSSoby Mathew * SPDX-License-Identifier: BSD-3-Clause 5*7b56928aSSoby Mathew */ 6*7b56928aSSoby Mathew 7*7b56928aSSoby Mathew #include <arch_helpers.h> 8*7b56928aSSoby Mathew #include <board_arm_def.h> 9*7b56928aSSoby Mathew #include <console.h> 10*7b56928aSSoby Mathew #include <debug.h> 11*7b56928aSSoby Mathew #include <errno.h> 12*7b56928aSSoby Mathew #include <norflash.h> 13*7b56928aSSoby Mathew #include <platform.h> 14*7b56928aSSoby Mathew #include <stdint.h> 15*7b56928aSSoby Mathew 16*7b56928aSSoby Mathew /* 17*7b56928aSSoby Mathew * ARM common implementation for error handler 18*7b56928aSSoby Mathew */ 19*7b56928aSSoby Mathew void plat_error_handler(int err) 20*7b56928aSSoby Mathew { 21*7b56928aSSoby Mathew int ret; 22*7b56928aSSoby Mathew 23*7b56928aSSoby Mathew switch (err) { 24*7b56928aSSoby Mathew case -ENOENT: 25*7b56928aSSoby Mathew case -EAUTH: 26*7b56928aSSoby Mathew /* Image load or authentication error. Erase the ToC */ 27*7b56928aSSoby Mathew INFO("Erasing FIP ToC from flash...\n"); 28*7b56928aSSoby Mathew nor_unlock(PLAT_ARM_FIP_BASE); 29*7b56928aSSoby Mathew ret = nor_word_program(PLAT_ARM_FIP_BASE, 0); 30*7b56928aSSoby Mathew if (ret != 0) { 31*7b56928aSSoby Mathew ERROR("Cannot erase ToC\n"); 32*7b56928aSSoby Mathew } else { 33*7b56928aSSoby Mathew INFO("Done\n"); 34*7b56928aSSoby Mathew } 35*7b56928aSSoby Mathew break; 36*7b56928aSSoby Mathew default: 37*7b56928aSSoby Mathew /* Unexpected error */ 38*7b56928aSSoby Mathew break; 39*7b56928aSSoby Mathew } 40*7b56928aSSoby Mathew 41*7b56928aSSoby Mathew (void)console_flush(); 42*7b56928aSSoby Mathew 43*7b56928aSSoby Mathew /* Loop until the watchdog resets the system */ 44*7b56928aSSoby Mathew for (;;) 45*7b56928aSSoby Mathew wfi(); 46*7b56928aSSoby Mathew } 47