mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Added debug window
This commit is contained in:
parent
fec1a97bf9
commit
39a788ddb5
@ -13,10 +13,44 @@ using namespace GraphicalUserInterface;
|
|||||||
|
|
||||||
namespace Recovery
|
namespace Recovery
|
||||||
{
|
{
|
||||||
|
WidgetCollection *wdgDbgWin = nullptr;
|
||||||
|
Window *DbgWin = nullptr;
|
||||||
|
|
||||||
void KernelRecovery::RecoveryThread()
|
void KernelRecovery::RecoveryThread()
|
||||||
{
|
{
|
||||||
|
while (wdgDbgWin == nullptr || DbgWin == nullptr)
|
||||||
|
TaskManager->Sleep(100);
|
||||||
|
|
||||||
|
wdgDbgWin->CreateLabel({10, 0, 0, 0}, "Scheduler Ticks / Last Task Ticks");
|
||||||
|
GraphicalUserInterface::Handle SchedLblHnd = wdgDbgWin->CreateLabel({10, 20, 0, 0}, "0000000000000000 / 0000000000000000");
|
||||||
|
|
||||||
|
wdgDbgWin->CreateLabel({10, 60, 0, 0}, "Memory Usage");
|
||||||
|
GraphicalUserInterface::Handle MemLblHnd = wdgDbgWin->CreateLabel({10, 80, 0, 0}, "0MB / 0GB (0MB reserved) 0%");
|
||||||
|
|
||||||
|
DbgWin->AddWidget(wdgDbgWin);
|
||||||
|
|
||||||
|
char TicksText[128];
|
||||||
|
uint64_t MemUsed = 0;
|
||||||
|
uint64_t MemTotal = 0;
|
||||||
|
uint64_t MemReserved = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
sprintf(TicksText, "%016ld / %016ld", TaskManager->GetSchedulerTicks(), TaskManager->GetLastTaskTicks());
|
||||||
|
wdgDbgWin->SetText(SchedLblHnd, TicksText);
|
||||||
|
static int RefreshCounter = 100;
|
||||||
|
if (RefreshCounter-- == 0)
|
||||||
|
{
|
||||||
|
MemUsed = KernelAllocator.GetUsedMemory();
|
||||||
|
MemTotal = KernelAllocator.GetTotalMemory();
|
||||||
|
MemReserved = KernelAllocator.GetReservedMemory();
|
||||||
|
int MemPercent = (MemUsed * 100) / MemTotal;
|
||||||
|
sprintf(TicksText, "%ldMB / %ldGB (%ldMB reserved) %d%%", TO_MB(MemUsed), TO_GB(MemTotal), TO_MB(MemReserved), MemPercent);
|
||||||
|
wdgDbgWin->SetText(MemLblHnd, TicksText);
|
||||||
|
RefreshCounter = 100;
|
||||||
|
}
|
||||||
|
sprintf(TicksText, "Debug - %ldx%ld", DbgWin->GetPosition().Width, DbgWin->GetPosition().Height);
|
||||||
|
DbgWin->SetTitle(TicksText);
|
||||||
|
TaskManager->Sleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +80,6 @@ namespace Recovery
|
|||||||
|
|
||||||
gui = new GraphicalUserInterface::GUI;
|
gui = new GraphicalUserInterface::GUI;
|
||||||
|
|
||||||
// TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (IP)RecoveryThreadWrapper);
|
|
||||||
TCB *guiThread = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (IP)GUIWrapper);
|
TCB *guiThread = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (IP)GUIWrapper);
|
||||||
guiThread->Rename("GUI Thread");
|
guiThread->Rename("GUI Thread");
|
||||||
guiThread->SetPriority(Tasking::TaskPriority::Critical);
|
guiThread->SetPriority(Tasking::TaskPriority::Critical);
|
||||||
@ -60,19 +93,22 @@ namespace Recovery
|
|||||||
gui->AddWindow(RecWin);
|
gui->AddWindow(RecWin);
|
||||||
|
|
||||||
WidgetCollection *wdgRecWin = new WidgetCollection(RecWin);
|
WidgetCollection *wdgRecWin = new WidgetCollection(RecWin);
|
||||||
GraphicalUserInterface::Handle SchedLblHnd = wdgRecWin->CreateLabel({10, 0, 0, 0}, "Scheduler Ticks: 0");
|
wdgRecWin->CreateLabel({80, 10, 0, 0}, "This is not fully implemented.");
|
||||||
wdgRecWin->CreateLabel({10, 20, 0, 0}, "This is not fully implemented.");
|
|
||||||
wdgRecWin->CreateLabel({10, 40, 0, 0}, "All you can do is shutdown/reboot the system.");
|
wdgRecWin->CreateLabel({10, 40, 0, 0}, "All you can do is shutdown/reboot the system.");
|
||||||
wdgRecWin->CreateButton({10, 70, 90, 20}, "Reboot", (uintptr_t)RebootCommandWrapper);
|
wdgRecWin->CreateButton({10, 70, 90, 20}, "Reboot", (uintptr_t)RebootCommandWrapper);
|
||||||
wdgRecWin->CreateButton({110, 70, 90, 20}, "Shutdown", (uintptr_t)ShutdownCommandWrapper);
|
wdgRecWin->CreateButton({110, 70, 90, 20}, "Shutdown", (uintptr_t)ShutdownCommandWrapper);
|
||||||
RecWin->AddWidget(wdgRecWin);
|
RecWin->AddWidget(wdgRecWin);
|
||||||
|
|
||||||
char TicksText[128];
|
Rect DebugWindow;
|
||||||
while (true)
|
DebugWindow.Width = 370;
|
||||||
{
|
DebugWindow.Height = 100;
|
||||||
sprintf(TicksText, "%016ld / %016ld - Sched. / Last Task Ticks", TaskManager->GetSchedulerTicks(), TaskManager->GetLastTaskTicks());
|
DebugWindow.Left = 25;
|
||||||
wdgRecWin->SetText(SchedLblHnd, TicksText);
|
DebugWindow.Top = 25;
|
||||||
}
|
DbgWin = new Window(gui, DebugWindow, "Debug");
|
||||||
|
gui->AddWindow(DbgWin);
|
||||||
|
|
||||||
|
wdgDbgWin = new WidgetCollection(DbgWin);
|
||||||
|
TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (IP)RecoveryThreadWrapper)->SetPriority(Tasking::TaskPriority::Idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
KernelRecovery::~KernelRecovery()
|
KernelRecovery::~KernelRecovery()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user