diff --git a/core/panic/handler.cpp b/core/panic/handler.cpp index d0acbbc..6dc5668 100644 --- a/core/panic/handler.cpp +++ b/core/panic/handler.cpp @@ -45,6 +45,8 @@ extern void DisplayStackSmashing(); extern void DisplayBufferOverflow(); Video::Font *CrashFont = nullptr; +void *FbBeforePanic = nullptr; +size_t FbPagesBeforePanic = 0; nsa void __printfWrapper(char c, void *) { @@ -101,9 +103,19 @@ nsa void HaltAllCores() nsa void InitFont() { + /* Hope we won't crash here */ + + if (FbBeforePanic != nullptr) + KernelAllocator.FreePages(FbBeforePanic, FbPagesBeforePanic); + else + { + FbPagesBeforePanic = TO_PAGES(Display->GetSize); + FbBeforePanic = KernelAllocator.RequestPages(FbPagesBeforePanic); + memcpy(FbBeforePanic, Display->GetBuffer, Display->GetSize); + } + if (CrashFont == nullptr) { - /* Hope we won't crash here */ CrashFont = new Video::Font(&_binary_files_tamsyn_font_1_11_Tamsyn8x16b_psf_start, &_binary_files_tamsyn_font_1_11_Tamsyn8x16b_psf_end, Video::FontType::PCScreenFont2); diff --git a/core/panic/ui.cpp b/core/panic/ui.cpp index 35516b6..114c6b6 100644 --- a/core/panic/ui.cpp +++ b/core/panic/ui.cpp @@ -40,10 +40,12 @@ #include "keyboard.hpp" extern void ExPrint(const char *Format, ...); -extern Video::Font *CrashFont; extern void DiagnosticDataCollection(); extern void InitFont(); +extern Video::Font *CrashFont; +extern void *FbBeforePanic; + struct StackFrame { struct StackFrame *bp; @@ -789,6 +791,7 @@ nsa void UserInput(char *Input) ExPrint("\eCACACA mem - Display memory information.\n"); ExPrint("\eAAAAAA dump [addr] [len] - Dump [len] bytes from [addr].\n"); ExPrint("\eCACACA diag - Collect diagnostic information.\n"); + ExPrint("\eAAAAAA screen - Display the final output prior to system panic.\n"); } else if (strcmp(Input, "clear") == 0) { @@ -918,6 +921,17 @@ nsa void UserInput(char *Input) { DiagnosticDataCollection(); } + else if (strcmp(Input, "screen") == 0) + { + if (unlikely(FbBeforePanic == nullptr)) + { + ExPrint("\eFF0000No screen data available\n"); + goto End; + } + memcpy(Display->GetBuffer, FbBeforePanic, Display->GetSize); + Display->UpdateBuffer(); + return; + } #ifdef DEBUG else if (strcmp(Input, "pt") == 0) {