+/** @file\r
+ Set a IDT entry for debug purpose\r
+\r
+ Set a IDT entry for interrupt vector 3 for debug purpose for x64 platform\r
+\r
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include "ScriptExecute.h"\r
+//\r
+// INTERRUPT_GATE_DESCRIPTOR and SetIdtEntry () are used to setup IDT to do debug\r
+//\r
+\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+ UINT16 Offset15To0;\r
+ UINT16 SegmentSelector;\r
+ UINT16 Attributes;\r
+ UINT16 Offset31To16;\r
+ UINT32 Offset63To32;\r
+ UINT32 Reserved;\r
+} INTERRUPT_GATE_DESCRIPTOR;\r
+\r
+#define INTERRUPT_GATE_ATTRIBUTE 0x8e00\r
+\r
+#pragma pack()\r
+/**\r
+ Set a IDT entry for interrupt vector 3 for debug purpose.\r
+\r
+ @param AcpiS3Context a pointer to a structure of ACPI_S3_CONTEXT\r
+\r
+**/\r
+VOID\r
+SetIdtEntry (\r
+ IN ACPI_S3_CONTEXT *AcpiS3Context\r
+ )\r
+{\r
+ INTERRUPT_GATE_DESCRIPTOR *IdtEntry;\r
+ IA32_DESCRIPTOR *IdtDescriptor;\r
+ UINTN S3DebugBuffer;\r
+\r
+ //\r
+ // Restore IDT for debug\r
+ //\r
+ IdtDescriptor = (IA32_DESCRIPTOR *) (UINTN) (AcpiS3Context->IdtrProfile);\r
+ IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));\r
+ S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);\r
+\r
+ IdtEntry->Offset15To0 = (UINT16)S3DebugBuffer;\r
+ IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();;\r
+ IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;\r
+ IdtEntry->Offset31To16 = (UINT16)(S3DebugBuffer >> 16);\r
+ IdtEntry->Offset63To32 = (UINT32)(S3DebugBuffer >> 32);\r
+ IdtEntry->Reserved = 0;\r
+\r
+ AsmWriteIdtr (IdtDescriptor);\r
+}\r
+\r