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