Rework for APIC & added support for x2APIC

This commit is contained in:
Alex
2023-08-31 01:07:55 +03:00
parent 612e8cc726
commit 6d95cd5261
12 changed files with 510 additions and 377 deletions

View File

@ -525,7 +525,7 @@ namespace Tasking
else
{
CurrentCPU->CurrentThread->Registers = *Frame;
CPU::x64::fxsave(CurrentCPU->CurrentThread->FPU);
CPU::x64::fxsave(&CurrentCPU->CurrentThread->FPU);
CurrentCPU->CurrentThread->ShadowGSBase = CPU::x64::rdmsr(CPU::x64::MSR_SHADOW_GS_BASE);
CurrentCPU->CurrentThread->GSBase = CPU::x64::rdmsr(CPU::x64::MSR_GS_BASE);
CurrentCPU->CurrentThread->FSBase = CPU::x64::rdmsr(CPU::x64::MSR_FS_BASE);
@ -616,7 +616,7 @@ namespace Tasking
/* Not sure if this is needed, but it's better to be safe than sorry. */
asmv("movq %cr3, %rax");
asmv("movq %rax, %cr3");
CPU::x64::fxrstor(CurrentCPU->CurrentThread->FPU);
CPU::x64::fxrstor(&CurrentCPU->CurrentThread->FPU);
CPU::x64::wrmsr(CPU::x64::MSR_SHADOW_GS_BASE, CurrentCPU->CurrentThread->ShadowGSBase);
CPU::x64::wrmsr(CPU::x64::MSR_GS_BASE, CurrentCPU->CurrentThread->GSBase);
CPU::x64::wrmsr(CPU::x64::MSR_FS_BASE, CurrentCPU->CurrentThread->FSBase);

View File

@ -458,27 +458,10 @@ namespace Tasking
this->Security.ExecutionMode =
this->Parent->Security.ExecutionMode;
std::size_t FXPgs = TO_PAGES(sizeof(CPU::x64::FXState) + 1);
this->FPU = (CPU::x64::FXState *)this->Memory->RequestPages(FXPgs);
memset(this->FPU, 0, sizeof(CPU::x64::FXState));
// TODO: Is really a good idea to use the FPU in kernel mode?
this->FPU->mxcsr = 0b0001111110000000;
this->FPU->mxcsrmask = 0b1111111110111111;
this->FPU->fcw = 0b0000001100111111;
// CPU::x64::fxrstor(this->FPU);
// uint16_t FCW = 0b1100111111;
// asmv("fldcw %0"
// :
// : "m"(FCW)
// : "memory");
// uint32_t MXCSR = 0b1111110000000;
// asmv("ldmxcsr %0"
// :
// : "m"(MXCSR)
// : "memory");
// CPU::x64::fxsave(this->FPU);
this->FPU.mxcsr = 0b0001111110000000;
this->FPU.mxcsrmask = 0b1111111110111111;
this->FPU.fcw = 0b0000001100111111;
#ifdef DEBUG
#ifdef a64