//\r
// private header files\r
//\r
-#include "PlDebugSupport.h"\r
+#include "DebugSupport.h"\r
\r
//\r
// This the global main table to keep track of the interrupts\r
//\r
IDT_ENTRY *IdtEntryTable = NULL;\r
-DESCRIPTOR NullDesc = 0;\r
+IA32_IDT_GATE_DESCRIPTOR NullDesc = {0};\r
\r
/**\r
- Allocate pool for a new IDT entry stub.\r
+ Read IDT Gate Descriptor from IDT Table.\r
\r
- Copy the generic stub into the new buffer and fixup the vector number\r
- and jump target address.\r
-\r
- @param ExceptionType This is the exception type that the new stub will be created\r
- for.\r
- @param Stub On successful exit, *Stub contains the newly allocated entry stub.\r
-\r
- @retval EFI_SUCCESS Always.\r
+ @param Vector Specifies vector number.\r
+ @param IdtGateDecriptor Pointer to IDT Gate Descriptor read from IDT Table.\r
\r
**/\r
-EFI_STATUS\r
-CreateEntryStub (\r
- IN EFI_EXCEPTION_TYPE ExceptionType,\r
- OUT VOID **Stub\r
+VOID ReadIdtGateDecriptor (\r
+ IN EFI_EXCEPTION_TYPE Vector,\r
+ OUT IA32_IDT_GATE_DESCRIPTOR *IdtGateDecriptor\r
)\r
{\r
- UINT8 *StubCopy;\r
+ IA32_DESCRIPTOR IdtrValue;\r
+ IA32_IDT_GATE_DESCRIPTOR *IdtTable;\r
\r
- StubCopy = *Stub;\r
+ AsmReadIdtr (&IdtrValue);\r
+ IdtTable = (IA32_IDT_GATE_DESCRIPTOR *) IdtrValue.Base;\r
\r
- //\r
- // Fixup the stub code for this vector\r
- //\r
+ CopyMem ((VOID *) IdtGateDecriptor, (VOID *) &(IdtTable)[Vector], sizeof (IA32_IDT_GATE_DESCRIPTOR));\r
+}\r
+/**\r
+ Write IDT Gate Descriptor into IDT Table.\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
+ @param Vector Specifies vector number.\r
+ @param IdtGateDecriptor Pointer to IDT Gate Descriptor written into IDT Table.\r
\r
- //\r
- // poke in the exception type so the second push pushes the exception type\r
- //\r
- StubCopy[0x0c] = (UINT8) ExceptionType;\r
+**/\r
+VOID WriteIdtGateDecriptor (\r
+ EFI_EXCEPTION_TYPE Vector,\r
+ IA32_IDT_GATE_DESCRIPTOR *IdtGateDecriptor\r
+ )\r
+{\r
+ IA32_DESCRIPTOR IdtrValue;\r
+ IA32_IDT_GATE_DESCRIPTOR *IdtTable;\r
\r
- //\r
- // fixup the jump target to point to the common entry\r
- //\r
- *(UINT32 *) &StubCopy[0x0e] = (UINT32) CommonIdtEntry - (UINT32) &StubCopy[StubSize];\r
+ AsmReadIdtr (&IdtrValue);\r
+ IdtTable = (IA32_IDT_GATE_DESCRIPTOR *) IdtrValue.Base;\r
\r
- return EFI_SUCCESS;\r
+ CopyMem ((VOID *) &(IdtTable)[Vector], (VOID *) IdtGateDecriptor, sizeof (IA32_IDT_GATE_DESCRIPTOR));\r
}\r
\r
+\r
/**\r
Creates a nes entry stub. Then saves the current IDT entry and replaces it\r
with an interrupt gate for the new entry point. The IdtEntryTable is updated\r
Status = CreateEntryStub (ExceptionType, (VOID **) &IdtEntryTable[ExceptionType].StubEntry);\r
if (Status == EFI_SUCCESS) {\r
OldIntFlagState = WriteInterruptFlag (0);\r
- READ_IDT (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
+ ReadIdtGateDecriptor (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
\r
- ((UINT16 *) &IdtEntryTable[ExceptionType].OrigVector)[0] = ((UINT16 *) &IdtEntryTable[ExceptionType].OrigDesc)[0];\r
- ((UINT16 *) &IdtEntryTable[ExceptionType].OrigVector)[1] = ((UINT16 *) &IdtEntryTable[ExceptionType].OrigDesc)[3];\r
+ IdtEntryTable[ExceptionType].OrigVector = (DEBUG_PROC) GetProcedureEntryPoint (&(IdtEntryTable[ExceptionType].OrigDesc));\r
\r
Vect2Desc (&IdtEntryTable[ExceptionType].NewDesc, IdtEntryTable[ExceptionType].StubEntry);\r
IdtEntryTable[ExceptionType].RegisteredCallback = NewCallback;\r
- WRITE_IDT (ExceptionType, &(IdtEntryTable[ExceptionType].NewDesc));\r
+ WriteIdtGateDecriptor (ExceptionType, &(IdtEntryTable[ExceptionType].NewDesc));\r
WriteInterruptFlag (OldIntFlagState);\r
}\r
\r
BOOLEAN OldIntFlagState;\r
\r
OldIntFlagState = WriteInterruptFlag (0);\r
- WRITE_IDT (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
+ WriteIdtGateDecriptor (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
WriteInterruptFlag (OldIntFlagState);\r
\r
return EFI_SUCCESS;\r
}\r
\r
-/**\r
- This is the main worker function that manages the state of the interrupt\r
- handlers. It both installs and uninstalls interrupt handlers based on the\r
- value of NewCallback. If NewCallback is NULL, then uninstall is indicated.\r
- If NewCallback is non-NULL, then install is indicated.\r
-\r
- @param NewCallback If non-NULL, NewCallback specifies the new handler to register.\r
- If NULL, specifies that the previously registered handler should\r
- be uninstalled.\r
- @param ExceptionType Indicates which entry to manage.\r
-\r
- @retval EFI_SUCCESS Process is ok.\r
- @retval EFI_INVALID_PARAMETER Requested uninstalling a handler from a vector that has\r
- no handler registered for it\r
- @retval EFI_ALREADY_STARTED Requested install to a vector that already has a handler registered.\r
- @retval others Possible return values are passed through from UnHookEntry and HookEntry.\r
-\r
-**/\r
-EFI_STATUS\r
-ManageIdtEntryTable (\r
- VOID (*NewCallback)(),\r
- EFI_EXCEPTION_TYPE ExceptionType\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- Status = EFI_SUCCESS;\r
-\r
- if (!FeaturePcdGet (PcdNtEmulatorEnable)) {\r
- if (COMPARE_DESCRIPTOR (&IdtEntryTable[ExceptionType].NewDesc, &NullDesc)) {\r
- //\r
- // we've already installed to this vector\r
- //\r
- if (NewCallback != NULL) {\r
- //\r
- // if the input handler is non-null, error\r
- //\r
- Status = EFI_ALREADY_STARTED;\r
- } else {\r
- Status = UnhookEntry (ExceptionType);\r
- }\r
- } else {\r
- //\r
- // no user handler installed on this vector\r
- //\r
- if (NewCallback == NULL) {\r
- //\r
- // if the input handler is null, error\r
- //\r
- Status = EFI_INVALID_PARAMETER;\r
- } else {\r
- Status = HookEntry (ExceptionType, NewCallback);\r
- }\r
- }\r
- }\r
-\r
- return Status;\r
-}\r
-\r
/**\r
This is a DebugSupport protocol member function, hard\r
coded to support only 1 processor for now.\r