TianoCore EDK2 master
Loading...
Searching...
No Matches
SetIdtEntry.c
Go to the documentation of this file.
1
11#include "ScriptExecute.h"
12
19VOID
21 IN ACPI_S3_CONTEXT *AcpiS3Context
22 )
23{
24 IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
25 IA32_DESCRIPTOR *IdtDescriptor;
26 UINTN S3DebugBuffer;
27 EFI_STATUS Status;
28
29 //
30 // Restore IDT for debug
31 //
32 IdtDescriptor = (IA32_DESCRIPTOR *)(UINTN)(AcpiS3Context->IdtrProfile);
33 AsmWriteIdtr (IdtDescriptor);
34
35 //
36 // Setup the default CPU exception handlers
37 //
38 Status = InitializeCpuExceptionHandlers (NULL);
39 ASSERT_EFI_ERROR (Status);
40
42 //
43 // Update IDT entry INT3 if the instruction is valid in it
44 //
45 S3DebugBuffer = (UINTN)(AcpiS3Context->S3DebugBufferAddress);
46 if (*(UINTN *)S3DebugBuffer != (UINTN)-1) {
47 IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (IA32_IDT_GATE_DESCRIPTOR)));
48 IdtEntry->Bits.OffsetLow = (UINT16)S3DebugBuffer;
49 IdtEntry->Bits.Selector = (UINT16)AsmReadCs ();
50 IdtEntry->Bits.Reserved_0 = 0;
51 IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
52 IdtEntry->Bits.OffsetHigh = (UINT16)(S3DebugBuffer >> 16);
53 }
54
56}
UINT64 UINTN
VOID SetIdtEntry(IN ACPI_S3_CONTEXT *AcpiS3Context)
Definition: SetIdtEntry.c:20
UINT16 EFIAPI AsmReadCs(VOID)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG_CODE_BEGIN()
Definition: DebugLib.h:564
#define DEBUG_CODE_END()
Definition: DebugLib.h:578
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID EFIAPI AsmWriteIdtr(IN CONST IA32_DESCRIPTOR *Idtr)