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>
#if defined(a64)
typedef struct CPU::x64::TrapFrame CHArchTrapFrame;
struct CRData
{
CHArchTrapFrame *Frame;
CPU::TrapFrame *Frame;
CPU::x64::CR0 cr0;
CPU::x64::CR2 cr2;
@ -48,11 +47,10 @@ struct CRData
};
#elif defined(a32)
typedef struct CPU::x32::TrapFrame CHArchTrapFrame;
struct CRData
{
CHArchTrapFrame *Frame;
CPU::TrapFrame *Frame;
CPU::x32::CR0 cr0;
CPU::x32::CR2 cr2;
@ -69,11 +67,10 @@ struct CRData
Tasking::TCB *Thread;
};
#elif defined(aa64)
typedef struct CPU::aarch64::TrapFrame CHArchTrapFrame;
struct CRData
{
CHArchTrapFrame *Frame;
CPU::TrapFrame *Frame;
long ID;
void *CPUData;
@ -293,29 +290,29 @@ namespace CrashHandler
void DisplayConsoleScreen(CRData data);
}
void DivideByZeroExceptionHandler(CHArchTrapFrame *Frame);
void DebugExceptionHandler(CHArchTrapFrame *Frame);
void NonMaskableInterruptExceptionHandler(CHArchTrapFrame *Frame);
void BreakpointExceptionHandler(CHArchTrapFrame *Frame);
void OverflowExceptionHandler(CHArchTrapFrame *Frame);
void BoundRangeExceptionHandler(CHArchTrapFrame *Frame);
void InvalidOpcodeExceptionHandler(CHArchTrapFrame *Frame);
void DeviceNotAvailableExceptionHandler(CHArchTrapFrame *Frame);
void DoubleFaultExceptionHandler(CHArchTrapFrame *Frame);
void CoprocessorSegmentOverrunExceptionHandler(CHArchTrapFrame *Frame);
void InvalidTSSExceptionHandler(CHArchTrapFrame *Frame);
void SegmentNotPresentExceptionHandler(CHArchTrapFrame *Frame);
void StackFaultExceptionHandler(CHArchTrapFrame *Frame);
void GeneralProtectionExceptionHandler(CHArchTrapFrame *Frame);
void PageFaultExceptionHandler(CHArchTrapFrame *Frame);
void x87FloatingPointExceptionHandler(CHArchTrapFrame *Frame);
void AlignmentCheckExceptionHandler(CHArchTrapFrame *Frame);
void MachineCheckExceptionHandler(CHArchTrapFrame *Frame);
void SIMDFloatingPointExceptionHandler(CHArchTrapFrame *Frame);
void VirtualizationExceptionHandler(CHArchTrapFrame *Frame);
void SecurityExceptionHandler(CHArchTrapFrame *Frame);
void UnknownExceptionHandler(CHArchTrapFrame *Frame);
void DivideByZeroExceptionHandler(CPU::TrapFrame *Frame);
void DebugExceptionHandler(CPU::TrapFrame *Frame);
void NonMaskableInterruptExceptionHandler(CPU::TrapFrame *Frame);
void BreakpointExceptionHandler(CPU::TrapFrame *Frame);
void OverflowExceptionHandler(CPU::TrapFrame *Frame);
void BoundRangeExceptionHandler(CPU::TrapFrame *Frame);
void InvalidOpcodeExceptionHandler(CPU::TrapFrame *Frame);
void DeviceNotAvailableExceptionHandler(CPU::TrapFrame *Frame);
void DoubleFaultExceptionHandler(CPU::TrapFrame *Frame);
void CoprocessorSegmentOverrunExceptionHandler(CPU::TrapFrame *Frame);
void InvalidTSSExceptionHandler(CPU::TrapFrame *Frame);
void SegmentNotPresentExceptionHandler(CPU::TrapFrame *Frame);
void StackFaultExceptionHandler(CPU::TrapFrame *Frame);
void GeneralProtectionExceptionHandler(CPU::TrapFrame *Frame);
void PageFaultExceptionHandler(CPU::TrapFrame *Frame);
void x87FloatingPointExceptionHandler(CPU::TrapFrame *Frame);
void AlignmentCheckExceptionHandler(CPU::TrapFrame *Frame);
void MachineCheckExceptionHandler(CPU::TrapFrame *Frame);
void SIMDFloatingPointExceptionHandler(CPU::TrapFrame *Frame);
void VirtualizationExceptionHandler(CPU::TrapFrame *Frame);
void SecurityExceptionHandler(CPU::TrapFrame *Frame);
void UnknownExceptionHandler(CPU::TrapFrame *Frame);
bool UserModeExceptionHandler(CHArchTrapFrame *Frame);
bool UserModeExceptionHandler(CPU::TrapFrame *Frame);
#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 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");
UNUSED(Frame);
}
SafeFunction void DebugExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void DebugExceptionHandler(CPU::TrapFrame *Frame)
{
CrashHandler::EHPrint("Kernel triggered debug exception.\n");
UNUSED(Frame);
}
SafeFunction void NonMaskableInterruptExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void NonMaskableInterruptExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("NMI exception");
UNUSED(Frame);
}
SafeFunction void BreakpointExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void BreakpointExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Breakpoint exception");
UNUSED(Frame);
}
SafeFunction void OverflowExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void OverflowExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Overflow exception");
UNUSED(Frame);
}
SafeFunction void BoundRangeExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void BoundRangeExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Bound range exception");
UNUSED(Frame);
}
SafeFunction void InvalidOpcodeExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void InvalidOpcodeExceptionHandler(CPU::TrapFrame *Frame)
{
CrashHandler::EHPrint("Kernel tried to execute an invalid opcode.\n");
UNUSED(Frame);
}
SafeFunction void DeviceNotAvailableExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void DeviceNotAvailableExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Device not available exception");
UNUSED(Frame);
}
SafeFunction void DoubleFaultExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void DoubleFaultExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Double fault exception");
UNUSED(Frame);
}
SafeFunction void CoprocessorSegmentOverrunExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void CoprocessorSegmentOverrunExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Coprocessor segment overrun exception");
UNUSED(Frame);
}
SafeFunction void InvalidTSSExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void InvalidTSSExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Invalid TSS exception");
UNUSED(Frame);
}
SafeFunction void SegmentNotPresentExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void SegmentNotPresentExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Segment not present exception");
UNUSED(Frame);
}
SafeFunction void StackFaultExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void StackFaultExceptionHandler(CPU::TrapFrame *Frame)
{
CPU::x64::SelectorErrorCode SelCode = {.raw = Frame->ErrorCode};
#if defined(a64)
@ -129,7 +129,7 @@ SafeFunction void StackFaultExceptionHandler(CHArchTrapFrame *Frame)
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};
// switch (SelCode.Table)
@ -156,7 +156,7 @@ SafeFunction void GeneralProtectionExceptionHandler(CHArchTrapFrame *Frame)
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};
#if defined(a64)
@ -305,43 +305,43 @@ SafeFunction void PageFaultExceptionHandler(CHArchTrapFrame *Frame)
#endif
}
SafeFunction void x87FloatingPointExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void x87FloatingPointExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("x87 floating point exception");
UNUSED(Frame);
}
SafeFunction void AlignmentCheckExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void AlignmentCheckExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Alignment check exception");
UNUSED(Frame);
}
SafeFunction void MachineCheckExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void MachineCheckExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Machine check exception");
UNUSED(Frame);
}
SafeFunction void SIMDFloatingPointExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void SIMDFloatingPointExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("SIMD floating point exception");
UNUSED(Frame);
}
SafeFunction void VirtualizationExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void VirtualizationExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Virtualization exception");
UNUSED(Frame);
}
SafeFunction void SecurityExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void SecurityExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Security exception");
UNUSED(Frame);
}
SafeFunction void UnknownExceptionHandler(CHArchTrapFrame *Frame)
SafeFunction void UnknownExceptionHandler(CPU::TrapFrame *Frame)
{
fixme("Unknown exception");
UNUSED(Frame);

View File

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

View File

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

View File

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