17b56928aSSoby Mathew /* 27b56928aSSoby Mathew * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. 37b56928aSSoby Mathew * 47b56928aSSoby Mathew * SPDX-License-Identifier: BSD-3-Clause 57b56928aSSoby Mathew */ 67b56928aSSoby Mathew 77b56928aSSoby Mathew #include <arch_helpers.h> 87b56928aSSoby Mathew #include <console.h> 97b56928aSSoby Mathew #include <debug.h> 107b56928aSSoby Mathew #include <errno.h> 117b56928aSSoby Mathew #include <platform.h> 1246b69e3dSSughosh Ganu #include <platform_def.h> 137b56928aSSoby Mathew #include <stdint.h> 14*aa7877c4SAntonio Nino Diaz #include <v2m_flash.h> 157b56928aSSoby Mathew 164da6f6cdSSathees Balya #pragma weak plat_arm_error_handler 174da6f6cdSSathees Balya 187b56928aSSoby Mathew /* 197b56928aSSoby Mathew * ARM common implementation for error handler 207b56928aSSoby Mathew */ 214da6f6cdSSathees Balya void __dead2 plat_arm_error_handler(int err) 227b56928aSSoby Mathew { 237b56928aSSoby Mathew int ret; 247b56928aSSoby Mathew 257b56928aSSoby Mathew switch (err) { 267b56928aSSoby Mathew case -ENOENT: 277b56928aSSoby Mathew case -EAUTH: 287b56928aSSoby Mathew /* Image load or authentication error. Erase the ToC */ 297b56928aSSoby Mathew INFO("Erasing FIP ToC from flash...\n"); 307b56928aSSoby Mathew nor_unlock(PLAT_ARM_FIP_BASE); 317b56928aSSoby Mathew ret = nor_word_program(PLAT_ARM_FIP_BASE, 0); 327b56928aSSoby Mathew if (ret != 0) { 337b56928aSSoby Mathew ERROR("Cannot erase ToC\n"); 347b56928aSSoby Mathew } else { 357b56928aSSoby Mathew INFO("Done\n"); 367b56928aSSoby Mathew } 377b56928aSSoby Mathew break; 387b56928aSSoby Mathew default: 397b56928aSSoby Mathew /* Unexpected error */ 407b56928aSSoby Mathew break; 417b56928aSSoby Mathew } 427b56928aSSoby Mathew 437b56928aSSoby Mathew (void)console_flush(); 447b56928aSSoby Mathew 457b56928aSSoby Mathew /* Loop until the watchdog resets the system */ 467b56928aSSoby Mathew for (;;) 477b56928aSSoby Mathew wfi(); 487b56928aSSoby Mathew } 494da6f6cdSSathees Balya 504da6f6cdSSathees Balya void __dead2 plat_error_handler(int err) 514da6f6cdSSathees Balya { 524da6f6cdSSathees Balya plat_arm_error_handler(err); 534da6f6cdSSathees Balya } 54