Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 1 | /* |
Sandrine Bailleux | 628198b | 2016-08-18 09:24:40 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. |
Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Sandrine Bailleux | 628198b | 2016-08-18 09:24:40 +0100 | [diff] [blame] | 7 | #include <arch_helpers.h> |
Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 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 | */ |
| 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 (;;) |
Sandrine Bailleux | 628198b | 2016-08-18 09:24:40 +0100 | [diff] [blame] | 41 | wfi(); |
Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 42 | } |