blob: 9c0a4f6efdcc5462c4daec5a54b4ee2747f57e64 [file] [log] [blame]
Andrew Sculla9c172d2019-04-03 14:10:00 +01001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "hf/panic.h"
18
19#include <stdarg.h>
20
Andrew Sculla59f9bc2019-04-03 15:24:35 +010021#include "hf/abort.h"
Andrew Sculla9c172d2019-04-03 14:10:00 +010022#include "hf/dlog.h"
23
24/**
Andrew Sculla59f9bc2019-04-03 15:24:35 +010025 * Logs a reason before calling abort.
Andrew Sculla9c172d2019-04-03 14:10:00 +010026 *
27 * TODO: Determine if we want to omit strings on non-debug builds.
28 */
29noreturn void panic(const char *fmt, ...)
30{
31 va_list args;
32
Andrew Sculla9c172d2019-04-03 14:10:00 +010033 dlog("Panic: ");
34
35 va_start(args, fmt);
36 vdlog(fmt, args);
37 va_end(args);
38
39 dlog("\n");
40
Andrew Sculla59f9bc2019-04-03 15:24:35 +010041 abort();
Andrew Sculla9c172d2019-04-03 14:10:00 +010042}