mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 07:34:06 +02:00
Use IA32_IDT_GATE_DESCRIPTOR defined in BaseLib instead of local struct INTERRUPT_GATE_DESCRIPTOR.
Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13948 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
54f8fc6d75
commit
68cc1ba3b6
@ -15,22 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
#include "ScriptExecute.h"
|
#include "ScriptExecute.h"
|
||||||
//
|
|
||||||
// INTERRUPT_GATE_DESCRIPTOR and SetIdtEntry () are used to setup IDT to do debug
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma pack(1)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT16 OffsetLow;
|
|
||||||
UINT16 SegmentSelector;
|
|
||||||
UINT16 Attributes;
|
|
||||||
UINT16 OffsetHigh;
|
|
||||||
} INTERRUPT_GATE_DESCRIPTOR;
|
|
||||||
|
|
||||||
#define INTERRUPT_GATE_ATTRIBUTE 0x8e00
|
|
||||||
|
|
||||||
#pragma pack()
|
|
||||||
/**
|
/**
|
||||||
Set a IDT entry for interrupt vector 3 for debug purpose.
|
Set a IDT entry for interrupt vector 3 for debug purpose.
|
||||||
|
|
||||||
@ -42,7 +27,7 @@ SetIdtEntry (
|
|||||||
IN ACPI_S3_CONTEXT *AcpiS3Context
|
IN ACPI_S3_CONTEXT *AcpiS3Context
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
INTERRUPT_GATE_DESCRIPTOR *IdtEntry;
|
IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
|
||||||
IA32_DESCRIPTOR *IdtDescriptor;
|
IA32_DESCRIPTOR *IdtDescriptor;
|
||||||
UINTN S3DebugBuffer;
|
UINTN S3DebugBuffer;
|
||||||
|
|
||||||
@ -63,11 +48,12 @@ SetIdtEntry (
|
|||||||
//
|
//
|
||||||
S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);
|
S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);
|
||||||
if (*(UINTN *)S3DebugBuffer != (UINTN) -1) {
|
if (*(UINTN *)S3DebugBuffer != (UINTN) -1) {
|
||||||
IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));
|
IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (IA32_IDT_GATE_DESCRIPTOR)));
|
||||||
IdtEntry->OffsetLow = (UINT16)S3DebugBuffer;
|
IdtEntry->Bits.OffsetLow = (UINT16)S3DebugBuffer;
|
||||||
IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();;
|
IdtEntry->Bits.Selector = (UINT16)AsmReadCs ();
|
||||||
IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;
|
IdtEntry->Bits.Reserved_0 = 0;
|
||||||
IdtEntry->OffsetHigh = (UINT16)(S3DebugBuffer >> 16);
|
IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
|
||||||
|
IdtEntry->Bits.OffsetHigh = (UINT16)(S3DebugBuffer >> 16);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -15,24 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
#include "ScriptExecute.h"
|
#include "ScriptExecute.h"
|
||||||
//
|
|
||||||
// INTERRUPT_GATE_DESCRIPTOR and SetIdtEntry () are used to setup IDT to do debug
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma pack(1)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT16 Offset15To0;
|
|
||||||
UINT16 SegmentSelector;
|
|
||||||
UINT16 Attributes;
|
|
||||||
UINT16 Offset31To16;
|
|
||||||
UINT32 Offset63To32;
|
|
||||||
UINT32 Reserved;
|
|
||||||
} INTERRUPT_GATE_DESCRIPTOR;
|
|
||||||
|
|
||||||
#define INTERRUPT_GATE_ATTRIBUTE 0x8e00
|
|
||||||
|
|
||||||
#pragma pack()
|
|
||||||
|
|
||||||
#define IA32_PG_P BIT0
|
#define IA32_PG_P BIT0
|
||||||
#define IA32_PG_RW BIT1
|
#define IA32_PG_RW BIT1
|
||||||
@ -61,7 +43,7 @@ PageFaultHandlerHook (
|
|||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
HookPageFaultHandler (
|
HookPageFaultHandler (
|
||||||
IN INTERRUPT_GATE_DESCRIPTOR *IdtEntry
|
IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 RegEax;
|
UINT32 RegEax;
|
||||||
@ -85,13 +67,14 @@ HookPageFaultHandler (
|
|||||||
//
|
//
|
||||||
// Set Page Fault entry to catch >4G access
|
// Set Page Fault entry to catch >4G access
|
||||||
//
|
//
|
||||||
mOriginalHandler = (VOID *)(UINTN)(LShiftU64 (IdtEntry->Offset63To32, 32) + IdtEntry->Offset15To0 + (IdtEntry->Offset31To16 << 16));
|
mOriginalHandler = (VOID *)(UINTN)(LShiftU64 (IdtEntry->Bits.OffsetUpper, 32) + IdtEntry->Bits.OffsetLow + (IdtEntry->Bits.OffsetHigh << 16));
|
||||||
IdtEntry->Offset15To0 = (UINT16)((UINTN)PageFaultHandlerHook);
|
IdtEntry->Bits.OffsetLow = (UINT16)((UINTN)PageFaultHandlerHook);
|
||||||
IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();
|
IdtEntry->Bits.Selector = (UINT16)AsmReadCs ();
|
||||||
IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;
|
IdtEntry->Bits.Reserved_0 = 0;
|
||||||
IdtEntry->Offset31To16 = (UINT16)((UINTN)PageFaultHandlerHook >> 16);
|
IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
|
||||||
IdtEntry->Offset63To32 = (UINT32)((UINTN)PageFaultHandlerHook >> 32);
|
IdtEntry->Bits.OffsetHigh = (UINT16)((UINTN)PageFaultHandlerHook >> 16);
|
||||||
IdtEntry->Reserved = 0;
|
IdtEntry->Bits.OffsetUpper = (UINT32)((UINTN)PageFaultHandlerHook >> 32);
|
||||||
|
IdtEntry->Bits.Reserved_1 = 0;
|
||||||
|
|
||||||
if (mPage1GSupport) {
|
if (mPage1GSupport) {
|
||||||
mS3NvsPageTableAddress = (UINTN)(AsmReadCr3 () & mPhyMask) + EFI_PAGES_TO_SIZE(2);
|
mS3NvsPageTableAddress = (UINTN)(AsmReadCr3 () & mPhyMask) + EFI_PAGES_TO_SIZE(2);
|
||||||
@ -111,7 +94,7 @@ SetIdtEntry (
|
|||||||
IN ACPI_S3_CONTEXT *AcpiS3Context
|
IN ACPI_S3_CONTEXT *AcpiS3Context
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
INTERRUPT_GATE_DESCRIPTOR *IdtEntry;
|
IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
|
||||||
IA32_DESCRIPTOR *IdtDescriptor;
|
IA32_DESCRIPTOR *IdtDescriptor;
|
||||||
UINTN S3DebugBuffer;
|
UINTN S3DebugBuffer;
|
||||||
|
|
||||||
@ -132,17 +115,18 @@ SetIdtEntry (
|
|||||||
//
|
//
|
||||||
S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);
|
S3DebugBuffer = (UINTN) (AcpiS3Context->S3DebugBufferAddress);
|
||||||
if (*(UINTN *)S3DebugBuffer != (UINTN) -1) {
|
if (*(UINTN *)S3DebugBuffer != (UINTN) -1) {
|
||||||
IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));
|
IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (3 * sizeof (IA32_IDT_GATE_DESCRIPTOR)));
|
||||||
IdtEntry->Offset15To0 = (UINT16)S3DebugBuffer;
|
IdtEntry->Bits.OffsetLow = (UINT16)S3DebugBuffer;
|
||||||
IdtEntry->SegmentSelector = (UINT16)AsmReadCs ();
|
IdtEntry->Bits.Selector = (UINT16)AsmReadCs ();
|
||||||
IdtEntry->Attributes = (UINT16)INTERRUPT_GATE_ATTRIBUTE;
|
IdtEntry->Bits.Reserved_0 = 0;
|
||||||
IdtEntry->Offset31To16 = (UINT16)(S3DebugBuffer >> 16);
|
IdtEntry->Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
|
||||||
IdtEntry->Offset63To32 = (UINT32)(S3DebugBuffer >> 32);
|
IdtEntry->Bits.OffsetHigh = (UINT16)(S3DebugBuffer >> 16);
|
||||||
IdtEntry->Reserved = 0;
|
IdtEntry->Bits.OffsetUpper = (UINT32)(S3DebugBuffer >> 32);
|
||||||
|
IdtEntry->Bits.Reserved_1 = 0;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
IdtEntry = (INTERRUPT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (14 * sizeof (INTERRUPT_GATE_DESCRIPTOR)));
|
IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *)(IdtDescriptor->Base + (14 * sizeof (IA32_IDT_GATE_DESCRIPTOR)));
|
||||||
HookPageFaultHandler (IdtEntry);
|
HookPageFaultHandler (IdtEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user