mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 23:39:20 +00:00
Enable compilation of project on AArch64 architecture
This commit is contained in:
@ -195,7 +195,10 @@ SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame)
|
||||
#elif defined(a32)
|
||||
Memory::Virtual vma = Memory::Virtual(((Memory::PageTable4 *)CPU::x32::readcr3().raw));
|
||||
#elif defined(aa64)
|
||||
Memory::Virtual vma = Memory::Virtual();
|
||||
#warning "TODO: aa64"
|
||||
#endif
|
||||
|
||||
bool PageAvailable = vma.Check((void *)CheckPageFaultAddress);
|
||||
debug("Page available (Check(...)): %s. %s",
|
||||
PageAvailable ? "Yes" : "No",
|
||||
@ -240,6 +243,8 @@ SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame)
|
||||
#elif defined(a32)
|
||||
Memory::PageMapLevel4 PML4 = ((Memory::PageTable4 *)CPU::x32::readcr3().raw)->Entries[Index.PMLIndex];
|
||||
#elif defined(aa64)
|
||||
Memory::PageMapLevel4 PML4 = {.raw = 0};
|
||||
#warning "TODO: aa64"
|
||||
#endif
|
||||
|
||||
Memory::PageDirectoryPointerTableEntryPtr *PDPTE = (Memory::PageDirectoryPointerTableEntryPtr *)((uintptr_t)PML4.GetAddress() << 12);
|
||||
|
@ -375,8 +375,10 @@ namespace CrashHandler
|
||||
int tmpidx = SBIdx;
|
||||
SBIdx = atoi(arg);
|
||||
Display->SetBuffer(SBIdx);
|
||||
#if defined(a64) || defined(a32)
|
||||
for (int i = 0; i < 5000000; i++)
|
||||
inb(0x80);
|
||||
#endif // a64 || a32
|
||||
SBIdx = tmpidx;
|
||||
Display->SetBuffer(SBIdx);
|
||||
}
|
||||
@ -408,12 +410,15 @@ namespace CrashHandler
|
||||
#elif defined(a32)
|
||||
if ((uintptr_t)EHIntFrames[i] >= 0xC0000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
|
||||
#elif defined(aa64)
|
||||
if ((uintptr_t)EHIntFrames[i] >= 0xFFFFFFFF80000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
|
||||
#endif
|
||||
EHPrint("\e25CCC9%s", KernelSymbolTable->GetSymbolFromAddress((uintptr_t)EHIntFrames[i]));
|
||||
else
|
||||
EHPrint("\eFF4CA9Outside Kernel");
|
||||
#if defined(a64) || defined(a32)
|
||||
for (int i = 0; i < 20000; i++)
|
||||
inb(0x80);
|
||||
#endif // a64 || a32
|
||||
Display->SetBuffer(SBIdx);
|
||||
}
|
||||
}
|
||||
@ -619,6 +624,7 @@ namespace CrashHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(a64) || defined(a32)
|
||||
GlobalDescriptorTable::TaskStateSegment tss = GlobalDescriptorTable::tss[TSSIndex];
|
||||
EHPrint("\eFAFAFAStack Pointer 0: \eAABB22%#lx\n", tss.StackPointer[0]);
|
||||
EHPrint("\eFAFAFAStack Pointer 1: \eAABB22%#lx\n", tss.StackPointer[1]);
|
||||
@ -637,6 +643,9 @@ namespace CrashHandler
|
||||
EHPrint("\eFAFAFAReserved 0: \eAABB22%#lx\n", tss.Reserved0);
|
||||
EHPrint("\eFAFAFAReserved 1: \eAABB22%#lx\n", tss.Reserved1);
|
||||
EHPrint("\eFAFAFAReserved 2: \eAABB22%#lx\n", tss.Reserved2);
|
||||
#elif defined(aa64)
|
||||
EHPrint("\eFF0000AArch64 does not have TSS\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (strncmp(Input, "dump", 4) == 0)
|
||||
@ -1058,7 +1067,9 @@ namespace CrashHandler
|
||||
goto CrashEnd;
|
||||
|
||||
#elif defined(a32)
|
||||
goto CrashEnd;
|
||||
#elif defined(aa64)
|
||||
goto CrashEnd;
|
||||
#endif
|
||||
|
||||
CrashEnd:
|
||||
|
@ -96,6 +96,7 @@ namespace CrashHandler
|
||||
{
|
||||
CrashKeyboardDriver::CrashKeyboardDriver() : Interrupts::Handler(1) /* IRQ1 */
|
||||
{
|
||||
#if defined(a64) || defined(a32)
|
||||
while (inb(0x64) & 0x1)
|
||||
inb(0x60);
|
||||
|
||||
@ -108,6 +109,8 @@ namespace CrashHandler
|
||||
|
||||
outb(0x21, 0xFD);
|
||||
outb(0xA1, 0xFF);
|
||||
#endif // defined(a64) || defined(a32)
|
||||
|
||||
CPU::Interrupts(CPU::Enable); // Just to be sure.
|
||||
}
|
||||
|
||||
@ -124,9 +127,10 @@ namespace CrashHandler
|
||||
#elif defined(a32)
|
||||
SafeFunction void CrashKeyboardDriver::OnInterruptReceived(CPU::x32::TrapFrame *Frame)
|
||||
#elif defined(aa64)
|
||||
SafeFunction void CrashKeyboardDriver::OnInterruptReceived(void *Frame)
|
||||
SafeFunction void CrashKeyboardDriver::OnInterruptReceived(CPU::aarch64::TrapFrame *Frame)
|
||||
#endif
|
||||
{
|
||||
#if defined(a64) || defined(a32)
|
||||
UNUSED(Frame);
|
||||
uint8_t scanCode = inb(0x60);
|
||||
if (scanCode == KEY_D_TAB ||
|
||||
@ -174,12 +178,17 @@ namespace CrashHandler
|
||||
}
|
||||
Display->SetBuffer(SBIdx); // Update as we type.
|
||||
}
|
||||
#endif // a64 || a32
|
||||
}
|
||||
|
||||
SafeFunction void HookKeyboard()
|
||||
{
|
||||
CrashKeyboardDriver kbd; // We don't want to allocate memory.
|
||||
#if defined(a64) || defined(a32)
|
||||
asmv("KeyboardHookLoop: nop; jmp KeyboardHookLoop;");
|
||||
#elif defined(aa64)
|
||||
asmv("KeyboardHookLoop: nop; b KeyboardHookLoop;");
|
||||
#endif
|
||||
// CPU::Halt(true); // This is an infinite loop.
|
||||
}
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ namespace CrashHandler
|
||||
#elif defined(a32)
|
||||
if ((frames->rip >= 0xC0000000 && frames->rip <= (uintptr_t)&_kernel_end) || !Kernel)
|
||||
#elif defined(aa64)
|
||||
if ((frames->rip >= 0xFFFFFFFF80000000 && frames->rip <= (uintptr_t)&_kernel_end) || !Kernel)
|
||||
#endif
|
||||
EHPrint("\e25CCC9%s", SymHandle->GetSymbolFromAddress(frames->rip));
|
||||
else
|
||||
|
@ -86,6 +86,8 @@ namespace CrashHandler
|
||||
EHPrint("EIP=%#llx EFL=%#llx INT=%#llx ERR=%#llx EFER=%#llx\n", data.Frame->eip, data.Frame->eflags.raw, data.Frame->InterruptNumber, data.Frame->ErrorCode, data.efer.raw);
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#if defined(a64) || defined(a32)
|
||||
EHPrint("CR0=%#llx CR2=%#llx CR3=%#llx CR4=%#llx CR8=%#llx\n", data.cr0.raw, data.cr2.raw, data.cr3.raw, data.cr4.raw, data.cr8.raw);
|
||||
EHPrint("DR0=%#llx DR1=%#llx DR2=%#llx DR3=%#llx DR6=%#llx DR7=%#llx\n", data.dr0, data.dr1, data.dr2, data.dr3, data.dr6, data.dr7.raw);
|
||||
|
||||
@ -111,10 +113,9 @@ namespace CrashHandler
|
||||
data.cr4.Reserved0, data.cr4.Reserved1, data.cr4.Reserved2);
|
||||
#elif defined(a32)
|
||||
data.cr4.Reserved0, data.cr4.Reserved1, 0);
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
EHPrint("\e79FCF5CR8: TPL:%d\n", data.cr8.TPL);
|
||||
#endif // a64 || a32
|
||||
|
||||
#if defined(a64)
|
||||
EHPrint("\eFCFC02RFL: CF:%s PF:%s AF:%s ZF:%s\n SF:%s TF:%s IF:%s DF:%s\n OF:%s IOPL:%s NT:%s RF:%s\n VM:%s AC:%s VIF:%s VIP:%s\n ID:%s AlwaysOne:%d\n R0:%#x R1:%#x R2:%#x R3:%#x\n",
|
||||
@ -135,6 +136,7 @@ namespace CrashHandler
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#if defined(a64) || defined(a32)
|
||||
EHPrint("\eA0F0F0DR7: LDR0:%s GDR0:%s LDR1:%s GDR1:%s\n LDR2:%s GDR2:%s LDR3:%s GDR3:%s\n CDR0:%s SDR0:%s CDR1:%s SDR1:%s\n CDR2:%s SDR2:%s CDR3:%s SDR3:%s\n R:%#x\n",
|
||||
data.dr7.LocalDR0 ? "True " : "False", data.dr7.GlobalDR0 ? "True " : "False", data.dr7.LocalDR1 ? "True " : "False", data.dr7.GlobalDR1 ? "True " : "False",
|
||||
data.dr7.LocalDR2 ? "True " : "False", data.dr7.GlobalDR2 ? "True " : "False", data.dr7.LocalDR3 ? "True " : "False", data.dr7.GlobalDR3 ? "True " : "False",
|
||||
@ -146,6 +148,7 @@ namespace CrashHandler
|
||||
data.efer.SCE ? "True " : "False", data.efer.LME ? "True " : "False", data.efer.LMA ? "True " : "False", data.efer.NXE ? "True " : "False",
|
||||
data.efer.SVME ? "True " : "False", data.efer.LMSLE ? "True " : "False", data.efer.FFXSR ? "True " : "False", data.efer.TCE ? "True " : "False",
|
||||
data.efer.Reserved0, data.efer.Reserved1, data.efer.Reserved2);
|
||||
#endif
|
||||
|
||||
switch (data.Frame->InterruptNumber)
|
||||
{
|
||||
|
@ -62,6 +62,7 @@ namespace CrashHandler
|
||||
#elif defined(a32)
|
||||
if ((uintptr_t)EHIntFrames[i] >= 0xC0000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
|
||||
#elif defined(aa64)
|
||||
if ((uintptr_t)EHIntFrames[i] >= 0xFFFFFFFF80000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
|
||||
#endif
|
||||
EHPrint("\e25CCC9%s", KernelSymbolTable->GetSymbolFromAddress((uintptr_t)EHIntFrames[i]));
|
||||
else
|
||||
|
@ -98,6 +98,8 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
error("EIP=%#llx EFL=%#llx INT=%#llx ERR=%#llx EFER=%#llx", Frame->eip, Frame->eflags.raw, Frame->InterruptNumber, Frame->ErrorCode, efer.raw);
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#if defined(a64) || defined(a32)
|
||||
error("CR0=%#llx CR2=%#llx CR3=%#llx CR4=%#llx CR8=%#llx", cr0.raw, cr2.raw, cr3.raw, cr4.raw, cr8.raw);
|
||||
|
||||
error("CR0: PE:%s MP:%s EM:%s TS:%s ET:%s NE:%s WP:%s AM:%s NW:%s CD:%s PG:%s R0:%#x R1:%#x R2:%#x",
|
||||
@ -111,6 +113,7 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
|
||||
error("CR3: PWT:%s PCD:%s PDBR:%#llx",
|
||||
cr3.PWT ? "True " : "False", cr3.PCD ? "True " : "False", cr3.PDBR);
|
||||
#endif // defined(a64) || defined(a32)
|
||||
|
||||
#if defined(a64)
|
||||
error("CR4: VME:%s PVI:%s TSD:%s DE:%s PSE:%s PAE:%s MCE:%s PGE:%s PCE:%s UMIP:%s OSFXSR:%s OSXMMEXCPT:%s LA57:%s VMXE:%s SMXE:%s PCIDE:%s OSXSAVE:%s SMEP:%s SMAP:%s PKE:%s R0:%#x R1:%#x R2:%#x",
|
||||
@ -121,7 +124,7 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
cr4.OSXSAVE ? "True " : "False", cr4.SMEP ? "True " : "False", cr4.SMAP ? "True " : "False", cr4.PKE ? "True " : "False",
|
||||
cr4.Reserved0, cr4.Reserved1, cr4.Reserved2);
|
||||
#elif defined(a32)
|
||||
error("CR4: VME:%s PVI:%s TSD:%s DE:%s PSE:%s PAE:%s MCE:%s PGE:%s PCE:%s UMIP:%s OSFXSR:%s OSXMMEXCPT:%s LA57:%s VMXE:%s SMXE:%s PCIDE:%s OSXSAVE:%s SMEP:%s SMAP:%s PKE:%s R0:%#x R1:%#x",
|
||||
error("CR4: VME:%s PVI:%s TSD:%s DE:%s PSE:%s PAE:%s MCE:%s PGE:%s PCE:%s UMIP:%s OSFXSR:%s OSXMMEXCPT:%s LA57:%s VMXE:%s SMXE:%s PCIDE:%s OSXSAVE:%s SMEP:%s SMAP:%s PKE:%s R0:%#x R1:%#x",
|
||||
cr4.VME ? "True " : "False", cr4.PVI ? "True " : "False", cr4.TSD ? "True " : "False", cr4.DE ? "True " : "False",
|
||||
cr4.PSE ? "True " : "False", cr4.PAE ? "True " : "False", cr4.MCE ? "True " : "False", cr4.PGE ? "True " : "False",
|
||||
cr4.PCE ? "True " : "False", cr4.UMIP ? "True " : "False", cr4.OSFXSR ? "True " : "False", cr4.OSXMMEXCPT ? "True " : "False",
|
||||
@ -130,7 +133,9 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
cr4.Reserved0, cr4.Reserved1);
|
||||
#endif
|
||||
|
||||
#if defined(a64) || defined(a32)
|
||||
error("CR8: TPL:%d", cr8.TPL);
|
||||
#endif // defined(a64) || defined(a32)
|
||||
|
||||
#if defined(a64)
|
||||
error("RFL: CF:%s PF:%s AF:%s ZF:%s SF:%s TF:%s IF:%s DF:%s OF:%s IOPL:%s NT:%s RF:%s VM:%s AC:%s VIF:%s VIP:%s ID:%s AlwaysOne:%d R0:%#x R1:%#x R2:%#x R3:%#x",
|
||||
@ -151,10 +156,12 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#if defined(a64) || defined(a32)
|
||||
error("EFER: SCE:%s LME:%s LMA:%s NXE:%s SVME:%s LMSLE:%s FFXSR:%s TCE:%s R0:%#x R1:%#x R2:%#x",
|
||||
efer.SCE ? "True " : "False", efer.LME ? "True " : "False", efer.LMA ? "True " : "False", efer.NXE ? "True " : "False",
|
||||
efer.SVME ? "True " : "False", efer.LMSLE ? "True " : "False", efer.FFXSR ? "True " : "False", efer.TCE ? "True " : "False",
|
||||
efer.Reserved0, efer.Reserved1, efer.Reserved2);
|
||||
#endif // a64 || a32
|
||||
}
|
||||
|
||||
switch (Frame->InterruptNumber)
|
||||
|
@ -68,6 +68,15 @@ struct CRData
|
||||
};
|
||||
#elif defined(aa64)
|
||||
typedef struct CPU::aarch64::TrapFrame CHArchTrapFrame;
|
||||
|
||||
struct CRData
|
||||
{
|
||||
CHArchTrapFrame *Frame;
|
||||
|
||||
long ID;
|
||||
Tasking::PCB *Process;
|
||||
Tasking::TCB *Thread;
|
||||
};
|
||||
#endif
|
||||
|
||||
enum Keys
|
||||
@ -266,7 +275,7 @@ namespace CrashHandler
|
||||
#elif defined(a32)
|
||||
void OnInterruptReceived(CPU::x32::TrapFrame *Frame);
|
||||
#elif defined(aa64)
|
||||
void OnInterruptReceived(void *Frame);
|
||||
void OnInterruptReceived(CPU::aarch64::TrapFrame *Frame);
|
||||
#endif
|
||||
public:
|
||||
CrashKeyboardDriver();
|
||||
|
Reference in New Issue
Block a user