arm_err.c 1 KB
Newer Older
1
/*
Roberto Vargas's avatar
Roberto Vargas committed
2
 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
 */

7
#include <arch_helpers.h>
8
#include <console.h>
9
10
#include <debug.h>
#include <errno.h>
11
#include <plat_arm.h>
Roberto Vargas's avatar
Roberto Vargas committed
12
#include <platform.h>
13
#include <platform_def.h>
14
#include <stdint.h>
15
#include <v2m_flash.h>
16

17
18
#pragma weak plat_arm_error_handler

19
/*
20
 * ARM common implementation for error handler
21
 */
22
void __dead2 plat_arm_error_handler(int err)
23
24
25
26
27
28
29
30
{
	int ret;

	switch (err) {
	case -ENOENT:
	case -EAUTH:
		/* Image load or authentication error. Erase the ToC */
		INFO("Erasing FIP ToC from flash...\n");
31
		(void)nor_unlock(PLAT_ARM_FIP_BASE);
32
		ret = nor_word_program(PLAT_ARM_FIP_BASE, 0);
33
		if (ret != 0) {
34
35
36
37
38
39
40
41
42
43
			ERROR("Cannot erase ToC\n");
		} else {
			INFO("Done\n");
		}
		break;
	default:
		/* Unexpected error */
		break;
	}

44
45
	(void)console_flush();

46
47
	/* Loop until the watchdog resets the system */
	for (;;)
48
		wfi();
49
}
50
51
52
53
54

void __dead2 plat_error_handler(int err)
{
	plat_arm_error_handler(err);
}