Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 1 | /* |
Roberto Vargas | 2ca18d9 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2018, 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> |
Soby Mathew | 9427357 | 2018-03-07 11:32:04 +0000 | [diff] [blame] | 9 | #include <console.h> |
Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 10 | #include <debug.h> |
| 11 | #include <errno.h> |
| 12 | #include <norflash.h> |
Roberto Vargas | 2ca18d9 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 13 | #include <platform.h> |
Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 14 | #include <stdint.h> |
| 15 | |
| 16 | /* |
Soby Mathew | 9427357 | 2018-03-07 11:32:04 +0000 | [diff] [blame] | 17 | * ARM common implementation for error handler |
Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 18 | */ |
| 19 | void plat_error_handler(int err) |
| 20 | { |
| 21 | int ret; |
| 22 | |
| 23 | switch (err) { |
| 24 | case -ENOENT: |
| 25 | case -EAUTH: |
| 26 | /* Image load or authentication error. Erase the ToC */ |
| 27 | INFO("Erasing FIP ToC from flash...\n"); |
| 28 | nor_unlock(PLAT_ARM_FIP_BASE); |
| 29 | ret = nor_word_program(PLAT_ARM_FIP_BASE, 0); |
Soby Mathew | 9427357 | 2018-03-07 11:32:04 +0000 | [diff] [blame] | 30 | if (ret != 0) { |
Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 31 | ERROR("Cannot erase ToC\n"); |
| 32 | } else { |
| 33 | INFO("Done\n"); |
| 34 | } |
| 35 | break; |
| 36 | default: |
| 37 | /* Unexpected error */ |
| 38 | break; |
| 39 | } |
| 40 | |
Soby Mathew | 9427357 | 2018-03-07 11:32:04 +0000 | [diff] [blame] | 41 | (void)console_flush(); |
| 42 | |
Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 43 | /* Loop until the watchdog resets the system */ |
| 44 | for (;;) |
Sandrine Bailleux | 628198b | 2016-08-18 09:24:40 +0100 | [diff] [blame] | 45 | wfi(); |
Juan Castillo | b6132f1 | 2015-10-06 14:01:35 +0100 | [diff] [blame] | 46 | } |