]> git.proxmox.com Git - mirror_edk2.git/blame - QuarkPlatformPkg/Acpi/Dxe/BootScriptExecutorDxe/IA32/SetIdtEntry.c
QuarkPlatformPkg: Add new package for Galileo boards
[mirror_edk2.git] / QuarkPlatformPkg / Acpi / Dxe / BootScriptExecutorDxe / IA32 / SetIdtEntry.c
CommitLineData
b303605e
MK
1/** @file\r
2Set a IDT entry for debug purpose\r
3\r
4Set a IDT entry for interrupt vector 3 for debug purpose for IA32 platform\r
5\r
6Copyright (c) 2013-2015 Intel Corporation.\r
7\r
8This program and the accompanying materials\r
9are licensed and made available under the terms and conditions of the BSD License\r
10which accompanies this distribution. The full text of the license may be found at\r
11http://opensource.org/licenses/bsd-license.php\r
12\r
13THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17#include "ScriptExecute.h"\r
18//\r
19// INTERRUPT_GATE_DESCRIPTOR and SetIdtEntry () are used to setup IDT to do debug\r
20//\r
21\r
22#pragma pack(1)\r
23\r
24typedef struct {\r
25 UINT16 OffsetLow;\r
26 UINT16 SegmentSelector;\r
27 UINT16 Attributes;\r
28 UINT16 OffsetHigh;\r
29} INTERRUPT_GATE_DESCRIPTOR;\r
30\r
31#define INTERRUPT_GATE_ATTRIBUTE 0x8e00\r
32\r
33#pragma pack()\r
34/**\r
35 Set a IDT entry for interrupt vector 3 for debug purpose.\r
36\r
37 @param AcpiS3Context a pointer to a structure of ACPI_S3_CONTEXT\r
38\r
39**/\r
40VOID\r
41SetIdtEntry (\r
42 IN ACPI_S3_CONTEXT *AcpiS3Context\r
43 )\r
44{\r
45 INTERRUPT_GATE_DESCRIPTOR *IdtEntry;\r
46 IA32_DESCRIPTOR *IdtDescriptor;\r
47 UINTN S3DebugBuffer;\r
48\r
49 //\r
50 // Restore IDT for debug\r
51 //\r
52 IdtDescriptor = (IA32_DESCRIPTOR *) (UINTN) (AcpiS3Context->IdtrProfile);\r
53 IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
54 S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);\r
55\r
56 IdtEntry->OffsetLow = (UINT16)S3DebugBuffer;\r
57 IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();\r
58 IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;\r
59 IdtEntry->OffsetHigh = (UINT16)(S3DebugBuffer >> 16);\r
60\r
61 AsmWriteIdtr (IdtDescriptor);\r
62}\r
63\r