]>
Commit | Line | Data |
---|---|---|
be46cd5f | 1 | /** @file\r |
2 | Set a IDT entry for debug purpose\r | |
3 | \r | |
4 | Set a IDT entry for interrupt vector 3 for debug purpose for IA32 platform\r | |
5 | \r | |
6 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
7 | \r | |
8 | This program and the accompanying materials\r | |
9 | are licensed and made available under the terms and conditions of the BSD License\r | |
10 | which accompanies this distribution. The full text of the license may be found at\r | |
11 | http://opensource.org/licenses/bsd-license.php\r | |
12 | \r | |
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
14 | WITHOUT 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 | |
24 | typedef 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 | |
40 | VOID\r | |
41 | SetIdtEntry (\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 |