1 /*
2  * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <arch_helpers.h>
8 #include <board_arm_def.h>
9 #include <debug.h>
10 #include <errno.h>
11 #include <norflash.h>
12 #include <stdint.h>
13 
14 /*
15  * FVP error handler
16  */
plat_error_handler(int err)17 void plat_error_handler(int err)
18 {
19 	int ret;
20 
21 	switch (err) {
22 	case -ENOENT:
23 	case -EAUTH:
24 		/* Image load or authentication error. Erase the ToC */
25 		INFO("Erasing FIP ToC from flash...\n");
26 		nor_unlock(PLAT_ARM_FIP_BASE);
27 		ret = nor_word_program(PLAT_ARM_FIP_BASE, 0);
28 		if (ret) {
29 			ERROR("Cannot erase ToC\n");
30 		} else {
31 			INFO("Done\n");
32 		}
33 		break;
34 	default:
35 		/* Unexpected error */
36 		break;
37 	}
38 
39 	/* Loop until the watchdog resets the system */
40 	for (;;)
41 		wfi();
42 }
43