boot loader: bios IA32: Add optional timestamps to debug output
This commit is contained in:
@@ -19,6 +19,10 @@
|
|||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
|
|
||||||
|
|
||||||
|
//#define PRINT_TIME_STAMPS
|
||||||
|
// Define to print a TSC timestamp before each line of output.
|
||||||
|
|
||||||
|
|
||||||
static const char* const kDebugSyslogSignature = "Haiku syslog";
|
static const char* const kDebugSyslogSignature = "Haiku syslog";
|
||||||
|
|
||||||
static char sBuffer[16384];
|
static char sBuffer[16384];
|
||||||
@@ -28,22 +32,48 @@ static ring_buffer* sDebugSyslogBuffer = NULL;
|
|||||||
static bool sPostCleanup = false;
|
static bool sPostCleanup = false;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef PRINT_TIME_STAMPS
|
||||||
|
extern "C" uint64 rdtsc();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dprintf_args(const char *format, va_list args)
|
syslog_write(const char* buffer, size_t length)
|
||||||
{
|
{
|
||||||
char buffer[512];
|
|
||||||
int length = vsnprintf(buffer, sizeof(buffer), format, args);
|
|
||||||
|
|
||||||
if (length >= (int)sizeof(buffer))
|
|
||||||
length = sizeof(buffer) - 1;
|
|
||||||
|
|
||||||
if (sPostCleanup && sDebugSyslogBuffer != NULL) {
|
if (sPostCleanup && sDebugSyslogBuffer != NULL) {
|
||||||
ring_buffer_write(sDebugSyslogBuffer, (const uint8*)buffer, length);
|
ring_buffer_write(sDebugSyslogBuffer, (const uint8*)buffer, length);
|
||||||
} else if (sBufferPosition + length < sizeof(sBuffer)) {
|
} else if (sBufferPosition + length < sizeof(sBuffer)) {
|
||||||
memcpy(sBuffer + sBufferPosition, buffer, length);
|
memcpy(sBuffer + sBufferPosition, buffer, length);
|
||||||
sBufferPosition += length;
|
sBufferPosition += length;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
dprintf_args(const char *format, va_list args)
|
||||||
|
{
|
||||||
|
char buffer[512];
|
||||||
|
int length = vsnprintf(buffer, sizeof(buffer), format, args);
|
||||||
|
if (length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (length >= (int)sizeof(buffer))
|
||||||
|
length = sizeof(buffer) - 1;
|
||||||
|
|
||||||
|
#ifdef PRINT_TIME_STAMPS
|
||||||
|
static bool sNewLine = true;
|
||||||
|
|
||||||
|
if (sNewLine) {
|
||||||
|
char timeBuffer[32];
|
||||||
|
snprintf(timeBuffer, sizeof(timeBuffer), "[%" B_PRIu64 "] ", rdtsc());
|
||||||
|
syslog_write(timeBuffer, strlen(timeBuffer));
|
||||||
|
serial_puts(timeBuffer, strlen(timeBuffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
sNewLine = buffer[length - 1] == '\n';
|
||||||
|
#endif // PRINT_TIME_STAMPS
|
||||||
|
|
||||||
|
syslog_write(buffer, length);
|
||||||
serial_puts(buffer, length);
|
serial_puts(buffer, length);
|
||||||
|
|
||||||
if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT)
|
if (platform_boot_options() & BOOT_OPTION_DEBUG_OUTPUT)
|
||||||
|
|||||||
Reference in New Issue
Block a user