From cc55d4127310370f3239556e6d232fc5a58e21f1 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 3 Feb 2020 12:20:31 +0100 Subject: [PATCH] efi loader: implement simple in-memory log This lets us see the bootloader log from the boot menu, which is very helpful on machines with no serial port or other way to debug. --- src/system/boot/platform/efi/debug.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/system/boot/platform/efi/debug.cpp b/src/system/boot/platform/efi/debug.cpp index 809af30e84..9355c6a796 100644 --- a/src/system/boot/platform/efi/debug.cpp +++ b/src/system/boot/platform/efi/debug.cpp @@ -14,6 +14,18 @@ #include "serial.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; +} + + static void dprintf_args(const char *format, va_list args) { @@ -22,6 +34,7 @@ dprintf_args(const char *format, va_list args) if (length == 0) return; + syslog_write(buffer, length); serial_puts(buffer, length); } @@ -58,5 +71,8 @@ panic(const char *format, ...) char* platform_debug_get_log_buffer(size_t *_size) { - return NULL; + if (_size != NULL) + *_size = sizeof(sBuffer); + + return sBuffer; }