b6d4a1c963
Signed-off-by: Chloe M. <chloe@mensia.org>
50 lines
1.2 KiB
C
50 lines
1.2 KiB
C
/*
|
|
* Copyright (c) 2026, Chloe M.
|
|
* Provided under the BSD-3 clause.
|
|
*
|
|
* Description: Trap handling
|
|
* Author: Chloe M.
|
|
*/
|
|
|
|
#include <machine/trap.h>
|
|
#include <ke/knot.h>
|
|
#include <stdef.h>
|
|
|
|
/* Used to convert trap codes to strings */
|
|
static const char *TrapTab[] = {
|
|
[TRAP_DIVERR] = "divide error",
|
|
[TRAP_DBG] = "debug exception",
|
|
[TRAP_NMI] = "non-maskable interrupt",
|
|
[TRAP_BP] = "breakpoint",
|
|
[TRAP_OF] = "overflow",
|
|
[TRAP_BR] = "bound range exceeded",
|
|
[TRAP_UD] = "undefined opcode",
|
|
[TRAP_NM] = "no math coprocessor",
|
|
[TRAP_DF] = "double fault",
|
|
[TRAP_CPR] = "reserved exception",
|
|
[TRAP_TS] = "invalid TSS",
|
|
[TRAP_NP] = "segment not present",
|
|
[TRAP_SS] = "stack segment fault",
|
|
[TRAP_GP] = "general protection fault",
|
|
[TRAP_PF] = "page fault"
|
|
};
|
|
|
|
|
|
VOID
|
|
MdTrapDispatch(TRAP_FRAME *Frame)
|
|
{
|
|
if (Frame == NULL) {
|
|
return;
|
|
}
|
|
|
|
if (Frame->Vector >= NELEM(TrapTab)) {
|
|
KeKnot(
|
|
KNOT_EXCEPTION,
|
|
"Fatal unknown vector %x\n",
|
|
Frame->Vector
|
|
);
|
|
}
|
|
|
|
KeKnot(KNOT_EXCEPTION, "Fatal %s\n", TrapTab[Frame->Vector]);
|
|
}
|