16152d8f5SFrançois Revol/*
234dc9962SFrançois Revol * Copyright 2008-2010, Fran��ois Revol, revol@free.fr. All rights reserved.
36152d8f5SFrançois Revol * Distributed under the terms of the MIT License.
46152d8f5SFrançois Revol */
56152d8f5SFrançois Revol
66152d8f5SFrançois Revol
76152d8f5SFrançois Revol#include "keyboard.h"
88c27b862SFrançois Revol#include "toscalls.h"
96152d8f5SFrançois Revol
107a2ec456SFrançois Revol#include <boot/stage2.h>
116152d8f5SFrançois Revol#include <boot/platform.h>
126152d8f5SFrançois Revol#include <boot/stdio.h>
136152d8f5SFrançois Revol#include <stdarg.h>
146152d8f5SFrançois Revol
158c27b862SFrançois Revol#include <Errors.h>
166152d8f5SFrançois Revol
176152d8f5SFrançois Revol/*!	This works only after console_init() was called.
186152d8f5SFrançois Revol*/
196152d8f5SFrançois Revolvoid
206152d8f5SFrançois Revolpanic(const char *format, ...)
216152d8f5SFrançois Revol{
22c6d022faSFrançois Revol	const char greetings[] = "\n*** PANIC ***";
2393879b9aSFrançois Revol	char buffer[512];
246152d8f5SFrançois Revol	va_list list;
256152d8f5SFrançois Revol
2693879b9aSFrançois Revol	//platform_switch_to_text_mode();
276152d8f5SFrançois Revol
28c6d022faSFrançois Revol	Bconputs(DEV_CONSOLE, greetings);
29c6d022faSFrançois Revol	// send to the emulator's stdout if available
30c6d022faSFrançois Revol	nat_feat_debugprintf(greetings);
31c6d022faSFrançois Revol	nat_feat_debugprintf("\n");
326152d8f5SFrançois Revol
336152d8f5SFrançois Revol	va_start(list, format);
343ce26345SIngo Weinhold	vsnprintf(buffer, sizeof(buffer), format, list);
356152d8f5SFrançois Revol	va_end(list);
366152d8f5SFrançois Revol
3793879b9aSFrançois Revol	Bconputs(DEV_CONSOLE, buffer);
38c6d022faSFrançois Revol	// send to the emulator's stdout if available
39c6d022faSFrançois Revol	nat_feat_debugprintf(buffer);
4074c5e8bdSFrançois Revol	nat_feat_debugprintf("\n");
4193879b9aSFrançois Revol
4293879b9aSFrançois Revol	Bconputs(DEV_CONSOLE, "\nPress key to reboot.");
436152d8f5SFrançois Revol
446152d8f5SFrançois Revol	clear_key_buffer();
456152d8f5SFrançois Revol	wait_for_key();
466152d8f5SFrançois Revol	platform_exit();
476152d8f5SFrançois Revol}
486152d8f5SFrançois Revol
496152d8f5SFrançois Revol
506152d8f5SFrançois Revolvoid
516152d8f5SFrançois Revoldprintf(const char *format, ...)
526152d8f5SFrançois Revol{
536152d8f5SFrançois Revol	char buffer[512];
546152d8f5SFrançois Revol	va_list list;
556152d8f5SFrançois Revol
566152d8f5SFrançois Revol	va_start(list, format);
573ce26345SIngo Weinhold	vsnprintf(buffer, sizeof(buffer), format, list);
586152d8f5SFrançois Revol	va_end(list);
596152d8f5SFrançois Revol
607ef900d3SFrançois Revol	Bconput(DEV_AUX, buffer);
616152d8f5SFrançois Revol
62d4d03238SFrançois Revol	// send to the emulator's stdout if available
63d4d03238SFrançois Revol	nat_feat_debugprintf(buffer);
64d4d03238SFrançois Revol
657ef900d3SFrançois Revol	//if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT)
667a2ec456SFrançois Revol	if (!gKernelArgs.frame_buffer.enabled)
677ef900d3SFrançois Revol		Bconput(DEV_CONSOLE, buffer);
686152d8f5SFrançois Revol}
696152d8f5SFrançois Revol
708c27b862SFrançois Revol
715e78920cSIngo Weinholdchar*
725e78920cSIngo Weinholdplatform_debug_get_log_buffer(size_t* _size)
735e78920cSIngo Weinhold{
745e78920cSIngo Weinhold	return NULL;
755e78920cSIngo Weinhold}
76