xref: /haiku/src/system/boot/platform/u-boot/debug.cpp (revision 9829800d2c60d6aba146af7fde09601929161730)
1 /*
2  * Copyright 2004-2010, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "serial.h"
8 #include "keyboard.h"
9 
10 #include <boot/platform.h>
11 #include <boot/stdio.h>
12 #include <stdarg.h>
13 
14 
15 /*!	This works only after console_init() was called.
16 */
17 extern "C" void
18 panic(const char* format, ...)
19 {
20 	va_list list;
21 
22 	platform_switch_to_text_mode();
23 
24 	puts("*** PANIC ***");
25 
26 	va_start(list, format);
27 	vprintf(format, list);
28 	va_end(list);
29 
30 	puts("\nPress key to reboot.");
31 
32 	clear_key_buffer();
33 	wait_for_key();
34 	platform_exit();
35 }
36 
37 
38 extern "C" void
39 dprintf(const char* format, ...)
40 {
41 	char buffer[512];
42 	va_list list;
43 	int length;
44 
45 	va_start(list, format);
46 	length = vsnprintf(buffer, sizeof(buffer), format, list);
47 	va_end(list);
48 
49 	if (length >= (int)sizeof(buffer))
50 		length = sizeof(buffer) - 1;
51 
52 	serial_puts(buffer, length);
53 
54 	if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT)
55 		fprintf(stderr, "%s", buffer);
56 }
57 
58 
59 char*
60 platform_debug_get_log_buffer(size_t* _size)
61 {
62 	return NULL;
63 }
64