Update CPU::TrapFrame in crash handler functions

This commit is contained in:
EnderIce2 2024-02-04 02:26:43 +02:00
parent d89f59a252
commit e7c4a5758c
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
5 changed files with 55 additions and 58 deletions

View File

@ -25,11 +25,10 @@
#include <cpu.hpp> #include <cpu.hpp>
#if defined(a64) #if defined(a64)
typedef struct CPU::x64::TrapFrame CHArchTrapFrame;
struct CRData struct CRData
{ {
CHArchTrapFrame *Frame; CPU::TrapFrame *Frame;
CPU::x64::CR0 cr0; CPU::x64::CR0 cr0;
CPU::x64::CR2 cr2; CPU::x64::CR2 cr2;
@ -48,11 +47,10 @@ struct CRData
}; };
#elif defined(a32) #elif defined(a32)
typedef struct CPU::x32::TrapFrame CHArchTrapFrame;
struct CRData struct CRData
{ {
CHArchTrapFrame *Frame; CPU::TrapFrame *Frame;
CPU::x32::CR0 cr0; CPU::x32::CR0 cr0;
CPU::x32::CR2 cr2; CPU::x32::CR2 cr2;
@ -69,11 +67,10 @@ struct CRData
Tasking::TCB *Thread; Tasking::TCB *Thread;
}; };
#elif defined(aa64) #elif defined(aa64)
typedef struct CPU::aarch64::TrapFrame CHArchTrapFrame;
struct CRData struct CRData
{ {
CHArchTrapFrame *Frame; CPU::TrapFrame *Frame;
long ID; long ID;
void *CPUData; void *CPUData;
@ -293,29 +290,29 @@ namespace CrashHandler
void DisplayConsoleScreen(CRData data); void DisplayConsoleScreen(CRData data);
} }
void DivideByZeroExceptionHandler(CHArchTrapFrame *Frame); void DivideByZeroExceptionHandler(CPU::TrapFrame *Frame);
void DebugExceptionHandler(CHArchTrapFrame *Frame); void DebugExceptionHandler(CPU::TrapFrame *Frame);
void NonMaskableInterruptExceptionHandler(CHArchTrapFrame *Frame); void NonMaskableInterruptExceptionHandler(CPU::TrapFrame *Frame);
void BreakpointExceptionHandler(CHArchTrapFrame *Frame); void BreakpointExceptionHandler(CPU::TrapFrame *Frame);
void OverflowExceptionHandler(CHArchTrapFrame *Frame); void OverflowExceptionHandler(CPU::TrapFrame *Frame);
void BoundRangeExceptionHandler(CHArchTrapFrame *Frame); void BoundRangeExceptionHandler(CPU::TrapFrame *Frame);
void InvalidOpcodeExceptionHandler(CHArchTrapFrame *Frame); void InvalidOpcodeExceptionHandler(CPU::TrapFrame *Frame);
void DeviceNotAvailableExceptionHandler(CHArchTrapFrame *Frame); void DeviceNotAvailableExceptionHandler(CPU::TrapFrame *Frame);
void DoubleFaultExceptionHandler(CHArchTrapFrame *Frame); void DoubleFaultExceptionHandler(CPU::TrapFrame *Frame);
void CoprocessorSegmentOverrunExceptionHandler(CHArchTrapFrame *Frame); void CoprocessorSegmentOverrunExceptionHandler(CPU::TrapFrame *Frame);
void InvalidTSSExceptionHandler(CHArchTrapFrame *Frame); void InvalidTSSExceptionHandler(CPU::TrapFrame *Frame);
void SegmentNotPresentExceptionHandler(CHArchTrapFrame *Frame); void SegmentNotPresentExceptionHandler(CPU::TrapFrame *Frame);
void StackFaultExceptionHandler(CHArchTrapFrame *Frame); void StackFaultExceptionHandler(CPU::TrapFrame *Frame);
void GeneralProtectionExceptionHandler(CHArchTrapFrame *Frame); void GeneralProtectionExceptionHandler(CPU::TrapFrame *Frame);
void PageFaultExceptionHandler(CHArchTrapFrame *Frame); void PageFaultExceptionHandler(CPU::TrapFrame *Frame);
void x87FloatingPointExceptionHandler(CHArchTrapFrame *Frame); void x87FloatingPointExceptionHandler(CPU::TrapFrame *Frame);
void AlignmentCheckExceptionHandler(CHArchTrapFrame *Frame); void AlignmentCheckExceptionHandler(CPU::TrapFrame *Frame);
void MachineCheckExceptionHandler(CHArchTrapFrame *Frame); void MachineCheckExceptionHandler(CPU::TrapFrame *Frame);
void SIMDFloatingPointExceptionHandler(CHArchTrapFrame *Frame); void SIMDFloatingPointExceptionHandler(CPU::TrapFrame *Frame);
void VirtualizationExceptionHandler(CHArchTrapFrame *Frame); void VirtualizationExceptionHandler(CPU::TrapFrame *Frame);
void SecurityExceptionHandler(CHArchTrapFrame *Frame); void SecurityExceptionHandler(CPU::TrapFrame *Frame);
void UnknownExceptionHandler(CHArchTrapFrame *Frame); void UnknownExceptionHandler(CPU::TrapFrame *Frame);
bool UserModeExceptionHandler(CHArchTrapFrame *Frame); bool UserModeExceptionHandler(CPU::TrapFrame *Frame);
#endif // !__FENNIX_KERNEL_CRASH_HANDLERS_FUNCTIONS_H__ #endif // !__FENNIX_KERNEL_CRASH_HANDLERS_FUNCTIONS_H__

View File

@ -42,79 +42,79 @@ static const char *PageFaultDescriptions[8] = {
"User process tried to write to a non-present page entry\n", "User process tried to write to a non-present page entry\n",
"User process tried to write a page and caused a protection fault\n"}; "User process tried to write a page and caused a protection fault\n"};
SafeFunction void DivideByZeroExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void DivideByZeroExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Divide by zero exception\n"); fixme("Divide by zero exception\n");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void DebugExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void DebugExceptionHandler(CPU::TrapFrame *Frame)
{ {
CrashHandler::EHPrint("Kernel triggered debug exception.\n"); CrashHandler::EHPrint("Kernel triggered debug exception.\n");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void NonMaskableInterruptExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void NonMaskableInterruptExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("NMI exception"); fixme("NMI exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void BreakpointExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void BreakpointExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Breakpoint exception"); fixme("Breakpoint exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void OverflowExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void OverflowExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Overflow exception"); fixme("Overflow exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void BoundRangeExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void BoundRangeExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Bound range exception"); fixme("Bound range exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void InvalidOpcodeExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void InvalidOpcodeExceptionHandler(CPU::TrapFrame *Frame)
{ {
CrashHandler::EHPrint("Kernel tried to execute an invalid opcode.\n"); CrashHandler::EHPrint("Kernel tried to execute an invalid opcode.\n");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void DeviceNotAvailableExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void DeviceNotAvailableExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Device not available exception"); fixme("Device not available exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void DoubleFaultExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void DoubleFaultExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Double fault exception"); fixme("Double fault exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void CoprocessorSegmentOverrunExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void CoprocessorSegmentOverrunExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Coprocessor segment overrun exception"); fixme("Coprocessor segment overrun exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void InvalidTSSExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void InvalidTSSExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Invalid TSS exception"); fixme("Invalid TSS exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void SegmentNotPresentExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void SegmentNotPresentExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Segment not present exception"); fixme("Segment not present exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void StackFaultExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void StackFaultExceptionHandler(CPU::TrapFrame *Frame)
{ {
CPU::x64::SelectorErrorCode SelCode = {.raw = Frame->ErrorCode}; CPU::x64::SelectorErrorCode SelCode = {.raw = Frame->ErrorCode};
#if defined(a64) #if defined(a64)
@ -129,7 +129,7 @@ SafeFunction void StackFaultExceptionHandler(CHArchTrapFrame *Frame)
CrashHandler::EHPrint("Error code: %#lx\n", Frame->ErrorCode); CrashHandler::EHPrint("Error code: %#lx\n", Frame->ErrorCode);
} }
SafeFunction void GeneralProtectionExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void GeneralProtectionExceptionHandler(CPU::TrapFrame *Frame)
{ {
CPU::x64::SelectorErrorCode SelCode = {.raw = Frame->ErrorCode}; CPU::x64::SelectorErrorCode SelCode = {.raw = Frame->ErrorCode};
// switch (SelCode.Table) // switch (SelCode.Table)
@ -156,7 +156,7 @@ SafeFunction void GeneralProtectionExceptionHandler(CHArchTrapFrame *Frame)
CrashHandler::EHPrint("Index: %#x\n", SelCode.Idx); CrashHandler::EHPrint("Index: %#x\n", SelCode.Idx);
} }
SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void PageFaultExceptionHandler(CPU::TrapFrame *Frame)
{ {
CPU::x64::PageFaultErrorCode params = {.raw = (uint32_t)Frame->ErrorCode}; CPU::x64::PageFaultErrorCode params = {.raw = (uint32_t)Frame->ErrorCode};
#if defined(a64) #if defined(a64)
@ -305,43 +305,43 @@ SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame)
#endif #endif
} }
SafeFunction void x87FloatingPointExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void x87FloatingPointExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("x87 floating point exception"); fixme("x87 floating point exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void AlignmentCheckExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void AlignmentCheckExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Alignment check exception"); fixme("Alignment check exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void MachineCheckExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void MachineCheckExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Machine check exception"); fixme("Machine check exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void SIMDFloatingPointExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void SIMDFloatingPointExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("SIMD floating point exception"); fixme("SIMD floating point exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void VirtualizationExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void VirtualizationExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Virtualization exception"); fixme("Virtualization exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void SecurityExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void SecurityExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Security exception"); fixme("Security exception");
UNUSED(Frame); UNUSED(Frame);
} }
SafeFunction void UnknownExceptionHandler(CHArchTrapFrame *Frame) SafeFunction void UnknownExceptionHandler(CPU::TrapFrame *Frame)
{ {
fixme("Unknown exception"); fixme("Unknown exception");
UNUSED(Frame); UNUSED(Frame);

View File

@ -841,7 +841,7 @@ namespace CrashHandler
#endif #endif
} }
SafeFunction inline bool Handle_x86_64(CHArchTrapFrame *Frame) SafeFunction inline bool Handle_x86_64(CPU::TrapFrame *Frame)
{ {
#ifdef a64 #ifdef a64
trace("Exception at %#lx(%s)", Frame->rip, trace("Exception at %#lx(%s)", Frame->rip,
@ -939,7 +939,7 @@ namespace CrashHandler
return false; return false;
} }
SafeFunction inline bool Handle_x86_32(CHArchTrapFrame *Frame) SafeFunction inline bool Handle_x86_32(CPU::TrapFrame *Frame)
{ {
#ifdef a32 #ifdef a32
trace("Exception at %#lx(%s)", Frame->eip, trace("Exception at %#lx(%s)", Frame->eip,
@ -1038,7 +1038,7 @@ namespace CrashHandler
return false; return false;
} }
SafeFunction inline void Print_x86_64(CHArchTrapFrame *Frame) SafeFunction inline void Print_x86_64(CPU::TrapFrame *Frame)
{ {
#ifdef a64 #ifdef a64
CPU::x64::CR0 cr0 = CPU::x64::readcr0(); CPU::x64::CR0 cr0 = CPU::x64::readcr0();
@ -1111,7 +1111,7 @@ namespace CrashHandler
#endif #endif
} }
SafeFunction inline void Print_x86_32(CHArchTrapFrame *Frame) SafeFunction inline void Print_x86_32(CPU::TrapFrame *Frame)
{ {
#ifdef a32 #ifdef a32
CPU::x32::CR0 cr0 = CPU::x32::readcr0(); CPU::x32::CR0 cr0 = CPU::x32::readcr0();
@ -1175,7 +1175,7 @@ namespace CrashHandler
{ {
// TODO: SUPPORT SMP // TODO: SUPPORT SMP
CPU::Interrupts(CPU::Disable); CPU::Interrupts(CPU::Disable);
CHArchTrapFrame *Frame = (CHArchTrapFrame *)Data; CPU::TrapFrame *Frame = (CPU::TrapFrame *)Data;
SBIdx = 255; SBIdx = 255;
debug("-----------------------------------------------------------------------------------"); debug("-----------------------------------------------------------------------------------");
debug("%ld MiB / %ld MiB (%ld MiB Reserved)", debug("%ld MiB / %ld MiB (%ld MiB Reserved)",

View File

@ -46,7 +46,7 @@ namespace CrashHandler
{ {
SafeFunction void DisplayMainScreen(CRData data) SafeFunction void DisplayMainScreen(CRData data)
{ {
CHArchTrapFrame *Frame = data.Frame; CPU::TrapFrame *Frame = data.Frame;
/* /*
_______ ___ ___ _______ _______ _______ _______ ______ ______ _______ _______ _______ _______ _____ _______ ___ ___ _______ _______ _______ _______ ______ ______ _______ _______ _______ _______ _____

View File

@ -32,7 +32,7 @@
#include "../../kernel.h" #include "../../kernel.h"
SafeFunction bool UserModeExceptionHandler(CHArchTrapFrame *Frame) SafeFunction bool UserModeExceptionHandler(CPU::TrapFrame *Frame)
{ {
CPUData *CurCPU = GetCurrentCPU(); CPUData *CurCPU = GetCurrentCPU();
Tasking::PCB *CurProc = CurCPU->CurrentProcess; Tasking::PCB *CurProc = CurCPU->CurrentProcess;