diff options
Diffstat (limited to 'EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c')
-rw-r--r-- | EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c | 80 |
1 files changed, 45 insertions, 35 deletions
diff --git a/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c b/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c index 3f12a76d6c..8b907ee6e1 100644 --- a/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c +++ b/EdkModulePkg/Universal/DebugSupport/Dxe/x64/plDebugSupport.c @@ -46,39 +46,30 @@ Returns: {
UINT8 *StubCopy;
+ StubCopy = *Stub;
+
//
- // First, allocate a new buffer and copy the stub code into it
+ // Fixup the stub code for this vector
//
- *Stub = AllocatePool (StubSize);
- if (*Stub != NULL) {
- StubCopy = *Stub;
- CopyMem (StubCopy, InterruptEntryStub, StubSize);
-
- //
- // Next fixup the stub code for this vector
- //
-
- // The stub code looks like this:
- //
- // 00000000 6A 00 push 0 ; push vector number - will be modified before installed
- // 00000002 E9 db 0e9h ; jump rel32
- // 00000003 00000000 dd 0 ; fixed up to relative address of CommonIdtEntry
- //
- //
- // poke in the exception type so the second push pushes the exception type
- //
- StubCopy[0x1] = (UINT8) ExceptionType;
+ // The stub code looks like this:
+ //
+ // 00000000 6A 00 push 0 ; push vector number - will be modified before installed
+ // 00000002 E9 db 0e9h ; jump rel32
+ // 00000003 00000000 dd 0 ; fixed up to relative address of CommonIdtEntry
+ //
- //
- // fixup the jump target to point to the common entry
- //
- *(UINT32 *) &StubCopy[0x3] = (UINT32)((UINTN) CommonIdtEntry - (UINTN) &StubCopy[StubSize]);
+ //
+ // poke in the exception type so the second push pushes the exception type
+ //
+ StubCopy[0x1] = (UINT8) ExceptionType;
- return EFI_SUCCESS;
- }
+ //
+ // fixup the jump target to point to the common entry
+ //
+ *(UINT32 *) &StubCopy[0x3] = (UINT32)((UINTN) CommonIdtEntry - (UINTN) &StubCopy[StubSize]);
- return EFI_OUT_OF_RESOURCES;
+ return EFI_SUCCESS;
}
STATIC
@@ -150,8 +141,6 @@ Returns: OldIntFlagState = WriteInterruptFlag (0);
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));
- FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);
- ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));
WriteInterruptFlag (OldIntFlagState);
return EFI_SUCCESS;
@@ -359,16 +348,37 @@ Returns: --*/
{
+ EFI_EXCEPTION_TYPE ExceptionType;
+
if (!FxStorSupport ()) {
return EFI_UNSUPPORTED;
- } else {
- IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);
- if (IdtEntryTable != NULL) {
- return EFI_SUCCESS;
- } else {
- return EFI_OUT_OF_RESOURCES;
+ }
+
+ IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);
+ if (IdtEntryTable == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {
+ IdtEntryTable[ExceptionType].StubEntry = (DEBUG_PROC) (UINTN) AllocatePool (StubSize);
+ if (IdtEntryTable[ExceptionType].StubEntry == NULL) {
+ goto ErrorCleanup;
}
+
+ CopyMem ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry, InterruptEntryStub, StubSize);
}
+ return EFI_SUCCESS;
+
+ErrorCleanup:
+
+ for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {
+ if (IdtEntryTable[ExceptionType].StubEntry != NULL) {
+ FreePool ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry);
+ }
+ }
+ FreePool (IdtEntryTable);
+
+ return EFI_OUT_OF_RESOURCES;
}
EFI_STATUS
|