and $0x200,%eax
shr $0x9,%eax
mov 0x8(%ebp),%ecx
- or %ecx,%ecx
+ or %cl,%cl
jne ASM_PFX(WriteInterruptFlag+0x17)
cli
jmp ASM_PFX(WriteInterruptFlag+0x18)
and eax, 200h\r
shr eax, 9\r
mov ecx, State\r
- .IF ecx == 0\r
+ .IF cl == 0\r
cli\r
.ELSE\r
sti\r
{\r
UINT8 *StubCopy;\r
\r
+ StubCopy = *Stub;\r
+\r
//\r
- // First, allocate a new buffer and copy the stub code into it\r
+ // Fixup the stub code for this vector\r
//\r
- *Stub = AllocatePool (StubSize);\r
- if (*Stub != NULL) {\r
- StubCopy = *Stub;\r
- CopyMem (StubCopy, InterruptEntryStub, StubSize);\r
-\r
- //\r
- // Next fixup the stub code for this vector\r
- //\r
-\r
- // The stub code looks like this:\r
- //\r
- // 00000000 89 25 00000004 R mov AppEsp, esp ; save stack top\r
- // 00000006 BC 00008014 R mov esp, offset DbgStkBot ; switch to debugger stack\r
- // 0000000B 6A 00 push 0 ; push vector number - will be modified before installed\r
- // 0000000D E9 db 0e9h ; jump rel32\r
- // 0000000E 00000000 dd 0 ; fixed up to relative address of CommonIdtEntry\r
- //\r
-\r
- //\r
- // poke in the exception type so the second push pushes the exception type\r
- //\r
- StubCopy[0x0c] = (UINT8) ExceptionType;\r
-\r
- //\r
- // fixup the jump target to point to the common entry\r
- //\r
- *(UINT32 *) &StubCopy[0x0e] = (UINT32) CommonIdtEntry - (UINT32) &StubCopy[StubSize];\r
-\r
- return EFI_SUCCESS;\r
- }\r
\r
- return EFI_OUT_OF_RESOURCES;\r
+ // The stub code looks like this:\r
+ //\r
+ // 00000000 89 25 00000004 R mov AppEsp, esp ; save stack top\r
+ // 00000006 BC 00008014 R mov esp, offset DbgStkBot ; switch to debugger stack\r
+ // 0000000B 6A 00 push 0 ; push vector number - will be modified before installed\r
+ // 0000000D E9 db 0e9h ; jump rel32\r
+ // 0000000E 00000000 dd 0 ; fixed up to relative address of CommonIdtEntry\r
+ //\r
+\r
+ //\r
+ // poke in the exception type so the second push pushes the exception type\r
+ //\r
+ StubCopy[0x0c] = (UINT8) ExceptionType;\r
+\r
+ //\r
+ // fixup the jump target to point to the common entry\r
+ //\r
+ *(UINT32 *) &StubCopy[0x0e] = (UINT32) CommonIdtEntry - (UINT32) &StubCopy[StubSize];\r
+\r
+ return EFI_SUCCESS;\r
}\r
\r
STATIC\r
\r
OldIntFlagState = WriteInterruptFlag (0);\r
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
- FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);\r
- ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));\r
WriteInterruptFlag (OldIntFlagState);\r
\r
return EFI_SUCCESS;\r
\r
--*/\r
{\r
+ EFI_EXCEPTION_TYPE ExceptionType;\r
+\r
if (!FxStorSupport ()) {\r
return EFI_UNSUPPORTED;\r
- } else {\r
- IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);\r
- if (IdtEntryTable != NULL) {\r
- return EFI_SUCCESS;\r
- } else {\r
- return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);\r
+ if (IdtEntryTable == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {\r
+ IdtEntryTable[ExceptionType].StubEntry = (DEBUG_PROC) (UINTN) AllocatePool (StubSize);\r
+ if (IdtEntryTable[ExceptionType].StubEntry == NULL) {\r
+ goto ErrorCleanup;\r
}\r
+\r
+ CopyMem ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry, InterruptEntryStub, StubSize);\r
}\r
+ return EFI_SUCCESS;\r
+\r
+ErrorCleanup:\r
+\r
+ for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {\r
+ if (IdtEntryTable[ExceptionType].StubEntry != NULL) {\r
+ FreePool ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry);\r
+ }\r
+ }\r
+ FreePool (IdtEntryTable);\r
+\r
+ return EFI_OUT_OF_RESOURCES;\r
}\r
\r
EFI_STATUS\r
\r
typedef UINT64 DESCRIPTOR;\r
\r
+typedef\r
+VOID\r
+(*DEBUG_PROC) (\r
+ VOID\r
+ )\r
+;\r
+\r
typedef struct {\r
DESCRIPTOR OrigDesc;\r
- VOID (*OrigVector) (VOID);\r
+ DEBUG_PROC OrigVector;\r
DESCRIPTOR NewDesc;\r
- VOID (*StubEntry) (VOID);\r
+ DEBUG_PROC StubEntry;\r
VOID (*RegisteredCallback) ();\r
} IDT_ENTRY;\r
\r
push rbp\r
mov rbp, rsp\r
\r
- sub rsp, 8h\r
- sidt QWORD PTR [rbp - 6]\r
- mov rax, QWORD PTR [rbp - 4]\r
+ sidt QWORD PTR [rbp - 0ah]\r
+ mov rax, QWORD PTR [rbp - 8h]\r
\r
mov rsp, rbp\r
pop rbp\r
{\r
UINT8 *StubCopy;\r
\r
+ StubCopy = *Stub;\r
+\r
//\r
- // First, allocate a new buffer and copy the stub code into it\r
+ // Fixup the stub code for this vector\r
//\r
- *Stub = AllocatePool (StubSize);\r
- if (*Stub != NULL) {\r
- StubCopy = *Stub;\r
- CopyMem (StubCopy, InterruptEntryStub, StubSize);\r
-\r
- //\r
- // Next fixup the stub code for this vector\r
- //\r
-\r
- // The stub code looks like this:\r
- //\r
- // 00000000 6A 00 push 0 ; push vector number - will be modified before installed\r
- // 00000002 E9 db 0e9h ; jump rel32\r
- // 00000003 00000000 dd 0 ; fixed up to relative address of CommonIdtEntry\r
- //\r
\r
- //\r
- // poke in the exception type so the second push pushes the exception type\r
- //\r
- StubCopy[0x1] = (UINT8) ExceptionType;\r
+ // The stub code looks like this:\r
+ //\r
+ // 00000000 6A 00 push 0 ; push vector number - will be modified before installed\r
+ // 00000002 E9 db 0e9h ; jump rel32\r
+ // 00000003 00000000 dd 0 ; fixed up to relative address of CommonIdtEntry\r
+ //\r
\r
- //\r
- // fixup the jump target to point to the common entry\r
- //\r
- *(UINT32 *) &StubCopy[0x3] = (UINT32)((UINTN) CommonIdtEntry - (UINTN) &StubCopy[StubSize]);\r
+ //\r
+ // poke in the exception type so the second push pushes the exception type\r
+ //\r
+ StubCopy[0x1] = (UINT8) ExceptionType;\r
\r
- return EFI_SUCCESS;\r
- }\r
+ //\r
+ // fixup the jump target to point to the common entry\r
+ //\r
+ *(UINT32 *) &StubCopy[0x3] = (UINT32)((UINTN) CommonIdtEntry - (UINTN) &StubCopy[StubSize]);\r
\r
- return EFI_OUT_OF_RESOURCES;\r
+ return EFI_SUCCESS;\r
}\r
\r
STATIC\r
\r
OldIntFlagState = WriteInterruptFlag (0);\r
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
- FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);\r
- ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));\r
WriteInterruptFlag (OldIntFlagState);\r
\r
return EFI_SUCCESS;\r
\r
--*/\r
{\r
+ EFI_EXCEPTION_TYPE ExceptionType;\r
+\r
if (!FxStorSupport ()) {\r
return EFI_UNSUPPORTED;\r
- } else {\r
- IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);\r
- if (IdtEntryTable != NULL) {\r
- return EFI_SUCCESS;\r
- } else {\r
- return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ IdtEntryTable = AllocateZeroPool (sizeof (IDT_ENTRY) * NUM_IDT_ENTRIES);\r
+ if (IdtEntryTable == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {\r
+ IdtEntryTable[ExceptionType].StubEntry = (DEBUG_PROC) (UINTN) AllocatePool (StubSize);\r
+ if (IdtEntryTable[ExceptionType].StubEntry == NULL) {\r
+ goto ErrorCleanup;\r
}\r
+\r
+ CopyMem ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry, InterruptEntryStub, StubSize);\r
}\r
+ return EFI_SUCCESS;\r
+\r
+ErrorCleanup:\r
+\r
+ for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {\r
+ if (IdtEntryTable[ExceptionType].StubEntry != NULL) {\r
+ FreePool ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry);\r
+ }\r
+ }\r
+ FreePool (IdtEntryTable);\r
+\r
+ return EFI_OUT_OF_RESOURCES;\r
}\r
\r
EFI_STATUS\r
UINT64 High;\r
} DESCRIPTOR;\r
\r
+typedef\r
+VOID\r
+(*DEBUG_PROC) (\r
+ VOID\r
+ )\r
+;\r
+\r
typedef struct {\r
DESCRIPTOR OrigDesc;\r
- VOID (*OrigVector) (VOID);\r
+ DEBUG_PROC OrigVector;\r
DESCRIPTOR NewDesc;\r
- VOID (*StubEntry) (VOID);\r
+ DEBUG_PROC StubEntry;\r
VOID (*RegisteredCallback) ();\r
} IDT_ENTRY;\r
\r