2015-10-06 14:01:35 +01:00
|
|
|
/*
|
2018-02-12 12:36:17 +00:00
|
|
|
* Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
|
2015-10-06 14:01:35 +01:00
|
|
|
*
|
2017-05-03 09:38:09 +01:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2015-10-06 14:01:35 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdint.h>
|
2018-12-14 00:18:21 +00:00
|
|
|
|
|
|
|
#include <platform_def.h>
|
|
|
|
|
|
|
|
#include <arch_helpers.h>
|
|
|
|
#include <common/debug.h>
|
|
|
|
#include <drivers/cfi/v2m_flash.h>
|
|
|
|
#include <drivers/console.h>
|
2019-01-25 14:30:04 +00:00
|
|
|
#include <plat/arm/common/plat_arm.h>
|
2018-12-14 00:18:21 +00:00
|
|
|
#include <plat/common/platform.h>
|
|
|
|
|
2018-09-03 17:41:13 +01:00
|
|
|
#pragma weak plat_arm_error_handler
|
|
|
|
|
2015-10-06 14:01:35 +01:00
|
|
|
/*
|
2018-03-07 11:32:04 +00:00
|
|
|
* ARM common implementation for error handler
|
2015-10-06 14:01:35 +01:00
|
|
|
*/
|
2018-09-03 17:41:13 +01:00
|
|
|
void __dead2 plat_arm_error_handler(int err)
|
2015-10-06 14:01:35 +01:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
switch (err) {
|
|
|
|
case -ENOENT:
|
|
|
|
case -EAUTH:
|
|
|
|
/* Image load or authentication error. Erase the ToC */
|
|
|
|
INFO("Erasing FIP ToC from flash...\n");
|
2018-11-06 13:14:21 +00:00
|
|
|
(void)nor_unlock(PLAT_ARM_FIP_BASE);
|
2015-10-06 14:01:35 +01:00
|
|
|
ret = nor_word_program(PLAT_ARM_FIP_BASE, 0);
|
2018-03-07 11:32:04 +00:00
|
|
|
if (ret != 0) {
|
2015-10-06 14:01:35 +01:00
|
|
|
ERROR("Cannot erase ToC\n");
|
|
|
|
} else {
|
|
|
|
INFO("Done\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Unexpected error */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-03-07 11:32:04 +00:00
|
|
|
(void)console_flush();
|
|
|
|
|
2015-10-06 14:01:35 +01:00
|
|
|
/* Loop until the watchdog resets the system */
|
|
|
|
for (;;)
|
2016-08-18 09:24:40 +01:00
|
|
|
wfi();
|
2015-10-06 14:01:35 +01:00
|
|
|
}
|
2018-09-03 17:41:13 +01:00
|
|
|
|
|
|
|
void __dead2 plat_error_handler(int err)
|
|
|
|
{
|
|
|
|
plat_arm_error_handler(err);
|
|
|
|
}
|