Add "screen" command to panic UI

This commit is contained in:
EnderIce2 2024-02-29 00:05:59 +02:00
parent 455c8a82de
commit 72ee2075ae
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
2 changed files with 28 additions and 2 deletions

View File

@ -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);

View File

@ -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)
{