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 const char hint[] = "*** PANIC ***"; 21 char buffer[512]; 22 va_list list; 23 int length; 24 25 platform_switch_to_text_mode(); 26 27 serial_puts(hint, sizeof(hint)); 28 serial_puts("\n", 1); 29 //fprintf(stderr, "%s", hint); 30 puts(hint); 31 32 va_start(list, format); 33 length = vsnprintf(buffer, sizeof(buffer), format, list); 34 va_end(list); 35 36 if (length >= (int)sizeof(buffer)) 37 length = sizeof(buffer) - 1; 38 39 serial_puts(buffer, length); 40 //fprintf(stderr, "%s", buffer); 41 puts(buffer); 42 43 puts("\nPress key to reboot."); 44 45 clear_key_buffer(); 46 wait_for_key(); 47 platform_exit(); 48 } 49 50 51 extern "C" void 52 dprintf(const char* format, ...) 53 { 54 char buffer[512]; 55 va_list list; 56 int length; 57 58 va_start(list, format); 59 length = vsnprintf(buffer, sizeof(buffer), format, list); 60 va_end(list); 61 62 if (length >= (int)sizeof(buffer)) 63 length = sizeof(buffer) - 1; 64 65 serial_puts(buffer, length); 66 67 if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT) 68 fprintf(stderr, "%s", buffer); 69 } 70 71 72 char* 73 platform_debug_get_log_buffer(size_t* _size) 74 { 75 return NULL; 76 } 77