1/*
2 * Copyright 2016 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include <string.h>
8
9#include <boot/platform.h>
10#include <boot/stage2.h>
11#include <boot/stdio.h>
12
13#include "efi_platform.h"
14#include "serial.h"
15
16
17static void
18dprintf_args(const char *format, va_list args)
19{
20	char buffer[512];
21	int length = vsnprintf(buffer, sizeof(buffer), format, args);
22	if (length == 0)
23		return;
24
25	serial_puts(buffer, length);
26}
27
28
29extern "C" void
30dprintf(const char *format, ...)
31{
32	va_list args;
33
34	va_start(args, format);
35	dprintf_args(format, args);
36	va_end(args);
37}
38
39
40extern "C" void
41panic(const char *format, ...)
42{
43	va_list args;
44
45	platform_switch_to_text_mode();
46
47	puts("*** PANIC ***");
48
49	va_start(args, format);
50	vprintf(format, args);
51	va_end(args);
52
53	while (true)
54		kBootServices->Stall(1000000);
55}
56
57
58char*
59platform_debug_get_log_buffer(size_t *_size)
60{
61	return NULL;
62}
63