From aeb2376cdd3f91c1c1a202a91b6b53cdd4442c5a Mon Sep 17 00:00:00 2001 From: Johannes Wischert Date: Tue, 15 May 2012 19:02:54 -0500 Subject: [PATCH] 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 --- .../boot/platform/raspberrypi_arm/debug.cpp | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/system/boot/platform/raspberrypi_arm/debug.cpp b/src/system/boot/platform/raspberrypi_arm/debug.cpp index 091cb414a2..4e47bc757e 100644 --- a/src/system/boot/platform/raspberrypi_arm/debug.cpp +++ b/src/system/boot/platform/raspberrypi_arm/debug.cpp @@ -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 #include #include -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); }