mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 15:29:18 +00:00
x32 is now compiling
This commit is contained in:
@ -7,10 +7,10 @@
|
||||
#include <smp.hpp>
|
||||
#include <cpu.hpp>
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
#include "../../Architecture/amd64/cpu/gdt.hpp"
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../kernel.h"
|
||||
@ -100,11 +100,11 @@ SafeFunction void SegmentNotPresentExceptionHandler(CHArchTrapFrame *Frame)
|
||||
SafeFunction void StackFaultExceptionHandler(CHArchTrapFrame *Frame)
|
||||
{
|
||||
CPU::x64::SelectorErrorCode SelCode = {.raw = Frame->ErrorCode};
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
CrashHandler::EHPrint("Stack segment fault at address %#lx\n", Frame->rip);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
CrashHandler::EHPrint("Stack segment fault at address %#lx\n", Frame->eip);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
CrashHandler::EHPrint("External: %d\n", SelCode.External);
|
||||
CrashHandler::EHPrint("Table: %d\n", SelCode.Table);
|
||||
@ -142,11 +142,11 @@ SafeFunction void GeneralProtectionExceptionHandler(CHArchTrapFrame *Frame)
|
||||
SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame)
|
||||
{
|
||||
CPU::x64::PageFaultErrorCode params = {.raw = (uint32_t)Frame->ErrorCode};
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
CrashHandler::EHPrint("\eAFAFAFAn exception occurred at %#lx by %#lx\n", CrashHandler::PageFaultAddress, Frame->rip);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
CrashHandler::EHPrint("\eAFAFAFAn exception occurred at %#lx by %#lx\n", CrashHandler::PageFaultAddress, Frame->eip);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
CrashHandler::EHPrint("Page: %s\n", params.P ? "Present" : "Not Present");
|
||||
CrashHandler::EHPrint("Write Operation: %s\n", params.W ? "Read-Only" : "Read-Write");
|
||||
@ -165,15 +165,20 @@ SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame)
|
||||
uintptr_t CheckPageFaultAddress = 0;
|
||||
CheckPageFaultAddress = CrashHandler::PageFaultAddress;
|
||||
if (CheckPageFaultAddress == 0)
|
||||
#ifdef __amd64__
|
||||
#ifdef a64
|
||||
CheckPageFaultAddress = Frame->rip;
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
CheckPageFaultAddress = Frame->eip;
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
CheckPageFaultAddress = 0;
|
||||
#endif
|
||||
|
||||
#if defined(a64)
|
||||
Memory::Virtual vma = Memory::Virtual(((Memory::PageTable4 *)CPU::x64::readcr3().raw));
|
||||
#elif defined(a32)
|
||||
Memory::Virtual vma = Memory::Virtual(((Memory::PageTable4 *)CPU::x32::readcr3().raw));
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
bool PageAvailable = vma.Check((void *)CheckPageFaultAddress);
|
||||
debug("Page available (Check(...)): %s. %s",
|
||||
PageAvailable ? "Yes" : "No",
|
||||
@ -213,7 +218,12 @@ SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame)
|
||||
Index.PDPTEIndex,
|
||||
Index.PDEIndex,
|
||||
Index.PTEIndex);
|
||||
#if defined(a64)
|
||||
Memory::PageMapLevel4 PML4 = ((Memory::PageTable4 *)CPU::x64::readcr3().raw)->Entries[Index.PMLIndex];
|
||||
#elif defined(a32)
|
||||
Memory::PageMapLevel4 PML4 = ((Memory::PageTable4 *)CPU::x32::readcr3().raw)->Entries[Index.PMLIndex];
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
Memory::PageDirectoryPointerTableEntryPtr *PDPTE = (Memory::PageDirectoryPointerTableEntryPtr *)((uintptr_t)PML4.GetAddress() << 12);
|
||||
Memory::PageDirectoryEntryPtr *PDE = (Memory::PageDirectoryEntryPtr *)((uintptr_t)PDPTE->Entries[Index.PDPTEIndex].GetAddress() << 12);
|
||||
|
@ -13,13 +13,13 @@
|
||||
#include <cpu.hpp>
|
||||
#include <io.h>
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
#include "../../Architecture/amd64/cpu/gdt.hpp"
|
||||
#include "../Architecture/amd64/cpu/apic.hpp"
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
#include "../../Architecture/i686/cpu/gdt.hpp"
|
||||
#include "../Architecture/i686/cpu/apic.hpp"
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../kernel.h"
|
||||
@ -386,11 +386,11 @@ namespace CrashHandler
|
||||
continue;
|
||||
EHPrint("\n\e2565CC%p", EHIntFrames[i]);
|
||||
EHPrint("\e7925CC-");
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
if ((uintptr_t)EHIntFrames[i] >= 0xFFFFFFFF80000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
if ((uintptr_t)EHIntFrames[i] >= 0xC0000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
EHPrint("\e25CCC9%s", KernelSymbolTable->GetSymbolFromAddress((uintptr_t)EHIntFrames[i]));
|
||||
else
|
||||
@ -543,20 +543,50 @@ namespace CrashHandler
|
||||
switch (cr[0])
|
||||
{
|
||||
case '0':
|
||||
{
|
||||
#if defined(a64)
|
||||
EHPrint("\e44AA000: %#lx\n", CPU::x64::readcr0());
|
||||
#elif defined(a32)
|
||||
EHPrint("\e44AA000: %#lx\n", CPU::x32::readcr0());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case '2':
|
||||
{
|
||||
#if defined(a64)
|
||||
EHPrint("\e44AA002: %#lx\n", PageFaultAddress);
|
||||
#elif defined(a32)
|
||||
EHPrint("\e44AA002: %#lx\n", CPU::x32::readcr2());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case '3':
|
||||
{
|
||||
#if defined(a64)
|
||||
EHPrint("\e44AA003: %#lx\n", CPU::x64::readcr3());
|
||||
#elif defined(a32)
|
||||
EHPrint("\e44AA003: %#lx\n", CPU::x32::readcr3());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case '4':
|
||||
{
|
||||
#if defined(a64)
|
||||
EHPrint("\e44AA004: %#lx\n", CPU::x64::readcr4());
|
||||
#elif defined(a32)
|
||||
EHPrint("\e44AA004: %#lx\n", CPU::x32::readcr4());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case '8':
|
||||
{
|
||||
#if defined(a64)
|
||||
EHPrint("\e44AA008: %#lx\n", CPU::x64::readcr8());
|
||||
#elif defined(a32)
|
||||
EHPrint("\e44AA008: %#lx\n", CPU::x32::readcr8());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
EHPrint("\eFF0000Invalid CR\n");
|
||||
break;
|
||||
@ -723,7 +753,7 @@ namespace CrashHandler
|
||||
|
||||
SafeFunction void StopAllCores()
|
||||
{
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
#if defined(a64) || defined(a32)
|
||||
/* FIXME: Can't send IPIs to other cores
|
||||
* because it causes another exception on
|
||||
* the other cores.
|
||||
@ -751,7 +781,7 @@ namespace CrashHandler
|
||||
__sync;
|
||||
CPU::Interrupts(CPU::Disable);
|
||||
// }
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -761,7 +791,7 @@ namespace CrashHandler
|
||||
CPU::Interrupts(CPU::Disable);
|
||||
SBIdx = 255;
|
||||
CHArchTrapFrame *Frame = (CHArchTrapFrame *)Data;
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
error("An exception occurred!");
|
||||
error("Exception: %#llx", Frame->InterruptNumber);
|
||||
for (size_t i = 0; i < INT_FRAMES_MAX; i++)
|
||||
@ -998,8 +1028,8 @@ namespace CrashHandler
|
||||
}
|
||||
goto CrashEnd;
|
||||
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
CrashEnd:
|
||||
|
@ -9,10 +9,10 @@
|
||||
#include <cpu.hpp>
|
||||
#include <io.h>
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
#include "../../Architecture/amd64/cpu/gdt.hpp"
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../kernel.h"
|
||||
@ -102,11 +102,11 @@ namespace CrashHandler
|
||||
int BackSpaceLimit = 0;
|
||||
static char UserInputBuffer[1024];
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
SafeFunction void CrashKeyboardDriver::OnInterruptReceived(CPU::x64::TrapFrame *Frame)
|
||||
#elif defined(__i386__)
|
||||
SafeFunction void CrashKeyboardDriver::OnInterruptReceived(void *Frame)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
SafeFunction void CrashKeyboardDriver::OnInterruptReceived(CPU::x32::TrapFrame *Frame)
|
||||
#elif defined(aa64)
|
||||
SafeFunction void CrashKeyboardDriver::OnInterruptReceived(void *Frame)
|
||||
#endif
|
||||
{
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include <smp.hpp>
|
||||
#include <cpu.hpp>
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
#include "../../Architecture/amd64/cpu/gdt.hpp"
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../kernel.h"
|
||||
@ -31,20 +31,20 @@ namespace CrashHandler
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
struct StackFrame *frames = (struct StackFrame *)Frame->rbp; // (struct StackFrame *)__builtin_frame_address(0);
|
||||
if (!Memory::Virtual().Check((void *)Frame->rbp))
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
struct StackFrame *frames = (struct StackFrame *)Frame->ebp; // (struct StackFrame *)__builtin_frame_address(0);
|
||||
if (!Memory::Virtual().Check((void *)Frame->ebp))
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
EHPrint("Invalid rbp pointer: %p\n", Frame->rbp);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
EHPrint("Invalid ebp pointer: %p\n", Frame->ebp);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -59,39 +59,39 @@ namespace CrashHandler
|
||||
EHPrint("\e7981FC\nStack Trace:\n");
|
||||
if (!frames || !frames->rip || !frames->rbp)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
EHPrint("\e2565CC%p", (void *)Frame->rip);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
EHPrint("\e2565CC%p", (void *)Frame->eip);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
EHPrint("\e7925CC-");
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
EHPrint("\eAA25CC%s", SymHandle->GetSymbolFromAddress(Frame->rip));
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
EHPrint("\eAA25CC%s", SymHandle->GetSymbolFromAddress(Frame->eip));
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
EHPrint("\e7981FC <- Exception");
|
||||
EHPrint("\eFF0000\n< No stack trace available. >\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
EHPrint("\e2565CC%p", (void *)Frame->rip);
|
||||
EHPrint("\e7925CC-");
|
||||
if ((Frame->rip >= 0xFFFFFFFF80000000 && Frame->rip <= (uintptr_t)&_kernel_end) || !Kernel)
|
||||
EHPrint("\eAA25CC%s", SymHandle->GetSymbolFromAddress(Frame->rip));
|
||||
else
|
||||
EHPrint("Outside Kernel");
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
EHPrint("\e2565CC%p", (void *)Frame->eip);
|
||||
EHPrint("\e7925CC-");
|
||||
if ((Frame->eip >= 0xC0000000 && Frame->eip <= (uintptr_t)&_kernel_end) || !Kernel)
|
||||
EHPrint("\eAA25CC%s", SymHandle->GetSymbolFromAddress(Frame->eip));
|
||||
else
|
||||
EHPrint("Outside Kernel");
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
EHPrint("\e7981FC <- Exception");
|
||||
for (int frame = 0; frame < Count; ++frame)
|
||||
@ -100,11 +100,11 @@ namespace CrashHandler
|
||||
break;
|
||||
EHPrint("\n\e2565CC%p", (void *)frames->rip);
|
||||
EHPrint("\e7925CC-");
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
if ((frames->rip >= 0xFFFFFFFF80000000 && frames->rip <= (uintptr_t)&_kernel_end) || !Kernel)
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
if ((frames->rip >= 0xC0000000 && frames->rip <= (uintptr_t)&_kernel_end) || !Kernel)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
EHPrint("\e25CCC9%s", SymHandle->GetSymbolFromAddress(frames->rip));
|
||||
else
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include <smp.hpp>
|
||||
#include <cpu.hpp>
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
#include "../../../Architecture/amd64/cpu/gdt.hpp"
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../../kernel.h"
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include <smp.hpp>
|
||||
#include <cpu.hpp>
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
#include "../../../Architecture/amd64/cpu/gdt.hpp"
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../../kernel.h"
|
||||
@ -29,7 +29,7 @@ namespace CrashHandler
|
||||
data.Thread->ID);
|
||||
EHPrint("\e7981FCTechnical Informations on CPU %lld:\n", data.ID);
|
||||
uintptr_t ds;
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
|
||||
CPUData *cpu = (CPUData *)data.CPUData;
|
||||
if (cpu)
|
||||
@ -45,26 +45,29 @@ namespace CrashHandler
|
||||
|
||||
asmv("mov %%ds, %0"
|
||||
: "=r"(ds));
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
asmv("mov %%ds, %0"
|
||||
: "=r"(ds));
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#if defined(a64)
|
||||
EHPrint("\e7981FCFS=%#llx GS=%#llx SS=%#llx CS=%#llx DS=%#llx\n",
|
||||
CPU::x64::rdmsr(CPU::x64::MSR_FS_BASE), CPU::x64::rdmsr(CPU::x64::MSR_GS_BASE),
|
||||
data.Frame->ss, data.Frame->cs, ds);
|
||||
#if defined(__amd64__)
|
||||
EHPrint("R8=%#llx R9=%#llx R10=%#llx R11=%#llx\n", data.Frame->r8, data.Frame->r9, data.Frame->r10, data.Frame->r11);
|
||||
EHPrint("R12=%#llx R13=%#llx R14=%#llx R15=%#llx\n", data.Frame->r12, data.Frame->r13, data.Frame->r14, data.Frame->r15);
|
||||
EHPrint("RAX=%#llx RBX=%#llx RCX=%#llx RDX=%#llx\n", data.Frame->rax, data.Frame->rbx, data.Frame->rcx, data.Frame->rdx);
|
||||
EHPrint("RSI=%#llx RDI=%#llx RBP=%#llx RSP=%#llx\n", data.Frame->rsi, data.Frame->rdi, data.Frame->rbp, data.Frame->rsp);
|
||||
EHPrint("RIP=%#llx RFL=%#llx INT=%#llx ERR=%#llx EFER=%#llx\n", data.Frame->rip, data.Frame->rflags.raw, data.Frame->InterruptNumber, data.Frame->ErrorCode, data.efer.raw);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
EHPrint("\e7981FCFS=%#llx GS=%#llx SS=%#llx CS=%#llx DS=%#llx\n",
|
||||
CPU::x32::rdmsr(CPU::x32::MSR_FS_BASE), CPU::x32::rdmsr(CPU::x32::MSR_GS_BASE),
|
||||
data.Frame->ss, data.Frame->cs, ds);
|
||||
EHPrint("EAX=%#llx EBX=%#llx ECX=%#llx EDX=%#llx\n", data.Frame->eax, data.Frame->ebx, data.Frame->ecx, data.Frame->edx);
|
||||
EHPrint("ESI=%#llx EDI=%#llx EBP=%#llx ESP=%#llx\n", data.Frame->esi, data.Frame->edi, data.Frame->ebp, data.Frame->esp);
|
||||
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(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
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);
|
||||
@ -87,16 +90,16 @@ namespace CrashHandler
|
||||
data.cr4.PCE ? "True " : "False", data.cr4.UMIP ? "True " : "False", data.cr4.OSFXSR ? "True " : "False", data.cr4.OSXMMEXCPT ? "True " : "False",
|
||||
data.cr4.LA57 ? "True " : "False", data.cr4.VMXE ? "True " : "False", data.cr4.SMXE ? "True " : "False", data.cr4.PCIDE ? "True " : "False",
|
||||
data.cr4.OSXSAVE ? "True " : "False", data.cr4.SMEP ? "True " : "False", data.cr4.SMAP ? "True " : "False", data.cr4.PKE ? "True " : "False",
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
data.cr4.Reserved0, data.cr4.Reserved1, data.cr4.Reserved2);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
data.cr4.Reserved0, data.cr4.Reserved1, 0);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
EHPrint("\e79FCF5CR8: TPL:%d\n", data.cr8.TPL);
|
||||
|
||||
#if defined(__amd64__)
|
||||
#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",
|
||||
data.Frame->rflags.CF ? "True " : "False", data.Frame->rflags.PF ? "True " : "False", data.Frame->rflags.AF ? "True " : "False", data.Frame->rflags.ZF ? "True " : "False",
|
||||
data.Frame->rflags.SF ? "True " : "False", data.Frame->rflags.TF ? "True " : "False", data.Frame->rflags.IF ? "True " : "False", data.Frame->rflags.DF ? "True " : "False",
|
||||
@ -104,7 +107,7 @@ namespace CrashHandler
|
||||
data.Frame->rflags.VM ? "True " : "False", data.Frame->rflags.AC ? "True " : "False", data.Frame->rflags.VIF ? "True " : "False", data.Frame->rflags.VIP ? "True " : "False",
|
||||
data.Frame->rflags.ID ? "True " : "False", data.Frame->rflags.AlwaysOne,
|
||||
data.Frame->rflags.Reserved0, data.Frame->rflags.Reserved1, data.Frame->rflags.Reserved2, data.Frame->rflags.Reserved3);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
EHPrint("\eFCFC02EFL: 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\n",
|
||||
data.Frame->eflags.CF ? "True " : "False", data.Frame->eflags.PF ? "True " : "False", data.Frame->eflags.AF ? "True " : "False", data.Frame->eflags.ZF ? "True " : "False",
|
||||
data.Frame->eflags.SF ? "True " : "False", data.Frame->eflags.TF ? "True " : "False", data.Frame->eflags.IF ? "True " : "False", data.Frame->eflags.DF ? "True " : "False",
|
||||
@ -112,7 +115,7 @@ namespace CrashHandler
|
||||
data.Frame->eflags.VM ? "True " : "False", data.Frame->eflags.AC ? "True " : "False", data.Frame->eflags.VIF ? "True " : "False", data.Frame->eflags.VIP ? "True " : "False",
|
||||
data.Frame->eflags.ID ? "True " : "False", data.Frame->eflags.AlwaysOne,
|
||||
data.Frame->eflags.Reserved0, data.Frame->eflags.Reserved1, data.Frame->eflags.Reserved2);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
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",
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include <smp.hpp>
|
||||
#include <cpu.hpp>
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
#include "../../../Architecture/amd64/cpu/gdt.hpp"
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../../kernel.h"
|
||||
@ -269,11 +269,11 @@ namespace CrashHandler
|
||||
EHPrint("The processor attempted to access a page that is not present.\n");
|
||||
|
||||
CPU::x64::PageFaultErrorCode params = {.raw = (uint32_t)Frame->ErrorCode};
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
EHPrint("At \e8888FF%#lx \eFAFAFAby \e8888FF%#lx\eFAFAFA\n", PageFaultAddress, Frame->rip);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
EHPrint("At \e8888FF%#lx \eFAFAFAby \e8888FF%#lx\eFAFAFA\n", PageFaultAddress, Frame->eip);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
EHPrint("Page: %s\eFAFAFA\n", params.P ? "\e058C19Present" : "\eE85230Not Present");
|
||||
EHPrint("Write Operation: \e8888FF%s\eFAFAFA\n", params.W ? "Read-Only" : "Read-Write");
|
||||
@ -335,11 +335,11 @@ namespace CrashHandler
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
EHPrint("The exception happened at \e8888FF%#lx\eFAFAFA\n", Frame->rip);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
EHPrint("The exception happened at \e8888FF%#lx\eFAFAFA\n", Frame->eip);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
#include <smp.hpp>
|
||||
#include <cpu.hpp>
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
#include "../../../Architecture/amd64/cpu/gdt.hpp"
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../../kernel.h"
|
||||
@ -40,11 +40,11 @@ namespace CrashHandler
|
||||
continue;
|
||||
EHPrint("\n\e2565CC%p", EHIntFrames[i]);
|
||||
EHPrint("\e7925CC-");
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
if ((uintptr_t)EHIntFrames[i] >= 0xFFFFFFFF80000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
if ((uintptr_t)EHIntFrames[i] >= 0xC0000000 && (uintptr_t)EHIntFrames[i] <= (uintptr_t)&_kernel_end)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
EHPrint("\e25CCC9%s", KernelSymbolTable->GetSymbolFromAddress((uintptr_t)EHIntFrames[i]));
|
||||
else
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include <smp.hpp>
|
||||
#include <cpu.hpp>
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
#include "../../../Architecture/amd64/cpu/gdt.hpp"
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../../kernel.h"
|
||||
@ -44,11 +44,11 @@ namespace CrashHandler
|
||||
if (TaskManager)
|
||||
{
|
||||
if (data.Thread)
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
EHPrint("\eFAFAFACrash occurred in thread \eAA0F0F%s\eFAFAFA(%ld) at \e00AAAA%#lx\n", data.Thread->Name, data.Thread->ID, data.Frame->rip);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
EHPrint("\eFAFAFACrash occurred in thread \eAA0F0F%s\eFAFAFA(%ld) at \e00AAAA%#lx\n", data.Thread->Name, data.Thread->ID, data.Frame->eip);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
EHPrint("\eFAFAFAProcess list (%ld):\n", Plist.size());
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include <smp.hpp>
|
||||
#include <cpu.hpp>
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
#include "../../Architecture/amd64/cpu/gdt.hpp"
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#include "../../kernel.h"
|
||||
@ -34,6 +34,7 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
CPUData *CurCPU = GetCurrentCPU();
|
||||
|
||||
{
|
||||
#if defined(a64)
|
||||
CPU::x64::CR0 cr0 = CPU::x64::readcr0();
|
||||
CPU::x64::CR2 cr2 = CPU::x64::CR2{.PFLA = CrashHandler::PageFaultAddress};
|
||||
CPU::x64::CR3 cr3 = CPU::x64::readcr3();
|
||||
@ -44,28 +45,41 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
|
||||
error("Technical Informations on CPU %lld:", CurCPU->ID);
|
||||
uintptr_t ds;
|
||||
#if defined(__amd64__)
|
||||
asmv("mov %%ds, %0"
|
||||
: "=r"(ds));
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
CPU::x32::CR0 cr0 = CPU::x32::readcr0();
|
||||
CPU::x32::CR2 cr2 = CPU::x32::CR2{.PFLA = CrashHandler::PageFaultAddress};
|
||||
CPU::x32::CR3 cr3 = CPU::x32::readcr3();
|
||||
CPU::x32::CR4 cr4 = CPU::x32::readcr4();
|
||||
CPU::x32::CR8 cr8 = CPU::x32::readcr8();
|
||||
CPU::x32::EFER efer;
|
||||
efer.raw = CPU::x32::rdmsr(CPU::x32::MSR_EFER);
|
||||
|
||||
error("Technical Informations on CPU %lld:", CurCPU->ID);
|
||||
uintptr_t ds;
|
||||
asmv("mov %%ds, %0"
|
||||
: "=r"(ds));
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
#if defined(a64)
|
||||
error("FS=%#llx GS=%#llx SS=%#llx CS=%#llx DS=%#llx",
|
||||
CPU::x64::rdmsr(CPU::x64::MSR_FS_BASE), CPU::x64::rdmsr(CPU::x64::MSR_GS_BASE),
|
||||
Frame->ss, Frame->cs, ds);
|
||||
#if defined(__amd64__)
|
||||
error("R8=%#llx R9=%#llx R10=%#llx R11=%#llx", Frame->r8, Frame->r9, Frame->r10, Frame->r11);
|
||||
error("R12=%#llx R13=%#llx R14=%#llx R15=%#llx", Frame->r12, Frame->r13, Frame->r14, Frame->r15);
|
||||
error("RAX=%#llx RBX=%#llx RCX=%#llx RDX=%#llx", Frame->rax, Frame->rbx, Frame->rcx, Frame->rdx);
|
||||
error("RSI=%#llx RDI=%#llx RBP=%#llx RSP=%#llx", Frame->rsi, Frame->rdi, Frame->rbp, Frame->rsp);
|
||||
error("RIP=%#llx RFL=%#llx INT=%#llx ERR=%#llx EFER=%#llx", Frame->rip, Frame->rflags.raw, Frame->InterruptNumber, Frame->ErrorCode, efer.raw);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
error("FS=%#llx GS=%#llx SS=%#llx CS=%#llx DS=%#llx",
|
||||
CPU::x32::rdmsr(CPU::x32::MSR_FS_BASE), CPU::x32::rdmsr(CPU::x32::MSR_GS_BASE),
|
||||
Frame->ss, Frame->cs, ds);
|
||||
error("EAX=%#llx EBX=%#llx ECX=%#llx EDX=%#llx", Frame->eax, Frame->ebx, Frame->ecx, Frame->edx);
|
||||
error("ESI=%#llx EDI=%#llx EBP=%#llx ESP=%#llx", Frame->esi, Frame->edi, Frame->ebp, Frame->esp);
|
||||
error("EIP=%#llx EFL=%#llx INT=%#llx ERR=%#llx EFER=%#llx", Frame->eip, Frame->eflags.raw, Frame->InterruptNumber, Frame->ErrorCode, efer.raw);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
error("CR0=%#llx CR2=%#llx CR3=%#llx CR4=%#llx CR8=%#llx", cr0.raw, cr2.raw, cr3.raw, cr4.raw, cr8.raw);
|
||||
|
||||
@ -81,6 +95,7 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
error("CR3: PWT:%s PCD:%s PDBR:%#llx",
|
||||
cr3.PWT ? "True " : "False", cr3.PCD ? "True " : "False", cr3.PDBR);
|
||||
|
||||
#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",
|
||||
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",
|
||||
@ -88,10 +103,19 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
cr4.LA57 ? "True " : "False", cr4.VMXE ? "True " : "False", cr4.SMXE ? "True " : "False", cr4.PCIDE ? "True " : "False",
|
||||
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",
|
||||
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",
|
||||
cr4.LA57 ? "True " : "False", cr4.VMXE ? "True " : "False", cr4.SMXE ? "True " : "False", cr4.PCIDE ? "True " : "False",
|
||||
cr4.OSXSAVE ? "True " : "False", cr4.SMEP ? "True " : "False", cr4.SMAP ? "True " : "False", cr4.PKE ? "True " : "False",
|
||||
cr4.Reserved0, cr4.Reserved1);
|
||||
#endif
|
||||
|
||||
error("CR8: TPL:%d", cr8.TPL);
|
||||
|
||||
#if defined(__amd64__)
|
||||
#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",
|
||||
Frame->rflags.CF ? "True " : "False", Frame->rflags.PF ? "True " : "False", Frame->rflags.AF ? "True " : "False", Frame->rflags.ZF ? "True " : "False",
|
||||
Frame->rflags.SF ? "True " : "False", Frame->rflags.TF ? "True " : "False", Frame->rflags.IF ? "True " : "False", Frame->rflags.DF ? "True " : "False",
|
||||
@ -99,7 +123,7 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
Frame->rflags.VM ? "True " : "False", Frame->rflags.AC ? "True " : "False", Frame->rflags.VIF ? "True " : "False", Frame->rflags.VIP ? "True " : "False",
|
||||
Frame->rflags.ID ? "True " : "False", Frame->rflags.AlwaysOne,
|
||||
Frame->rflags.Reserved0, Frame->rflags.Reserved1, Frame->rflags.Reserved2, Frame->rflags.Reserved3);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
error("EFL: 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",
|
||||
Frame->eflags.CF ? "True " : "False", Frame->eflags.PF ? "True " : "False", Frame->eflags.AF ? "True " : "False", Frame->eflags.ZF ? "True " : "False",
|
||||
Frame->eflags.SF ? "True " : "False", Frame->eflags.TF ? "True " : "False", Frame->eflags.IF ? "True " : "False", Frame->eflags.DF ? "True " : "False",
|
||||
@ -107,7 +131,7 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
Frame->eflags.VM ? "True " : "False", Frame->eflags.AC ? "True " : "False", Frame->eflags.VIF ? "True " : "False", Frame->eflags.VIP ? "True " : "False",
|
||||
Frame->eflags.ID ? "True " : "False", Frame->eflags.AlwaysOne,
|
||||
Frame->eflags.Reserved0, Frame->eflags.Reserved1, Frame->eflags.Reserved2);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
|
||||
error("EFER: SCE:%s LME:%s LMA:%s NXE:%s SVME:%s LMSLE:%s FFXSR:%s TCE:%s R0:%#x R1:%#x R2:%#x",
|
||||
@ -178,15 +202,15 @@ SafeFunction void UserModeExceptionHandler(CHArchTrapFrame *Frame)
|
||||
{
|
||||
uintptr_t CheckPageFaultAddress = 0;
|
||||
CPU::x64::PageFaultErrorCode params = {.raw = (uint32_t)Frame->ErrorCode};
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
CheckPageFaultAddress = CrashHandler::PageFaultAddress;
|
||||
if (CheckPageFaultAddress == 0)
|
||||
CheckPageFaultAddress = Frame->rip;
|
||||
|
||||
error("An exception occurred at %#lx by %#lx", CrashHandler::PageFaultAddress, Frame->rip);
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
error("An exception occurred at %#lx by %#lx", CrashHandler::PageFaultAddress, Frame->eip);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
#endif
|
||||
error("Page: %s", params.P ? "Present" : "Not Present");
|
||||
error("Write Operation: %s", params.W ? "Read-Only" : "Read-Write");
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <task.hpp>
|
||||
#include <cpu.hpp>
|
||||
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
typedef struct CPU::x64::TrapFrame CHArchTrapFrame;
|
||||
|
||||
struct CRData
|
||||
@ -29,7 +29,7 @@ struct CRData
|
||||
Tasking::TCB *Thread;
|
||||
};
|
||||
|
||||
#elif defined(__i386__)
|
||||
#elif defined(a32)
|
||||
typedef struct CPU::x32::TrapFrame CHArchTrapFrame;
|
||||
|
||||
struct CRData
|
||||
@ -49,7 +49,7 @@ struct CRData
|
||||
Tasking::PCB *Process;
|
||||
Tasking::TCB *Thread;
|
||||
};
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(aa64)
|
||||
typedef struct CPU::aarch64::TrapFrame CHArchTrapFrame;
|
||||
#endif
|
||||
|
||||
@ -244,11 +244,11 @@ namespace CrashHandler
|
||||
class CrashKeyboardDriver : public Interrupts::Handler
|
||||
{
|
||||
private:
|
||||
#if defined(__amd64__)
|
||||
#if defined(a64)
|
||||
void OnInterruptReceived(CPU::x64::TrapFrame *Frame);
|
||||
#elif defined(__i386__)
|
||||
void OnInterruptReceived(void *Frame);
|
||||
#elif defined(__aarch64__)
|
||||
#elif defined(a32)
|
||||
void OnInterruptReceived(CPU::x32::TrapFrame *Frame);
|
||||
#elif defined(aa64)
|
||||
void OnInterruptReceived(void *Frame);
|
||||
#endif
|
||||
public:
|
||||
|
Reference in New Issue
Block a user