]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/IA32/SetIdtEntry.c
1. DxeIplPeim will locate Vector Handoff Table PPI and build GUIDed HOB if it has.
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / 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) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
7
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17 #include "ScriptExecute.h"
18
19 /**
20 Set a IDT entry for interrupt vector 3 for debug purpose.
21
22 @param AcpiS3Context a pointer to a structure of ACPI_S3_CONTEXT
23
24 **/
25 VOID
26 SetIdtEntry (
27 IN ACPI_S3_CONTEXT *AcpiS3Context
28 )
29 {
30 IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
31 IA32_DESCRIPTOR *IdtDescriptor;
32 UINTN S3DebugBuffer;
33 EFI_STATUS Status;
34
35 //
36 // Restore IDT for debug
37 //
38 IdtDescriptor = (IA32_DESCRIPTOR *) (UINTN) (AcpiS3Context->IdtrProfile);
39 AsmWriteIdtr (IdtDescriptor);
40
41 //
42 // Setup the default CPU exception handlers
43 //
44 Status = InitializeCpuExceptionHandlers (NULL);
45 ASSERT_EFI_ERROR (Status);
46
47 DEBUG_CODE (
48 //
49 // Update IDT entry INT3 if the instruction is valid in it
50 //
51 S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);
52 if (*(UINTN *)S3DebugBuffer != (UINTN) -1) {
53 IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (IA32_IDT_GATE_DESCRIPTOR)));
54 IdtEntry->Bits.OffsetLow = (UINT16)S3DebugBuffer;
55 IdtEntry->Bits.Selector = (UINT16)AsmReadCs ();
56 IdtEntry->Bits.Reserved_0 = 0;
57 IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
58 IdtEntry->Bits.OffsetHigh = (UINT16)(S3DebugBuffer >> 16);
59 }
60 );
61 }
62