Rework trap handling to access registers
Some checks failed
Builds / ExectOS (i686) (push) Failing after 28s
Builds / ExectOS (amd64) (push) Failing after 29s

This commit is contained in:
2024-04-19 16:49:40 +02:00
parent cf408519ad
commit 92ee74b494
9 changed files with 850 additions and 192 deletions

View File

@@ -10,7 +10,10 @@
/**
* Handles the trap 0x00 when a Divide By Zero exception occurs.
* Dispatches the trap provided by common trap handler.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
@@ -18,7 +21,127 @@
*/
XTCDECL
VOID
ArpHandleTrap00(VOID)
ArpDispatchTrap(IN PKTRAP_FRAME TrapFrame)
{
/* Check vector and call appropriate handler */
switch(TrapFrame->Vector)
{
case 0x00:
/* Divide By Zero exception */
ArpHandleTrap00(TrapFrame);
break;
case 0x01:
/* Debug exception */
ArpHandleTrap01(TrapFrame);
break;
case 0x02:
/* Non-Maskable Interrupt (NMI) */
ArpHandleTrap02(TrapFrame);
break;
case 0x03:
/* INT3 instruction executed */
ArpHandleTrap03(TrapFrame);
break;
case 0x04:
/* Overflow exception */
ArpHandleTrap04(TrapFrame);
break;
case 0x05:
/* Bound Range Exceeded exception */
ArpHandleTrap05(TrapFrame);
break;
case 0x06:
/* Invalid Opcode exception */
ArpHandleTrap06(TrapFrame);
break;
case 0x07:
/* Device Not Available exception */
ArpHandleTrap07(TrapFrame);
break;
case 0x08:
/* Double Fault exception */
ArpHandleTrap08(TrapFrame);
break;
case 0x09:
/* Segment Overrun exception */
ArpHandleTrap09(TrapFrame);
break;
case 0x0A:
/* Invalid TSS exception */
ArpHandleTrap0A(TrapFrame);
break;
case 0x0B:
/* Segment Not Present exception */
ArpHandleTrap0B(TrapFrame);
break;
case 0x0C:
/* Stack Segment Fault exception */
ArpHandleTrap0C(TrapFrame);
break;
case 0x0D:
/* General Protection Fault (GPF) exception*/
ArpHandleTrap0D(TrapFrame);
break;
case 0x0E:
/* Page Fault exception */
ArpHandleTrap0E(TrapFrame);
break;
case 0x10:
/* X87 Floating-Point exception */
ArpHandleTrap10(TrapFrame);
break;
case 0x11:
/* Alignment Check exception */
ArpHandleTrap11(TrapFrame);
break;
case 0x12:
/* Machine Check exception */
ArpHandleTrap12(TrapFrame);
break;
case 0x13:
/* SIMD Floating-Point exception */
ArpHandleTrap13(TrapFrame);
break;
case 0x2A:
/* Tick Count service request */
ArpHandleTrap2A(TrapFrame);
break;
case 0x2B:
/* User-mode callback return */
ArpHandleTrap2B(TrapFrame);
break;
case 0x2C:
/* Assertion raised */
ArpHandleTrap2C(TrapFrame);
break;
case 0x2D:
/* Debug-Service-Request raised */
ArpHandleTrap2D(TrapFrame);
break;
case 0x2E:
/* System call service request */
ArpHandleTrap2E(TrapFrame);
break;
default:
/* Unknown/Unexpected trap */
ArpHandleTrapFF(TrapFrame);
break;
}
}
/**
* Handles the trap 0x00 when a Divide By Zero exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap00(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Division-By-Zero Error (0x00)!\n");
for(;;);
@@ -27,13 +150,16 @@ ArpHandleTrap00(VOID)
/**
* Handles the trap 0x01 when Debug exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap01(VOID)
ArpHandleTrap01(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Debug exception (0x01)!\n");
for(;;);
@@ -42,13 +168,16 @@ ArpHandleTrap01(VOID)
/**
* Handles the trap 0x02 when Non-Maskable Interrupt (NMI) occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap02(VOID)
ArpHandleTrap02(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Non-Maskable-Interrupt (0x02)!\n");
for(;;);
@@ -57,13 +186,16 @@ ArpHandleTrap02(VOID)
/**
* Handles the trap 0x03 when the INT3 instruction is executed.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap03(VOID)
ArpHandleTrap03(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled INT3 (0x03)!\n");
for(;;);
@@ -72,13 +204,16 @@ ArpHandleTrap03(VOID)
/**
* Handles the trap 0x04 when the INTO instruction is executed and overflow bit is set.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap04(VOID)
ArpHandleTrap04(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Overflow exception (0x04)!\n");
for(;;);
@@ -87,13 +222,16 @@ ArpHandleTrap04(VOID)
/**
* Handles the trap 0x05 when the Bound Range Exceeded exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap05(VOID)
ArpHandleTrap05(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Bound-Range-Exceeded exception (0x05)!\n");
for(;;);
@@ -102,13 +240,16 @@ ArpHandleTrap05(VOID)
/**
* Handles the trap 0x06 when the Invalid Opcode exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap06(VOID)
ArpHandleTrap06(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Invalid Opcode exception (0x06)!\n");
for(;;);
@@ -117,13 +258,16 @@ ArpHandleTrap06(VOID)
/**
* Handles the trap 0x07 when the Device Not Available exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap07(VOID)
ArpHandleTrap07(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Device Not Available exception (0x07)!\n");
for(;;);
@@ -132,13 +276,16 @@ ArpHandleTrap07(VOID)
/**
* Handles the trap 0x08 when Double Fault exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap08(VOID)
ArpHandleTrap08(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Double-Fault exception (0x08)!\n");
for(;;);
@@ -147,13 +294,16 @@ ArpHandleTrap08(VOID)
/**
* Handles the trap 0x09 when the Segment Overrun exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap09(VOID)
ArpHandleTrap09(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Segment-Overrun exception (0x09)!\n");
for(;;);
@@ -162,13 +312,16 @@ ArpHandleTrap09(VOID)
/**
* Handles the trap 0x0A when the Invalid TSS exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap0A(VOID)
ArpHandleTrap0A(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Invalid-TSS exception (0x0A)!\n");
for(;;);
@@ -177,13 +330,16 @@ ArpHandleTrap0A(VOID)
/**
* Handles the trap 0x0B when the Segment Not Present exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap0B(VOID)
ArpHandleTrap0B(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Segment-Not-Present exception (0x0B)!\n");
for(;;);
@@ -192,13 +348,16 @@ ArpHandleTrap0B(VOID)
/**
* Handles the trap 0x0C when the Stack Segment Fault exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap0C(VOID)
ArpHandleTrap0C(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Stack-Segment-Fault exception (0x0C)!\n");
for(;;);
@@ -207,13 +366,16 @@ ArpHandleTrap0C(VOID)
/**
* Handles the trap 0x0D when General Protection Fault (GPF) exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap0D(VOID)
ArpHandleTrap0D(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled General-Protection-Fault (0x0D)!\n");
for(;;);
@@ -222,13 +384,16 @@ ArpHandleTrap0D(VOID)
/**
* Handles the trap 0x0E when the Page Fault (PF) exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap0E(VOID)
ArpHandleTrap0E(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Page-Fault exception (0x0E)!\n");
for(;;);
@@ -237,13 +402,16 @@ ArpHandleTrap0E(VOID)
/**
* Handles the trap 0x10 when the X87 Floating-Point exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap10(VOID)
ArpHandleTrap10(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled x87 Floating-Point exception (0x10)!\n");
for(;;);
@@ -252,13 +420,16 @@ ArpHandleTrap10(VOID)
/**
* Handles the trap 0x11 when the Alignment Check exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap11(VOID)
ArpHandleTrap11(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Alignment-Check exception (0x11)!\n");
for(;;);
@@ -267,13 +438,16 @@ ArpHandleTrap11(VOID)
/**
* Handles the trap 0x12 when the Machine Check exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap12(VOID)
ArpHandleTrap12(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Machine-Check exception (0x12)!\n");
for(;;);
@@ -282,20 +456,26 @@ ArpHandleTrap12(VOID)
/**
* Handles the trap 0x13 when the SIMD Floating-Point exception occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap13(VOID)
ArpHandleTrap13(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled SIMD Floating-Point exception (0x13)!\n");
for(;;);
}
/**
* Handles the trap 0x2C when an assertion is raised.
* Handles the trap 0x2A when Tick Count service request occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
@@ -303,7 +483,41 @@ ArpHandleTrap13(VOID)
*/
XTCDECL
VOID
ArpHandleTrap2C(VOID)
ArpHandleTrap2A(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Unhandled Tick Count service request (0x2A)!\n");
}
/**
* Handles the trap 0x2B when Callback return service request occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap2B(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Unhandled Callback return service request (0x2B)!\n");
}
/**
* Handles the trap 0x2C when an assertion is raised.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap2C(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Assertion (0x2C)!\n");
for(;;);
@@ -312,20 +526,26 @@ ArpHandleTrap2C(VOID)
/**
* Handles the trap 0x2D when a debug service is being requested.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrap2D(VOID)
ArpHandleTrap2D(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Debug-Service-Request (0x2D)!\n");
for(;;);
}
/**
* Handles the trap 0xFF then Unexpected Interrupt occurs.
* Handles the trap 0x2E when a system call is being requested.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
@@ -333,7 +553,24 @@ ArpHandleTrap2D(VOID)
*/
XTCDECL
VOID
ArpHandleTrapFF(VOID)
ArpHandleTrap2E(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Unhandled system call (0x2E)!\n");
}
/**
* Handles the trap 0xFF then Unexpected Interrupt occurs.
*
* @param TrapFrame
* Supplies a kernel trap frame pushed by common trap handler on the stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTCDECL
VOID
ArpHandleTrapFF(IN PKTRAP_FRAME TrapFrame)
{
DebugPrint(L"Handled Unexpected-Interrupt (0xFF)!\n");
for(;;);