xref: /optee_os/core/kernel/panic.c (revision 5a913ee74d3c71af2a2860ce8a4e7aeab2916f9b)
1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3  * Copyright (c) 2016, Linaro Limited
4  * Copyright (c) 2014, STMicroelectronics International N.V.
5  */
6 
7 #include <kernel/panic.h>
8 #include <kernel/thread.h>
9 #include <trace.h>
10 
11 void __do_panic(const char *file __maybe_unused,
12 		const int line __maybe_unused,
13 		const char *func __maybe_unused,
14 		const char *msg __maybe_unused)
15 {
16 	/* disable prehemption */
17 	(void)thread_mask_exceptions(THREAD_EXCP_ALL);
18 
19 	/* TODO: notify other cores */
20 
21 	/* trace: Panic ['panic-string-message' ]at FILE:LINE [<FUNCTION>]" */
22 	if (!file && !func && !msg)
23 		EMSG_RAW("Panic");
24 	else
25 		EMSG_RAW("Panic %s%s%sat %s:%d %s%s%s",
26 			 msg ? "'" : "", msg ? msg : "", msg ? "' " : "",
27 			 file ? file : "?", file ? line : 0,
28 			 func ? "<" : "", func ? func : "", func ? ">" : "");
29 
30 	EPRINT_STACK();
31 	/* abort current execution */
32 	while (1)
33 		;
34 }
35