]> git.proxmox.com Git - mirror_edk2.git/blob - QuarkPlatformPkg/Acpi/Dxe/BootScriptExecutorDxe/IA32/SetIdtEntry.c
ArmPkg/CompilerIntrinsicsLib: Add uread, uwrite GCC assembly sources
[mirror_edk2.git] / QuarkPlatformPkg / Acpi / Dxe / BootScriptExecutorDxe / IA32 / SetIdtEntry.c
1 /** @file
2 Set a IDT entry for debug purpose
3
4 Set a IDT entry for interrupt vector 3 for debug purpose for IA32 platform
5
6 Copyright (c) 2013-2015 Intel Corporation.
7
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11 #include "ScriptExecute.h"
12 //
13 // INTERRUPT_GATE_DESCRIPTOR and SetIdtEntry () are used to setup IDT to do debug
14 //
15
16 #pragma pack(1)
17
18 typedef struct {
19 UINT16 OffsetLow;
20 UINT16 SegmentSelector;
21 UINT16 Attributes;
22 UINT16 OffsetHigh;
23 } INTERRUPT_GATE_DESCRIPTOR;
24
25 #define INTERRUPT_GATE_ATTRIBUTE 0x8e00
26
27 #pragma pack()
28 /**
29 Set a IDT entry for interrupt vector 3 for debug purpose.
30
31 @param AcpiS3Context a pointer to a structure of ACPI_S3_CONTEXT
32
33 **/
34 VOID
35 SetIdtEntry (
36 IN ACPI_S3_CONTEXT *AcpiS3Context
37 )
38 {
39 INTERRUPT_GATE_DESCRIPTOR *IdtEntry;
40 IA32_DESCRIPTOR *IdtDescriptor;
41 UINTN S3DebugBuffer;
42
43 //
44 // Restore IDT for debug
45 //
46 IdtDescriptor = (IA32_DESCRIPTOR *) (UINTN) (AcpiS3Context->IdtrProfile);
47 IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));
48 S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);
49
50 IdtEntry->OffsetLow = (UINT16)S3DebugBuffer;
51 IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();
52 IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;
53 IdtEntry->OffsetHigh = (UINT16)(S3DebugBuffer >> 16);
54
55 AsmWriteIdtr (IdtDescriptor);
56 }
57