blob: 7571d392b2e67b48715ebd898eaac682d8fe07cc [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{
23 va_list args;
24
Andrew Sculla9c172d2019-04-03 14:10:00 +010025 dlog("Panic: ");
26
27 va_start(args, fmt);
28 vdlog(fmt, args);
29 va_end(args);
30
31 dlog("\n");
32
Andrew Sculla59f9bc2019-04-03 15:24:35 +010033 abort();
Andrew Sculla9c172d2019-04-03 14:10:00 +010034}