summaryrefslogtreecommitdiffstats
path: root/plat/nxp/common/setup/ls_err.c
blob: 845cd150534a05b8f338d2ec7d8a46f04ec684e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright 2018-2020 NXP
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *
 */

#include <errno.h>
#include <stdbool.h>
#include <stdint.h>

#include <arch_helpers.h>
#include <common/debug.h>

#if TRUSTED_BOARD_BOOT
#include <dcfg.h>
#include <snvs.h>
#endif

#include "plat_common.h"

/*
 * Error handler
 */
void plat_error_handler(int err)
{
#if TRUSTED_BOARD_BOOT
	uint32_t mode;
	bool sb = check_boot_mode_secure(&mode);
#endif

	switch (err) {
	case -ENOENT:
	case -EAUTH:
		printf("Authentication failure\n");
#if TRUSTED_BOARD_BOOT
		/* For SB production mode i.e ITS = 1 */
		if (sb == true) {
			if (mode == 1U) {
				transition_snvs_soft_fail();
			} else {
				transition_snvs_non_secure();
			}
		}
#endif
		break;
	default:
		/* Unexpected error */
		break;
	}

	/* Loop until the watchdog resets the system */
	for (;;)
		wfi();
}