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 <[email protected]>
This commit is contained in:
committed by
Alexander von Gluck IV
parent
3af608ada5
commit
aeb2376cdd
@@ -1,25 +1,62 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2004-2005, Axel Dörfler, [email protected].
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
* Copyright 2009 Jonas Sundström, [email protected]
|
* Copyright 2009 Jonas Sundström, [email protected]
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "serial.h"
|
||||||
|
|
||||||
#include <boot/platform.h>
|
#include <boot/platform.h>
|
||||||
#include <boot/stdio.h>
|
#include <boot/stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
||||||
void
|
extern "C" void
|
||||||
panic(const char* format, ...)
|
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, ...)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user