Andrew Scull | a9c172d | 2019-04-03 14:10:00 +0100 | [diff] [blame] | 1 | /* |
2 | * Copyright 2019 The Hafnium Authors. | ||||
3 | * | ||||
Andrew Walbran | e959ec1 | 2020-06-17 15:01:09 +0100 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style |
5 | * license that can be found in the LICENSE file or at | ||||
6 | * https://opensource.org/licenses/BSD-3-Clause. | ||||
Andrew Scull | a9c172d | 2019-04-03 14:10:00 +0100 | [diff] [blame] | 7 | */ |
8 | |||||
9 | #include "hf/panic.h" | ||||
10 | |||||
11 | #include <stdarg.h> | ||||
12 | |||||
Andrew Scull | a59f9bc | 2019-04-03 15:24:35 +0100 | [diff] [blame] | 13 | #include "hf/abort.h" |
Andrew Scull | a9c172d | 2019-04-03 14:10:00 +0100 | [diff] [blame] | 14 | #include "hf/dlog.h" |
15 | |||||
16 | /** | ||||
Andrew Scull | a59f9bc | 2019-04-03 15:24:35 +0100 | [diff] [blame] | 17 | * Logs a reason before calling abort. |
Andrew Scull | a9c172d | 2019-04-03 14:10:00 +0100 | [diff] [blame] | 18 | * |
19 | * TODO: Determine if we want to omit strings on non-debug builds. | ||||
20 | */ | ||||
Karl Meakin | 1923faf | 2025-03-19 14:54:52 +0000 | [diff] [blame] | 21 | [[noreturn]] void panic(const char *fmt, ...) |
Andrew Scull | a9c172d | 2019-04-03 14:10:00 +0100 | [diff] [blame] | 22 | { |
Karl Meakin | 1978e7a | 2024-11-20 13:56:58 +0000 | [diff] [blame] | 23 | struct va_list_wrapper args; |
Andrew Scull | a9c172d | 2019-04-03 14:10:00 +0100 | [diff] [blame] | 24 | |
Andrew Scull | a9c172d | 2019-04-03 14:10:00 +0100 | [diff] [blame] | 25 | dlog("Panic: "); |
26 | |||||
Karl Meakin | 1978e7a | 2024-11-20 13:56:58 +0000 | [diff] [blame] | 27 | va_start(args.va, fmt); |
28 | vdlog(fmt, &args); | ||||
29 | va_end(args.va); | ||||
Andrew Scull | a9c172d | 2019-04-03 14:10:00 +0100 | [diff] [blame] | 30 | |
31 | dlog("\n"); | ||||
32 | |||||
Andrew Scull | a59f9bc | 2019-04-03 15:24:35 +0100 | [diff] [blame] | 33 | abort(); |
Andrew Scull | a9c172d | 2019-04-03 14:10:00 +0100 | [diff] [blame] | 34 | } |