Initialize IDT with specific trap handlers for each vector

This commit is contained in:
2026-03-27 19:16:16 +01:00
parent a64aa83eb8
commit 9c449bed43
6 changed files with 27 additions and 3 deletions

View File

@@ -82,7 +82,7 @@ _ArTrap\Vector:
jmp UserMode$\Vector
KernelMode$\Vector:
/* Save kernel stack pointer (SS:ESP) as CPU did not push them */
/* Save kernel stack pointer (SS:ESP) */
movl %ss, %eax
mov %eax, TrapSegSs(%ebp)
lea TrapEsp(%ebp), %eax
@@ -133,3 +133,12 @@ KernelModeReturn$\Vector:
ArCreateTrapHandler 0x\i\j
.endr
.endr
/* Define array of pointers to the trap handlers */
.global ArTrapEntry
ArTrapEntry:
.irp i,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
.irp j,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
.long ArTrap0x\i\j
.endr
.endr

View File

@@ -242,7 +242,7 @@ AR::ProcSup::InitializeIdt(IN PKPROCESSOR_BLOCK ProcessorBlock)
for(Vector = 0; Vector < IDT_ENTRIES; Vector++)
{
/* Set the IDT to handle unexpected interrupts */
SetIdtGate(ProcessorBlock->IdtBase, Vector, (PVOID)ArTrap0xFF, KGDT_R0_CODE, 0, KIDT_ACCESS_RING0, I686_INTERRUPT_GATE);
SetIdtGate(ProcessorBlock->IdtBase, Vector, (PVOID)ArTrapEntry[Vector], KGDT_R0_CODE, 0, KIDT_ACCESS_RING0, I686_INTERRUPT_GATE);
}
/* Setup IDT handlers for known interrupts and traps */