1 /*
2 * Copyright (c) 2024, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8
9 #include "fatal_error.h"
10
11 #include "tfm_hal_device_header.h"
12
13 #include <stdio.h>
14
15 extern uint32_t stdio_is_initialized;
16
log_error_permissions_check(uint32_t err,bool is_fatal)17 __WEAK bool log_error_permissions_check(uint32_t err, bool is_fatal)
18 {
19 return true;
20 }
21
log_error(char * file,uint32_t line,uint32_t err,void * sp,bool is_fatal)22 __WEAK void log_error(char *file, uint32_t line, uint32_t err, void *sp, bool is_fatal)
23 {
24 if (stdio_is_initialized) {
25 if (is_fatal) {
26 printf("[ERR] Fatal error ");
27 } else {
28 printf("[WRN] Non-fatal error ");
29 }
30
31 if (err != 0) {
32 printf("%08X ", err);
33 }
34
35 if (file != NULL) {
36 printf("in file %s ", file);
37 }
38
39 if (line != 0) {
40 printf("at line %u ", line);
41 }
42
43 if (sp != NULL) {
44 printf("with SP=%p ", sp);
45 }
46
47 printf("\r\n");
48 }
49 }
50