/*
 * Copyright 2019 The Hafnium Authors.
 *
 * Use of this source code is governed by a BSD-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/BSD-3-Clause.
 */

#include "hf/panic.h"

#include <stdarg.h>

#include "hf/abort.h"
#include "hf/dlog.h"

/**
 * Logs a reason before calling abort.
 *
 * TODO: Determine if we want to omit strings on non-debug builds.
 */
noreturn void panic(const char *fmt, ...)
{
	struct va_list_wrapper args;

	dlog("Panic: ");

	va_start(args.va, fmt);
	vdlog(fmt, &args);
	va_end(args.va);

	dlog("\n");

	abort();
}
