Ambroise Vincent | fa42c9e | 2019-07-04 14:58:45 +0100 | [diff] [blame] | 1 | /* |
Zelalem | 87675d4 | 2020-02-03 14:56:42 -0600 | [diff] [blame] | 2 | * Copyright (c) 2019-2020, Arm Limited. All rights reserved. |
Ambroise Vincent | fa42c9e | 2019-07-04 14:58:45 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <errno.h> |
| 8 | |
| 9 | #include <common/debug.h> |
| 10 | #include <drivers/arm/sp805.h> |
| 11 | #include <drivers/cfi/v2m_flash.h> |
| 12 | #include <plat/arm/common/plat_arm.h> |
Ambroise Vincent | fa42c9e | 2019-07-04 14:58:45 +0100 | [diff] [blame] | 13 | #include <platform_def.h> |
| 14 | |
| 15 | /* |
| 16 | * FVP error handler |
| 17 | */ |
| 18 | __dead2 void plat_arm_error_handler(int err) |
| 19 | { |
| 20 | int ret; |
| 21 | |
| 22 | switch (err) { |
| 23 | case -ENOENT: |
| 24 | case -EAUTH: |
| 25 | /* Image load or authentication error. Erase the ToC */ |
| 26 | INFO("Erasing FIP ToC from flash...\n"); |
| 27 | (void)nor_unlock(PLAT_ARM_FIP_BASE); |
| 28 | ret = nor_word_program(PLAT_ARM_FIP_BASE, 0); |
| 29 | if (ret != 0) { |
| 30 | ERROR("Cannot erase ToC\n"); |
| 31 | } else { |
| 32 | INFO("Done\n"); |
| 33 | } |
| 34 | break; |
| 35 | default: |
| 36 | /* Unexpected error */ |
| 37 | break; |
| 38 | } |
| 39 | |
| 40 | (void)console_flush(); |
| 41 | |
| 42 | /* Setup the watchdog to reset the system as soon as possible */ |
| 43 | sp805_refresh(ARM_SP805_TWDG_BASE, 1U); |
| 44 | |
| 45 | for (;;) |
| 46 | wfi(); |
| 47 | } |