From Adrien Destugues <pulkomandy@xxxxxxxxx>:
Adrien Destugues has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/2369 ;)
Change subject: openfirmware: implement the in-memory log
......................................................................
openfirmware: implement the in-memory log
We should probably make this code more platform-generic, the
implementation is very similar to the EFI one.
---
M src/system/boot/platform/openfirmware/debug.cpp
1 file changed, 39 insertions(+), 7 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/69/2369/1
diff --git a/src/system/boot/platform/openfirmware/debug.cpp
b/src/system/boot/platform/openfirmware/debug.cpp
index ef31e66..78eb3cf 100644
--- a/src/system/boot/platform/openfirmware/debug.cpp
+++ b/src/system/boot/platform/openfirmware/debug.cpp
@@ -1,16 +1,30 @@
/*
* Copyright 2003-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * Copyright 2016 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <stdarg.h>
+#include <string.h>
#include <boot/platform.h>
#include <boot/stdio.h>
#include <platform/openfirmware/openfirmware.h>
+static char sBuffer[16384];
+static uint32 sBufferPosition;
+
+
+static void
+syslog_write(const char* buffer, size_t length)
+{
+ memcpy(sBuffer + sBufferPosition, buffer, length);
+ sBufferPosition += length;
+}
+
+
extern "C" void
panic(const char* format, ...)
{
@@ -27,19 +41,37 @@
}
-extern "C" void
-dprintf(const char* format, ...)
+static void
+dprintf_args(const char *format, va_list args)
{
- va_list list;
+ char buffer[512];
+ int length = vsnprintf(buffer, sizeof(buffer), format, args);
+ if (length == 0)
+ return;
- va_start(list, format);
- vprintf(format, list);
- va_end(list);
+ syslog_write(buffer, length);
+ printf("%s", buffer);
}
+extern "C" void
+dprintf(const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ dprintf_args(format, args);
+ va_end(args);
+}
+
+
+
+
char*
platform_debug_get_log_buffer(size_t* _size)
{
- return NULL;
+ if (_size != NULL)
+ *_size = sizeof(sBuffer);
+
+ return sBuffer;
}
--
To view, visit https://review.haiku-os.org/c/haiku/+/2369
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I17c9db933bfc2a81c96816dd6348d2d0c9627951
Gerrit-Change-Number: 2369
Gerrit-PatchSet: 1
Gerrit-Owner: Adrien Destugues <pulkomandy@xxxxxxxxx>
Gerrit-MessageType: newchange