xref: /optee_os/core/kernel/panic.c (revision e6f01334a7bf77e6e3251d51d86fe045be4aed59)
11bb92983SJerome Forissier // SPDX-License-Identifier: BSD-2-Clause
2b0104773SPascal Brand /*
387a092a7SEtienne Carriere  * Copyright (c) 2016, Linaro Limited
4b0104773SPascal Brand  * Copyright (c) 2014, STMicroelectronics International N.V.
5b0104773SPascal Brand  */
6b0104773SPascal Brand 
7b0104773SPascal Brand #include <kernel/panic.h>
8a046599aSJens Wiklander #include <kernel/thread.h>
9*e6f01334SJerome Forissier #include <kernel/unwind.h>
104de4bebcSJens Wiklander #include <trace.h>
11b0104773SPascal Brand 
1287a092a7SEtienne Carriere void __do_panic(const char *file __maybe_unused,
1387a092a7SEtienne Carriere 		const int line __maybe_unused,
1487a092a7SEtienne Carriere 		const char *func __maybe_unused,
1587a092a7SEtienne Carriere 		const char *msg __maybe_unused)
16b0104773SPascal Brand {
1787a092a7SEtienne Carriere 	/* disable prehemption */
1887a092a7SEtienne Carriere 	(void)thread_mask_exceptions(THREAD_EXCP_ALL);
19a046599aSJens Wiklander 
2087a092a7SEtienne Carriere 	/* TODO: notify other cores */
2187a092a7SEtienne Carriere 
2287a092a7SEtienne Carriere 	/* trace: Panic ['panic-string-message' ]at FILE:LINE [<FUNCTION>]" */
2387a092a7SEtienne Carriere 	if (!file && !func && !msg)
2487a092a7SEtienne Carriere 		EMSG_RAW("Panic");
2587a092a7SEtienne Carriere 	else
2687a092a7SEtienne Carriere 		EMSG_RAW("Panic %s%s%sat %s:%d %s%s%s",
2787a092a7SEtienne Carriere 			 msg ? "'" : "", msg ? msg : "", msg ? "' " : "",
2887a092a7SEtienne Carriere 			 file ? file : "?", file ? line : 0,
2987a092a7SEtienne Carriere 			 func ? "<" : "", func ? func : "", func ? ">" : "");
3087a092a7SEtienne Carriere 
31*e6f01334SJerome Forissier 	print_kernel_stack();
3287a092a7SEtienne Carriere 	/* abort current execution */
33b0104773SPascal Brand 	while (1)
34b0104773SPascal Brand 		;
35b0104773SPascal Brand }
36