arm_err.c 995 Bytes
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
11
#include <debug.h>
#include <errno.h>
#include <norflash.h>
Roberto Vargas's avatar
Roberto Vargas committed
12
#include <platform.h>
13
#include <platform_def.h>
14
15
#include <stdint.h>

16
17
#pragma weak plat_arm_error_handler

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

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

43
44
	(void)console_flush();

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

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