arm_err.c 871 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 <board_arm_def.h>
9
#include <console.h>
10
11
12
#include <debug.h>
#include <errno.h>
#include <norflash.h>
Roberto Vargas's avatar
Roberto Vargas committed
13
#include <platform.h>
14
15
16
#include <stdint.h>

/*
17
 * ARM common implementation for error handler
18
19
20
21
22
23
24
25
26
27
28
29
 */
void plat_error_handler(int err)
{
	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);
30
		if (ret != 0) {
31
32
33
34
35
36
37
38
39
40
			ERROR("Cannot erase ToC\n");
		} else {
			INFO("Done\n");
		}
		break;
	default:
		/* Unexpected error */
		break;
	}

41
42
	(void)console_flush();

43
44
	/* Loop until the watchdog resets the system */
	for (;;)
45
		wfi();
46
}