rpi: Add debug code from u-boot code

* Cleaned up a bit
* Add panic function
* Add printd function

Signed-off-by: Alexander von Gluck IV <kallisti5@unixzen.com>
This commit is contained in:
Johannes Wischert 2012-05-15 19:02:54 -05:00 committed by Alexander von Gluck IV
parent 3af608ada5
commit aeb2376cdd

View File

@ -1,25 +1,62 @@
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de.
* All rights reserved. Distributed under the terms of the MIT License.
*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* All rights reserved. Distributed under the terms of the MIT License.
*/
#include "serial.h"
#include <boot/platform.h>
#include <boot/stdio.h>
#include <stdarg.h>
void
extern "C" void
panic(const char* format, ...)
{
#warning IMPLEMENT panic
const char hint[] = "*** PANIC ***";
char buffer[512];
va_list list;
int length;
serial_puts(hint, sizeof(hint));
va_start(list, format);
length = vsnprintf(buffer, sizeof(buffer), format, list);
va_end(list);
if (length >= (int)sizeof(buffer))
length = sizeof(buffer) - 1;
serial_puts(buffer, length);
//fprintf(stderr, "%s", buffer);
serial_puts("\nPress key to reboot.", 21);
platform_exit();
}
void
extern "C" void
dprintf(const char* format, ...)
{
#warning IMPLEMENT dprintf
char buffer[512];
va_list list;
int length;
va_start(list, format);
length = vsnprintf(buffer, sizeof(buffer), format, list);
va_end(list);
if (length >= (int)sizeof(buffer))
length = sizeof(buffer) - 1;
serial_puts(buffer, length);
if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT)
fprintf(stderr, "%s", buffer);
}