Refactor filesystem & stl code

This commit is contained in:
EnderIce2
2024-05-18 07:42:01 +03:00
parent 77a291d08b
commit 6801475243
186 changed files with 15784 additions and 9746 deletions

View File

@ -65,7 +65,7 @@ struct DiagnosticFile
} Data;
};
nsa bool WriteDiagDataToNode(vfs::RefNode *refFile)
nsa bool WriteDiagDataToNode(FileNode *node)
{
uintptr_t KStart = (uintptr_t)&_kernel_start;
uintptr_t kEnd = (uintptr_t)&_kernel_end;
@ -89,8 +89,8 @@ nsa bool WriteDiagDataToNode(vfs::RefNode *refFile)
file->Data.KernelMemoryLength = uint32_t(kSize);
memcpy(file->Data.KernelMemory, (void *)KStart, kSize);
ExPrint("\eFAFAFAWriting to %s\n", refFile->node->FullPath);
size_t w = refFile->write(buf, fileSize);
ExPrint("\eFAFAFAWriting to %s\n", node->Path.c_str());
size_t w = node->Write(buf, fileSize, 0);
if (w != fileSize)
{
debug("%d out of %d bytes written", w, fileSize);
@ -111,7 +111,12 @@ nsa void DiagnosticDataCollection()
ExPrint("\n\eFAFAFAPlease wait while we collect some diagnostic information...\n");
ExPrint("This may take a while...\n");
vfs::Node *panicDir = fs->CreateIfNotExists("/var/panic", vfs::DIRECTORY);
mode_t mode = S_IRWXU |
S_IRWXG |
S_IROTH |
S_IFDIR;
FileNode *panicDir = fs->ForceCreate(nullptr, "/var/panic", mode);
if (!panicDir)
{
ExPrint("\eFF0000Failed to create /var/panic\n");
@ -119,6 +124,7 @@ nsa void DiagnosticDataCollection()
return;
}
FileNode *dumpFile;
Time::Clock clock = Time::ReadClock();
char filename[64];
for (int i = 0; i < INT32_MAX; i++)
@ -128,18 +134,18 @@ nsa void DiagnosticDataCollection()
if (fs->PathExists(filename, panicDir))
continue;
fs->Create(filename, vfs::FILE, panicDir);
mode = S_IRWXU |
S_IRWXG |
S_IROTH |
S_IFREG;
dumpFile = fs->Create(panicDir, filename, mode);
break;
}
vfs::RefNode *refFile = fs->Open(filename, panicDir);
if (!WriteDiagDataToNode(refFile))
{
delete refFile;
if (!WriteDiagDataToNode(dumpFile))
return;
}
ExPrint("You can find the diagnostic file in /var/panic/%s\n", filename);
Display->UpdateBuffer();
delete refFile;
}

View File

@ -517,7 +517,7 @@ nsa void DisplayStackScreen(CPU::ExceptionFrame *Frame)
sym, offset);
}
else
ExPrint("\eFF5555???\n");
ExPrint("\eFF5555??? \eFFAAAA<- Exception\n");
if (!sf || !sf->ip || !sf->bp)
{
@ -591,7 +591,7 @@ nsa void DisplayProcessScreen(CPU::ExceptionFrame *Frame, bool IgnoreReady = tru
if (Display->GetWidth > 800 && Display->GetHeight > 600)
textLimit = 128;
std::list<Tasking::PCB *> Plist = TaskManager->GetProcessList();
std::vector<Tasking::PCB *> Plist = TaskManager->GetProcessList();
ExPrint("\n\eFAFAFAProcess list (%ld):\n", Plist.size());
bool pRdy = false;
@ -626,7 +626,7 @@ nsa void DisplayProcessScreen(CPU::ExceptionFrame *Frame, bool IgnoreReady = tru
Process->ID, StatusColor[Process->State.load()],
StatusString[Process->State.load()],
Process->Executable
? Process->Executable->Name
? Process->Executable->Name.c_str()
: "none");
bool tRdy = false;
@ -766,6 +766,29 @@ nsa void DisplayAssertionFailed(const char *File, int Line, const char *Expressi
ExPrint(" This is a kernel bug.\n");
ExPrint(" Please create a new issue on \e00AAFFhttps://github.com/Fennix-Project/Fennix\eFAFAFA for further assistance.\n");
CPU::ExceptionFrame ef;
// Fill only the necessary fields
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wframe-address"
/* Jump over HandleAssertionFailed, and ip will be the function where it failed */
void *fun = __builtin_return_address(1);
/* Jump over this, HandleAssertionFailed & ip */
void *stk = __builtin_frame_address(2);
#pragma GCC diagnostic pop
#ifdef __x86_64__
asmv("movq %%cr3, %0" : "=r"(ef.cr3));
ef.rip = (uint64_t)fun;
ef.rbp = ef.rsp = (uint64_t)stk;
#elif defined(__i386__)
asmv("movl %%cr3, %0" : "=r"(ef.cr3));
ef.eip = (uint32_t)fun;
ef.ebp = ef.esp = (uint32_t)stk;
#endif
DisplayStackScreen(&ef);
Display->UpdateBuffer();
/* TODO: Add additional info */