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> 11*583e0791SAntonio Nino Diaz #include <plat_arm.h> 127b56928aSSoby Mathew #include <platform.h> 1346b69e3dSSughosh Ganu #include <platform_def.h> 147b56928aSSoby Mathew #include <stdint.h> 15aa7877c4SAntonio Nino Diaz #include <v2m_flash.h> 167b56928aSSoby Mathew 174da6f6cdSSathees Balya #pragma weak plat_arm_error_handler 184da6f6cdSSathees Balya 197b56928aSSoby Mathew /* 207b56928aSSoby Mathew * ARM common implementation for error handler 217b56928aSSoby Mathew */ 224da6f6cdSSathees Balya void __dead2 plat_arm_error_handler(int err) 237b56928aSSoby Mathew { 247b56928aSSoby Mathew int ret; 257b56928aSSoby Mathew 267b56928aSSoby Mathew switch (err) { 277b56928aSSoby Mathew case -ENOENT: 287b56928aSSoby Mathew case -EAUTH: 297b56928aSSoby Mathew /* Image load or authentication error. Erase the ToC */ 307b56928aSSoby Mathew INFO("Erasing FIP ToC from flash...\n"); 31*583e0791SAntonio Nino Diaz (void)nor_unlock(PLAT_ARM_FIP_BASE); 327b56928aSSoby Mathew ret = nor_word_program(PLAT_ARM_FIP_BASE, 0); 337b56928aSSoby Mathew if (ret != 0) { 347b56928aSSoby Mathew ERROR("Cannot erase ToC\n"); 357b56928aSSoby Mathew } else { 367b56928aSSoby Mathew INFO("Done\n"); 377b56928aSSoby Mathew } 387b56928aSSoby Mathew break; 397b56928aSSoby Mathew default: 407b56928aSSoby Mathew /* Unexpected error */ 417b56928aSSoby Mathew break; 427b56928aSSoby Mathew } 437b56928aSSoby Mathew 447b56928aSSoby Mathew (void)console_flush(); 457b56928aSSoby Mathew 467b56928aSSoby Mathew /* Loop until the watchdog resets the system */ 477b56928aSSoby Mathew for (;;) 487b56928aSSoby Mathew wfi(); 497b56928aSSoby Mathew } 504da6f6cdSSathees Balya 514da6f6cdSSathees Balya void __dead2 plat_error_handler(int err) 524da6f6cdSSathees Balya { 534da6f6cdSSathees Balya plat_arm_error_handler(err); 544da6f6cdSSathees Balya } 55