blob: cfd9a37ad18eb5372f1daa16ab1c694c51bc39f4 [file] [log] [blame]
Andrew Sculla9c172d2019-04-03 14:10:00 +01001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
Andrew Walbrane959ec12020-06-17 15:01:09 +01004 * 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 Sculla9c172d2019-04-03 14:10:00 +01007 */
8
9#include "hf/panic.h"
10
11#include <stdarg.h>
12
Andrew Sculla59f9bc2019-04-03 15:24:35 +010013#include "hf/abort.h"
Andrew Sculla9c172d2019-04-03 14:10:00 +010014#include "hf/dlog.h"
15
16/**
Andrew Sculla59f9bc2019-04-03 15:24:35 +010017 * Logs a reason before calling abort.
Andrew Sculla9c172d2019-04-03 14:10:00 +010018 *
19 * TODO: Determine if we want to omit strings on non-debug builds.
20 */
21noreturn void panic(const char *fmt, ...)
22{
Karl Meakin1978e7a2024-11-20 13:56:58 +000023 struct va_list_wrapper args;
Andrew Sculla9c172d2019-04-03 14:10:00 +010024
Andrew Sculla9c172d2019-04-03 14:10:00 +010025 dlog("Panic: ");
26
Karl Meakin1978e7a2024-11-20 13:56:58 +000027 va_start(args.va, fmt);
28 vdlog(fmt, &args);
29 va_end(args.va);
Andrew Sculla9c172d2019-04-03 14:10:00 +010030
31 dlog("\n");
32
Andrew Sculla59f9bc2019-04-03 15:24:35 +010033 abort();
Andrew Sculla9c172d2019-04-03 14:10:00 +010034}