mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Added implementation of critical thread/process
This commit is contained in:
parent
954223cbf5
commit
3d947c2a03
@ -117,9 +117,14 @@ namespace CrashHandler
|
||||
else
|
||||
{
|
||||
debug("Exception in user mode");
|
||||
if (!GetCurrentCPU()->CurrentThread->Security.IsCritical)
|
||||
{
|
||||
UserModeExceptionHandler(Frame);
|
||||
return;
|
||||
}
|
||||
else
|
||||
EHPrint("\eFF0000Init process crashed!");
|
||||
}
|
||||
|
||||
debug("Reading control registers...");
|
||||
CPU::x64::CR0 cr0 = CPU::x64::readcr0();
|
||||
|
@ -81,6 +81,7 @@ void KernelMainThread()
|
||||
|
||||
// TODO: Untested!
|
||||
Execute::SpawnData ret = Execute::Spawn(Config.InitPath, argc, (uint64_t)argv.data());
|
||||
ret.Thread->SetCritical(true);
|
||||
if (ret.Status != Execute::ExStatus::OK)
|
||||
{
|
||||
KPrint("\eE85230Failed to start %s! Code: %d", Config.InitPath, ret);
|
||||
|
@ -624,12 +624,12 @@ namespace Tasking
|
||||
Thread->Registers.rsp = ((uint64_t)Thread->Stack + STACK_SIZE);
|
||||
/* We need to leave the libc's crt to make a syscall when the Thread is exited or we are going to get GPF or PF exception. */
|
||||
for (uint64_t i = 0; i < TO_PAGES(STACK_SIZE); i++)
|
||||
Memory::Virtual(Parent->PageTable).Map((void *)((uint64_t)Thread->Stack + (i * PAGE_SIZE)), (void *)((uint64_t)Thread->Stack + (i * PAGE_SIZE)), Memory::PTFlag::US);
|
||||
Memory::Virtual(Parent->PageTable).Map((void *)((uint64_t)Thread->Stack + (i * PAGE_SIZE)), (void *)((uint64_t)Thread->Stack + (i * PAGE_SIZE)), Memory::PTFlag::RW | Memory::PTFlag::US);
|
||||
|
||||
if (!Memory::Virtual(Parent->PageTable).Check((void *)Offset, Memory::PTFlag::US))
|
||||
{
|
||||
error("Offset is not user accessible");
|
||||
Memory::Virtual(Parent->PageTable).Map((void *)Offset, (void *)Offset, Memory::PTFlag::RW | Memory::PTFlag::US);
|
||||
Memory::Virtual(Parent->PageTable).Map((void *)Offset, (void *)Offset, Memory::PTFlag::RW | Memory::PTFlag::US); // We try one more time.
|
||||
}
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
|
@ -60,6 +60,7 @@ namespace Tasking
|
||||
{
|
||||
TaskTrustLevel TrustLevel;
|
||||
Token UniqueToken;
|
||||
bool IsCritical;
|
||||
};
|
||||
|
||||
struct TaskInfo
|
||||
@ -117,6 +118,12 @@ namespace Tasking
|
||||
}
|
||||
|
||||
int GetExitCode() { return ExitCode; }
|
||||
|
||||
void SetCritical(bool critical)
|
||||
{
|
||||
trace("Setting criticality of thread %s to %s", Name, critical ? "true" : "false");
|
||||
Security.IsCritical = critical;
|
||||
}
|
||||
};
|
||||
|
||||
struct PCB
|
||||
|
Loading…
x
Reference in New Issue
Block a user