9#include <PeCoffExtraActionLib.h>
23 IN IA32_DESCRIPTOR *IdtDescriptor,
27 IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
28 UINTN InterruptHandler;
30 IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor->Base;
31 if (IdtEntry ==
NULL) {
35 InterruptHandler = IdtEntry[InterruptType].Bits.OffsetLow +
36 (((
UINTN)IdtEntry[InterruptType].Bits.OffsetHigh) << 16) +
37 (((
UINTN)IdtEntry[InterruptType].Bits.OffsetUpper) << 32);
38 if ((InterruptHandler >=
sizeof (UINT32)) && (*(UINT32 *)(InterruptHandler -
sizeof (UINT32)) == AGENT_HANDLER_SIGNATURE)) {
54 IN IA32_DESCRIPTOR *IdtDescriptor,
55 OUT IA32_IDT_GATE_DESCRIPTOR *SavedIdtEntry
58 IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
60 UINTN InterruptHandler;
62 IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor->Base;
63 CopyMem (SavedIdtEntry, &IdtEntry[1],
sizeof (IA32_IDT_GATE_DESCRIPTOR));
70 InterruptHandler = (
UINTN)&AsmInterruptHandle;
71 IdtEntry[1].Bits.OffsetLow = (UINT16)(
UINTN)InterruptHandler;
72 IdtEntry[1].Bits.OffsetHigh = (UINT16)((
UINTN)InterruptHandler >> 16);
73 IdtEntry[1].Bits.OffsetUpper = (UINT32)((
UINTN)InterruptHandler >> 32);
74 IdtEntry[1].Bits.Selector = CodeSegment;
75 IdtEntry[1].Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
87 IN IA32_DESCRIPTOR *IdtDescriptor,
88 IN IA32_IDT_GATE_DESCRIPTOR *RestoredIdtEntry
91 IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
93 IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)IdtDescriptor->Base;
94 CopyMem (&IdtEntry[1], RestoredIdtEntry,
sizeof (IA32_IDT_GATE_DESCRIPTOR));
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
UINT16 EFIAPI AsmReadCs(VOID)
VOID SaveAndUpdateIdtEntry1(IN IA32_DESCRIPTOR *IdtDescriptor, OUT IA32_IDT_GATE_DESCRIPTOR *SavedIdtEntry)
VOID RestoreIdtEntry1(IN IA32_DESCRIPTOR *IdtDescriptor, IN IA32_IDT_GATE_DESCRIPTOR *RestoredIdtEntry)
BOOLEAN CheckDebugAgentHandler(IN IA32_DESCRIPTOR *IdtDescriptor, IN UINTN InterruptType)