1*1bb92983SJerome 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 * All rights reserved. 6b0104773SPascal Brand * 7b0104773SPascal Brand * Redistribution and use in source and binary forms, with or without 8b0104773SPascal Brand * modification, are permitted provided that the following conditions are met: 9b0104773SPascal Brand * 10b0104773SPascal Brand * 1. Redistributions of source code must retain the above copyright notice, 11b0104773SPascal Brand * this list of conditions and the following disclaimer. 12b0104773SPascal Brand * 13b0104773SPascal Brand * 2. Redistributions in binary form must reproduce the above copyright notice, 14b0104773SPascal Brand * this list of conditions and the following disclaimer in the documentation 15b0104773SPascal Brand * and/or other materials provided with the distribution. 16b0104773SPascal Brand * 17b0104773SPascal Brand * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18b0104773SPascal Brand * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19b0104773SPascal Brand * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20b0104773SPascal Brand * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21b0104773SPascal Brand * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22b0104773SPascal Brand * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23b0104773SPascal Brand * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24b0104773SPascal Brand * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25b0104773SPascal Brand * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26b0104773SPascal Brand * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27b0104773SPascal Brand * POSSIBILITY OF SUCH DAMAGE. 28b0104773SPascal Brand */ 29b0104773SPascal Brand 30b0104773SPascal Brand #include <kernel/panic.h> 31a046599aSJens Wiklander #include <kernel/thread.h> 324de4bebcSJens Wiklander #include <trace.h> 33b0104773SPascal Brand 3487a092a7SEtienne Carriere void __do_panic(const char *file __maybe_unused, 3587a092a7SEtienne Carriere const int line __maybe_unused, 3687a092a7SEtienne Carriere const char *func __maybe_unused, 3787a092a7SEtienne Carriere const char *msg __maybe_unused) 38b0104773SPascal Brand { 3987a092a7SEtienne Carriere /* disable prehemption */ 4087a092a7SEtienne Carriere (void)thread_mask_exceptions(THREAD_EXCP_ALL); 41a046599aSJens Wiklander 4287a092a7SEtienne Carriere /* TODO: notify other cores */ 4387a092a7SEtienne Carriere 4487a092a7SEtienne Carriere /* trace: Panic ['panic-string-message' ]at FILE:LINE [<FUNCTION>]" */ 4587a092a7SEtienne Carriere if (!file && !func && !msg) 4687a092a7SEtienne Carriere EMSG_RAW("Panic"); 4787a092a7SEtienne Carriere else 4887a092a7SEtienne Carriere EMSG_RAW("Panic %s%s%sat %s:%d %s%s%s", 4987a092a7SEtienne Carriere msg ? "'" : "", msg ? msg : "", msg ? "' " : "", 5087a092a7SEtienne Carriere file ? file : "?", file ? line : 0, 5187a092a7SEtienne Carriere func ? "<" : "", func ? func : "", func ? ">" : ""); 5287a092a7SEtienne Carriere 53aee3c6d6SZeng Tao EPRINT_STACK(); 5487a092a7SEtienne Carriere /* abort current execution */ 55b0104773SPascal Brand while (1) 56b0104773SPascal Brand ; 57b0104773SPascal Brand } 58