]> git.proxmox.com Git - mirror_edk2.git/commitdiff
code scrub for DebugSpport Module.
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 11 Dec 2008 08:38:20 +0000 (08:38 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 11 Dec 2008 08:38:20 +0000 (08:38 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6997 6f19259b-4bc3-4df7-8a09-765794883524

12 files changed:
MdeModulePkg/Universal/DebugSupportDxe/DebugSupport.c
MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
MdeModulePkg/Universal/DebugSupportDxe/Ia32/AsmFuncs.S
MdeModulePkg/Universal/DebugSupportDxe/Ia32/AsmFuncs.asm
MdeModulePkg/Universal/DebugSupportDxe/Ia32/DebugSupport.h
MdeModulePkg/Universal/DebugSupportDxe/Ia32/PlDebugSupport.c
MdeModulePkg/Universal/DebugSupportDxe/Ia32/PlDebugSupportIa32.c
MdeModulePkg/Universal/DebugSupportDxe/Ipf/PlDebugSupport.c
MdeModulePkg/Universal/DebugSupportDxe/Ipf/PlDebugSupport.h
MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.S
MdeModulePkg/Universal/DebugSupportDxe/X64/AsmFuncs.asm
MdeModulePkg/Universal/DebugSupportDxe/X64/PlDebugSupportX64.c

index ed4d86038aa8d75b72f7d8a752e53e4d4139f613..4ef12cac19c74eb004bff9c389383630e995f82c 100644 (file)
@@ -12,15 +12,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
 \r
 **/\r
 \r
-//\r
-// private header files\r
-//\r
 #include "PlDebugSupport.h"\r
 \r
 #include "PlDebugSupport.h"\r
 \r
-//\r
-// This is a global that is the actual interface\r
-//\r
-EFI_DEBUG_SUPPORT_PROTOCOL  gDebugSupportProtocolInterface = {\r
+EFI_DEBUG_SUPPORT_PROTOCOL  mDebugSupportProtocolInterface = {\r
   EFI_ISA,\r
   GetMaximumProcessorIndex,\r
   RegisterPeriodicCallback,\r
   EFI_ISA,\r
   GetMaximumProcessorIndex,\r
   RegisterPeriodicCallback,\r
@@ -30,16 +24,16 @@ EFI_DEBUG_SUPPORT_PROTOCOL  gDebugSupportProtocolInterface = {
 \r
 \r
 /**\r
 \r
 \r
 /**\r
-  Debug Port Driver entry point. \r
+  Debug Support Driver entry point. \r
 \r
 \r
-  Checks to see there's not already a DebugSupport protocol installed for \r
-  the selected processor before installing protocol.\r
+  Checks to see if there's not already a Debug Support protocol installed for \r
+  the selected processor before installing it.\r
 \r
   @param[in] ImageHandle       The firmware allocated handle for the EFI image.  \r
   @param[in] SystemTable       A pointer to the EFI System Table.\r
   \r
   @retval EFI_SUCCESS          The entry point is executed successfully.\r
 \r
   @param[in] ImageHandle       The firmware allocated handle for the EFI image.  \r
   @param[in] SystemTable       A pointer to the EFI System Table.\r
   \r
   @retval EFI_SUCCESS          The entry point is executed successfully.\r
-  @retval EFI_ALREADY_STARTED  DebugSupport protocol is installed already.\r
+  @retval EFI_ALREADY_STARTED  DebugS upport protocol is installed already.\r
   @retval other                Some error occurs when executing this entry point.\r
 \r
 **/\r
   @retval other                Some error occurs when executing this entry point.\r
 \r
 **/\r
@@ -56,8 +50,6 @@ InitializeDebugSupportDriver (
   UINTN                       NumHandles;\r
   EFI_DEBUG_SUPPORT_PROTOCOL  *DebugSupportProtocolPtr;\r
 \r
   UINTN                       NumHandles;\r
   EFI_DEBUG_SUPPORT_PROTOCOL  *DebugSupportProtocolPtr;\r
 \r
-  //\r
-  //  Install Protocol Interface...\r
   //\r
   // First check to see that the debug support protocol for this processor\r
   // type is not already installed\r
   //\r
   // First check to see that the debug support protocol for this processor\r
   // type is not already installed\r
@@ -81,7 +73,10 @@ InitializeDebugSupportDriver (
                       NULL,\r
                       EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                       );\r
                       NULL,\r
                       EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                       );\r
-      if (Status == EFI_SUCCESS && DebugSupportProtocolPtr->Isa == EFI_ISA) {\r
+      if ((Status == EFI_SUCCESS) && (DebugSupportProtocolPtr->Isa == EFI_ISA)) {\r
+        //\r
+        // a Debug Support protocol has been installed for this processor\r
+        //\r
         FreePool (HandlePtr);\r
         Status = EFI_ALREADY_STARTED;\r
         goto ErrExit;\r
         FreePool (HandlePtr);\r
         Status = EFI_ALREADY_STARTED;\r
         goto ErrExit;\r
@@ -109,7 +104,7 @@ InitializeDebugSupportDriver (
   LoadedImageProtocolPtr->Unload = PlUnloadDebugSupportDriver;\r
 \r
   //\r
   LoadedImageProtocolPtr->Unload = PlUnloadDebugSupportDriver;\r
 \r
   //\r
-  // Call hook for platform specific initialization\r
+  // Call hook for processor specific initialization \r
   //\r
   Status = PlInitializeDebugSupportDriver ();\r
   ASSERT (!EFI_ERROR (Status));\r
   //\r
   Status = PlInitializeDebugSupportDriver ();\r
   ASSERT (!EFI_ERROR (Status));\r
@@ -118,14 +113,14 @@ InitializeDebugSupportDriver (
   }\r
 \r
   //\r
   }\r
 \r
   //\r
-  // Install DebugSupport protocol to new handle\r
+  // Install Debug Support protocol to new handle\r
   //\r
   Handle = NULL;\r
   Status = gBS->InstallProtocolInterface (\r
                   &Handle,\r
                   &gEfiDebugSupportProtocolGuid,\r
                   EFI_NATIVE_INTERFACE,\r
   //\r
   Handle = NULL;\r
   Status = gBS->InstallProtocolInterface (\r
                   &Handle,\r
                   &gEfiDebugSupportProtocolGuid,\r
                   EFI_NATIVE_INTERFACE,\r
-                  &gDebugSupportProtocolInterface\r
+                  &mDebugSupportProtocolInterface\r
                   );\r
   ASSERT (!EFI_ERROR (Status));\r
   if (Status != EFI_SUCCESS) {\r
                   );\r
   ASSERT (!EFI_ERROR (Status));\r
   if (Status != EFI_SUCCESS) {\r
index d303847c75640d3cc12ef471d2b94aaa1e5df5ef..41ed14d453b2979133e4f4eaa66be9c5395d1aad 100644 (file)
@@ -77,7 +77,7 @@
 \r
 [Protocols]\r
   gEfiLoadedImageProtocolGuid                   # PROTOCOL ALWAYS_CONSUMED\r
 \r
 [Protocols]\r
   gEfiLoadedImageProtocolGuid                   # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiDebugSupportProtocolGuid                  # PROTOCOL SOMETIMES_PRODUCED\r
+  gEfiDebugSupportProtocolGuid                  # PROTOCOL ALWAYS_PRODUCED\r
 \r
 \r
 [FeaturePcd.IA32]\r
 \r
 \r
 [FeaturePcd.IA32]\r
index 965828cf56799c08b6ef19f7571a1c92b73b4462..b6f326d805a0735da86a7de5be55dbaec8f1cdcf 100644 (file)
@@ -37,33 +37,6 @@ ASM_PFX(FxStorSupport):
         pop    %ebx\r
         ret\r
 \r
         pop    %ebx\r
         ret\r
 \r
-.globl ASM_PFX(GetIdtr)\r
-ASM_PFX(GetIdtr):\r
-        push   %ebp\r
-        mov    %esp,%ebp\r
-        add    $0xfffffff8,%esp\r
-        sidtl  0xfffffffa(%ebp)\r
-        mov    0xfffffffc(%ebp),%eax\r
-        leave\r
-        ret\r
-\r
-.globl ASM_PFX(WriteInterruptFlag)\r
-ASM_PFX(WriteInterruptFlag):\r
-        push   %ebp\r
-        mov    %esp,%ebp\r
-        pushf\r
-        pop    %eax\r
-        and    $0x200,%eax\r
-        shr    $0x9,%eax\r
-        mov    0x8(%ebp),%ecx\r
-        or     %cl,%cl\r
-        jne    ASM_PFX(WriteInterruptFlag+0x17)\r
-        cli\r
-        jmp    ASM_PFX(WriteInterruptFlag+0x18)\r
-        sti\r
-        leave\r
-        ret\r
-\r
 .globl ASM_PFX(Vect2Desc)\r
 ASM_PFX(Vect2Desc):\r
         push   %ebp\r
 .globl ASM_PFX(Vect2Desc)\r
 ASM_PFX(Vect2Desc):\r
         push   %ebp\r
index cc776c867e093fe2ab7fa084bd0276ed343ef3a8..3cf75025ad51a5233cf71fb71f86b5e73c2ce3a3 100644 (file)
@@ -133,34 +133,6 @@ FxStorSupport   ENDP
 \r
 \r
 \r
 \r
 \r
 \r
-\r
-;------------------------------------------------------------------------------\r
-; BOOLEAN\r
-; WriteInterruptFlag (\r
-;   BOOLEAN NewState\r
-;   )\r
-;\r
-; Abstract: Programs interrupt flag to the requested state and returns previous\r
-;           state.\r
-;\r
-WriteInterruptFlag  PROC C PUBLIC State:DWORD\r
-\r
-                pushfd\r
-                pop     eax\r
-                and     eax, 200h\r
-                shr     eax, 9\r
-                mov     ecx, State\r
-                .IF     cl == 0\r
-                        cli\r
-                .ELSE\r
-                        sti\r
-                .ENDIF\r
-                ret\r
-\r
-WriteInterruptFlag  ENDP\r
-\r
-\r
-\r
 ;------------------------------------------------------------------------------\r
 ; void\r
 ; Vect2Desc (\r
 ;------------------------------------------------------------------------------\r
 ; void\r
 ; Vect2Desc (\r
index 72765507d539103923aa2bb17fd9624ebcb1473a..d1a126c1c29937bd08ac9ea5047d55b4507f0405 100644 (file)
@@ -15,7 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _DEBUG_SUPPORT_H_\r
 #define _DEBUG_SUPPORT_H_\r
 \r
 #ifndef _DEBUG_SUPPORT_H_\r
 #define _DEBUG_SUPPORT_H_\r
 \r
-\r
 #include <Uefi.h>\r
 \r
 #include <Protocol/DebugSupport.h>\r
 #include <Uefi.h>\r
 \r
 #include <Protocol/DebugSupport.h>\r
@@ -31,9 +30,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #define NUM_IDT_ENTRIES                 0x78\r
 #define SYSTEM_TIMER_VECTOR             0x68\r
 \r
 #define NUM_IDT_ENTRIES                 0x78\r
 #define SYSTEM_TIMER_VECTOR             0x68\r
-#define VECTOR_ENTRY_PAGES              1\r
-\r
-#define FF_FXSR                         (1 << 24)\r
 \r
 typedef\r
 VOID\r
 \r
 typedef\r
 VOID\r
@@ -49,11 +45,10 @@ typedef struct {
   VOID (*RegisteredCallback) ();\r
 } IDT_ENTRY;\r
 \r
   VOID (*RegisteredCallback) ();\r
 } IDT_ENTRY;\r
 \r
-extern EFI_SYSTEM_CONTEXT SystemContext;\r
-extern UINT8              InterruptEntryStub[];\r
-extern UINT32             StubSize;\r
-extern VOID              (*OrigVector) (VOID);\r
-extern IDT_ENTRY         *IdtEntryTable;\r
+extern UINT8                     InterruptEntryStub[];\r
+extern UINT32                    StubSize;\r
+extern VOID                      (*OrigVector) (VOID);\r
+extern IDT_ENTRY                 *IdtEntryTable;\r
 extern IA32_IDT_GATE_DESCRIPTOR  NullDesc;\r
 \r
 /**\r
 extern IA32_IDT_GATE_DESCRIPTOR  NullDesc;\r
 \r
 /**\r
@@ -90,21 +85,6 @@ Vect2Desc (
   VOID (*Vector) (VOID)\r
   );\r
 \r
   VOID (*Vector) (VOID)\r
   );\r
 \r
-/**\r
-  Programs interrupt flag to the requested state and returns previous\r
-  state.\r
-\r
-  @param  NewState    New interrupt status.\r
-\r
-  @retval TRUE     Old interrupt status is TRUE.\r
-  @retval FALSE    Old interrupt status is FALSE\r
-\r
-**/\r
-BOOLEAN\r
-WriteInterruptFlag (\r
-  BOOLEAN NewState\r
-  );\r
-\r
 /**\r
   Initializes driver's handler registration databas. \r
   \r
 /**\r
   Initializes driver's handler registration databas. \r
   \r
@@ -139,13 +119,16 @@ PlUnloadDebugSupportDriver (
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
-  This is a DebugSupport protocol member function, hard\r
-  coded to support only 1 processor for now.\r
-\r
-  @param  This                The DebugSupport instance\r
-  @param  MaxProcessorIndex   The maximuim supported processor index\r
+  Returns the maximum value that may be used for the ProcessorIndex parameter in\r
+  RegisterPeriodicCallback() and RegisterExceptionCallback().                   \r
+    \r
+  Hard coded to support only 1 processor for now.\r
 \r
 \r
-  @retval EFI_SUCCESS         Always returned with **MaxProcessorIndex set to 0.\r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+  @param  MaxProcessorIndex     Pointer to a caller-allocated UINTN in which the maximum supported\r
+                                processor index is returned. Always 0 returned.                                     \r
+                                \r
+  @retval EFI_SUCCESS           Always returned with **MaxProcessorIndex set to 0.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -156,15 +139,18 @@ GetMaximumProcessorIndex (
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
-  DebugSupport protocol member function.\r
-\r
-  @param  This               The DebugSupport instance\r
-  @param  ProcessorIndex     Which processor the callback applies to.\r
-  @param  PeriodicCallback   Callback function\r
-\r
-  @retval EFI_SUCCESS        Indicates the callback was registered.\r
-  @retval others             Callback was not registered.\r
-\r
+  Registers a function to be called back periodically in interrupt context.\r
+    \r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+  @param  ProcessorIndex        Specifies which processor the callback function applies to.\r
+  @param  PeriodicCallback      A pointer to a function of type PERIODIC_CALLBACK that is the main\r
+                                periodic entry point of the debug agent.\r
+                                \r
+  @retval EFI_SUCCESS           The function completed successfully.  \r
+  @retval EFI_ALREADY_STARTED   Non-NULL PeriodicCallback parameter when a callback\r
+                                function was previously registered.                \r
+  @retval EFI_OUT_OF_RESOURCES  System has insufficient memory resources to register new callback                               \r
+                                function. \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -175,37 +161,42 @@ RegisterPeriodicCallback (
   );\r
 \r
 /**\r
   );\r
 \r
 /**\r
-  DebugSupport protocol member function.\r
+  Registers a function to be called when a given processor exception occurs.\r
 \r
   This code executes in boot services context.\r
 \r
   This code executes in boot services context.\r
-\r
-  @param  This              The DebugSupport instance\r
-  @param  ProcessorIndex    Which processor the callback applies to.\r
-  @param  NewCallback       Callback function\r
-  @param  ExceptionType     Which exception to hook\r
-\r
-  @retval EFI_SUCCESS        Indicates the callback was registered.\r
-  @retval others             Callback was not registered.\r
-\r
+    \r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+  @param  ProcessorIndex        Specifies which processor the callback function applies to.\r
+  @param  ExceptionCallback     A pointer to a function of type EXCEPTION_CALLBACK that is called\r
+                                when the processor exception specified by ExceptionType occurs.  \r
+  @param  ExceptionType         Specifies which processor exception to hook.                       \r
+                                \r
+  @retval EFI_SUCCESS           The function completed successfully.  \r
+  @retval EFI_ALREADY_STARTED   Non-NULL PeriodicCallback parameter when a callback\r
+                                function was previously registered.                \r
+  @retval EFI_OUT_OF_RESOURCES  System has insufficient memory resources to register new callback                               \r
+                                function.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 RegisterExceptionCallback (\r
   IN EFI_DEBUG_SUPPORT_PROTOCOL       *This,\r
   IN UINTN                            ProcessorIndex,\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 RegisterExceptionCallback (\r
   IN EFI_DEBUG_SUPPORT_PROTOCOL       *This,\r
   IN UINTN                            ProcessorIndex,\r
-  IN EFI_EXCEPTION_CALLBACK           NewCallback,\r
+  IN EFI_EXCEPTION_CALLBACK           ExceptionCallback,\r
   IN EFI_EXCEPTION_TYPE               ExceptionType\r
   );\r
 \r
 /**\r
   IN EFI_EXCEPTION_TYPE               ExceptionType\r
   );\r
 \r
 /**\r
-  DebugSupport protocol member function.  Calls assembly routine to flush cache.\r
-\r
-  @param  This              The DebugSupport instance\r
-  @param  ProcessorIndex    Which processor the callback applies to.\r
-  @param  Start             Physical base of the memory range to be invalidated\r
-  @param  Length            mininum number of bytes in instruction cache to invalidate\r
-\r
-  @retval EFI_SUCCESS       Always returned.\r
+  Invalidates processor instruction cache for a memory range. Subsequent execution in this range\r
+  causes a fresh memory fetch to retrieve code to be executed.                                  \r
+    \r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+  @param  ProcessorIndex        Specifies which processor's instruction cache is to be invalidated.\r
+  @param  Start                 Specifies the physical base of the memory range to be invalidated.                                \r
+  @param  Length                Specifies the minimum number of bytes in the processor's instruction\r
+                                cache to invalidate.                                                 \r
+                                \r
+  @retval EFI_SUCCESS           Always returned.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -227,24 +218,23 @@ InvalidateInstructionCache (
                           for.\r
   @param  Stub            On successful exit, *Stub contains the newly allocated entry stub.\r
 \r
                           for.\r
   @param  Stub            On successful exit, *Stub contains the newly allocated entry stub.\r
 \r
-  @retval EFI_SUCCESS     Always.\r
-\r
 **/\r
 **/\r
-EFI_STATUS\r
+VOID\r
 CreateEntryStub (\r
   IN EFI_EXCEPTION_TYPE     ExceptionType,\r
   OUT VOID                  **Stub\r
   );\r
 \r
 /**\r
 CreateEntryStub (\r
   IN EFI_EXCEPTION_TYPE     ExceptionType,\r
   OUT VOID                  **Stub\r
   );\r
 \r
 /**\r
-  Get Procedure Entry Point from IDT Gate Descriptor.\r
+  Get Interrupt Handle from IDT Gate Descriptor.\r
 \r
   @param  IdtGateDecriptor  IDT Gate Descriptor.\r
 \r
 \r
   @param  IdtGateDecriptor  IDT Gate Descriptor.\r
 \r
-  @return Procedure Entry Point located in IDT Gate Descriptor.\r
+  @return Interrupt Handle stored in IDT Gate Descriptor.\r
 \r
 **/\r
 \r
 **/\r
-UINTN GetProcedureEntryPoint (\r
+UINTN\r
+GetInterruptHandleFromIdt (\r
   IN IA32_IDT_GATE_DESCRIPTOR  *IdtGateDecriptor\r
   );\r
 \r
   IN IA32_IDT_GATE_DESCRIPTOR  *IdtGateDecriptor\r
   );\r
 \r
@@ -268,7 +258,7 @@ UINTN GetProcedureEntryPoint (
 **/\r
 EFI_STATUS\r
 ManageIdtEntryTable (\r
 **/\r
 EFI_STATUS\r
 ManageIdtEntryTable (\r
-  VOID (*NewCallback)(),\r
+  VOID               (*NewCallback)(),\r
   EFI_EXCEPTION_TYPE ExceptionType\r
   );\r
 \r
   EFI_EXCEPTION_TYPE ExceptionType\r
   );\r
 \r
@@ -283,10 +273,8 @@ ManageIdtEntryTable (
   @param  ExceptionType      Specifies which vector to hook.\r
   @param  NewCallback        A pointer to the new function to be registered.\r
 \r
   @param  ExceptionType      Specifies which vector to hook.\r
   @param  NewCallback        A pointer to the new function to be registered.\r
 \r
-  @retval EFI_SUCCESS        Always.\r
-\r
 **/\r
 **/\r
-EFI_STATUS\r
+VOID\r
 HookEntry (\r
   IN EFI_EXCEPTION_TYPE            ExceptionType,\r
   IN VOID                         (*NewCallback) ()\r
 HookEntry (\r
   IN EFI_EXCEPTION_TYPE            ExceptionType,\r
   IN VOID                         (*NewCallback) ()\r
@@ -297,10 +285,8 @@ HookEntry (
 \r
   @param  ExceptionType   Specifies which entry to unhook\r
 \r
 \r
   @param  ExceptionType   Specifies which entry to unhook\r
 \r
-  @retval EFI_SUCCESS     Always.\r
-\r
 **/\r
 **/\r
-EFI_STATUS\r
+VOID\r
 UnhookEntry (\r
   IN EFI_EXCEPTION_TYPE           ExceptionType\r
   );\r
 UnhookEntry (\r
   IN EFI_EXCEPTION_TYPE           ExceptionType\r
   );\r
index 932e923eaa11bd41e334c7df98da8916402b14c1..24e2cd070003f5fbe7bb89e9a688d242fecde16d 100644 (file)
@@ -1,5 +1,5 @@
 /** @file\r
 /** @file\r
-  IA32 specific debug support functions\r
+  Generic debug support functions for IA32/x64.\r
 \r
 Copyright (c) 2006 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 \r
 Copyright (c) 2006 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
@@ -12,27 +12,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
 \r
 **/\r
 \r
-//\r
-// private header files\r
-//\r
 #include "DebugSupport.h"\r
 \r
 //\r
 // This the global main table to keep track of the interrupts\r
 //\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
+IDT_ENTRY                 *IdtEntryTable  = NULL;\r
 IA32_IDT_GATE_DESCRIPTOR  NullDesc        = {0};\r
 \r
 /**\r
   Read IDT Gate Descriptor from IDT Table.\r
 \r
   @param  Vector            Specifies vector number.\r
 IA32_IDT_GATE_DESCRIPTOR  NullDesc        = {0};\r
 \r
 /**\r
   Read IDT Gate Descriptor from IDT Table.\r
 \r
   @param  Vector            Specifies vector number.\r
-  @param  IdtGateDecriptor  Pointer to IDT Gate Descriptor read from IDT Table.\r
+  @param  IdtGateDescriptor Pointer to IDT Gate Descriptor read from IDT Table.\r
 \r
 **/\r
 \r
 **/\r
-VOID ReadIdtGateDecriptor (\r
+VOID\r
+ReadIdtGateDescriptor (\r
   IN  EFI_EXCEPTION_TYPE        Vector,\r
   IN  EFI_EXCEPTION_TYPE        Vector,\r
-  OUT IA32_IDT_GATE_DESCRIPTOR  *IdtGateDecriptor\r
+  OUT IA32_IDT_GATE_DESCRIPTOR  *IdtGateDescriptor\r
   )\r
 {\r
  IA32_DESCRIPTOR            IdtrValue;\r
   )\r
 {\r
  IA32_DESCRIPTOR            IdtrValue;\r
@@ -41,18 +39,20 @@ VOID ReadIdtGateDecriptor (
  AsmReadIdtr (&IdtrValue);\r
  IdtTable = (IA32_IDT_GATE_DESCRIPTOR *) IdtrValue.Base;\r
 \r
  AsmReadIdtr (&IdtrValue);\r
  IdtTable = (IA32_IDT_GATE_DESCRIPTOR *) IdtrValue.Base;\r
 \r
- CopyMem ((VOID *) IdtGateDecriptor, (VOID *) &(IdtTable)[Vector], sizeof (IA32_IDT_GATE_DESCRIPTOR));\r
+ CopyMem ((VOID *) IdtGateDescriptor, (VOID *) &(IdtTable)[Vector], sizeof (IA32_IDT_GATE_DESCRIPTOR));\r
 }\r
 }\r
+\r
 /**\r
   Write IDT Gate Descriptor into IDT Table.\r
 \r
   @param  Vector            Specifies vector number.\r
 /**\r
   Write IDT Gate Descriptor into IDT Table.\r
 \r
   @param  Vector            Specifies vector number.\r
-  @param  IdtGateDecriptor  Pointer to IDT Gate Descriptor written into IDT Table.\r
+  @param  IdtGateDescriptor Pointer to IDT Gate Descriptor written into IDT Table.\r
 \r
 **/\r
 \r
 **/\r
-VOID WriteIdtGateDecriptor (\r
+VOID\r
+WriteIdtGateDescriptor (\r
   EFI_EXCEPTION_TYPE        Vector,\r
   EFI_EXCEPTION_TYPE        Vector,\r
-  IA32_IDT_GATE_DESCRIPTOR  *IdtGateDecriptor\r
+  IA32_IDT_GATE_DESCRIPTOR  *IdtGateDescriptor\r
   )\r
 {\r
  IA32_DESCRIPTOR            IdtrValue;\r
   )\r
 {\r
  IA32_DESCRIPTOR            IdtrValue;\r
@@ -61,10 +61,9 @@ VOID WriteIdtGateDecriptor (
  AsmReadIdtr (&IdtrValue);\r
  IdtTable = (IA32_IDT_GATE_DESCRIPTOR *) IdtrValue.Base;\r
 \r
  AsmReadIdtr (&IdtrValue);\r
  IdtTable = (IA32_IDT_GATE_DESCRIPTOR *) IdtrValue.Base;\r
 \r
- CopyMem ((VOID *) &(IdtTable)[Vector], (VOID *) IdtGateDecriptor, sizeof (IA32_IDT_GATE_DESCRIPTOR));\r
+ CopyMem ((VOID *) &(IdtTable)[Vector], (VOID *) IdtGateDescriptor, sizeof (IA32_IDT_GATE_DESCRIPTOR));\r
 }\r
 \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
 /**\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
@@ -76,32 +75,35 @@ VOID WriteIdtGateDecriptor (
   @param  ExceptionType      Specifies which vector to hook.\r
   @param  NewCallback        A pointer to the new function to be registered.\r
 \r
   @param  ExceptionType      Specifies which vector to hook.\r
   @param  NewCallback        A pointer to the new function to be registered.\r
 \r
-  @retval EFI_SUCCESS        Always.\r
-\r
 **/\r
 **/\r
-EFI_STATUS\r
+VOID\r
 HookEntry (\r
   IN EFI_EXCEPTION_TYPE            ExceptionType,\r
   IN VOID                         (*NewCallback) ()\r
   )\r
 {\r
   BOOLEAN     OldIntFlagState;\r
 HookEntry (\r
   IN EFI_EXCEPTION_TYPE            ExceptionType,\r
   IN VOID                         (*NewCallback) ()\r
   )\r
 {\r
   BOOLEAN     OldIntFlagState;\r
-  EFI_STATUS  Status;\r
 \r
 \r
-  Status = CreateEntryStub (ExceptionType, (VOID **) &IdtEntryTable[ExceptionType].StubEntry);\r
-  if (Status == EFI_SUCCESS) {\r
-    OldIntFlagState = WriteInterruptFlag (0);\r
-    ReadIdtGateDecriptor (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
+  CreateEntryStub (ExceptionType, (VOID **) &IdtEntryTable[ExceptionType].StubEntry);\r
+                          \r
+  //\r
+  // Disables CPU interrupts and returns the previous interrupt state\r
+  //\r
+  OldIntFlagState = SaveAndDisableInterrupts ();\r
 \r
 \r
-    IdtEntryTable[ExceptionType].OrigVector = (DEBUG_PROC) GetProcedureEntryPoint (&(IdtEntryTable[ExceptionType].OrigDesc));\r
+  ReadIdtGateDescriptor (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
+  IdtEntryTable[ExceptionType].OrigVector = (DEBUG_PROC) GetInterruptHandleFromIdt (&(IdtEntryTable[ExceptionType].OrigDesc));\r
 \r
 \r
-    Vect2Desc (&IdtEntryTable[ExceptionType].NewDesc, IdtEntryTable[ExceptionType].StubEntry);\r
-    IdtEntryTable[ExceptionType].RegisteredCallback = NewCallback;\r
-    WriteIdtGateDecriptor (ExceptionType, &(IdtEntryTable[ExceptionType].NewDesc));\r
-    WriteInterruptFlag (OldIntFlagState);\r
-  }\r
+  Vect2Desc (&IdtEntryTable[ExceptionType].NewDesc, IdtEntryTable[ExceptionType].StubEntry);\r
+  IdtEntryTable[ExceptionType].RegisteredCallback = NewCallback;\r
+  WriteIdtGateDescriptor (ExceptionType, &(IdtEntryTable[ExceptionType].NewDesc));\r
+\r
+  //\r
+  // restore interrupt state\r
+  //\r
+  SetInterruptState (OldIntFlagState);\r
 \r
 \r
-  return Status;\r
+  return ;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -109,31 +111,43 @@ HookEntry (
 \r
   @param  ExceptionType   Specifies which entry to unhook\r
 \r
 \r
   @param  ExceptionType   Specifies which entry to unhook\r
 \r
-  @retval EFI_SUCCESS     Always.\r
-\r
 **/\r
 **/\r
-EFI_STATUS\r
+VOID\r
 UnhookEntry (\r
   IN EFI_EXCEPTION_TYPE           ExceptionType\r
   )\r
 {\r
   BOOLEAN     OldIntFlagState;\r
 \r
 UnhookEntry (\r
   IN EFI_EXCEPTION_TYPE           ExceptionType\r
   )\r
 {\r
   BOOLEAN     OldIntFlagState;\r
 \r
-  OldIntFlagState = WriteInterruptFlag (0);\r
-  WriteIdtGateDecriptor (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
-  WriteInterruptFlag (OldIntFlagState);\r
+  //\r
+  // Disables CPU interrupts and returns the previous interrupt state\r
+  //\r
+  OldIntFlagState = SaveAndDisableInterrupts ();\r
 \r
 \r
-  return EFI_SUCCESS;\r
+  //\r
+  // restore the default IDT Date Descriptor\r
+  //\r
+  WriteIdtGateDescriptor (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
+\r
+  //\r
+  // restore interrupt state\r
+  //\r
+  SetInterruptState (OldIntFlagState);\r
+\r
+  return ;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  This is a DebugSupport protocol member function, hard\r
-  coded to support only 1 processor for now.\r
+  Returns the maximum value that may be used for the ProcessorIndex parameter in\r
+  RegisterPeriodicCallback() and RegisterExceptionCallback().                   \r
+    \r
+  Hard coded to support only 1 processor for now.\r
 \r
 \r
-  @param  This                The DebugSupport instance\r
-  @param  MaxProcessorIndex   The maximuim supported processor index\r
-\r
-  @retval EFI_SUCCESS         Always returned with **MaxProcessorIndex set to 0.\r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+  @param  MaxProcessorIndex     Pointer to a caller-allocated UINTN in which the maximum supported\r
+                                processor index is returned. Always 0 returned.                                     \r
+                                \r
+  @retval EFI_SUCCESS           Always returned with **MaxProcessorIndex set to 0.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -144,19 +158,22 @@ GetMaximumProcessorIndex (
   )\r
 {\r
   *MaxProcessorIndex = 0;\r
   )\r
 {\r
   *MaxProcessorIndex = 0;\r
-  return (EFI_SUCCESS);\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  DebugSupport protocol member function.\r
-\r
-  @param  This               The DebugSupport instance\r
-  @param  ProcessorIndex     Which processor the callback applies to.\r
-  @param  PeriodicCallback   Callback function\r
-\r
-  @retval EFI_SUCCESS        Indicates the callback was registered.\r
-  @retval others             Callback was not registered.\r
-\r
+  Registers a function to be called back periodically in interrupt context.\r
+    \r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+  @param  ProcessorIndex        Specifies which processor the callback function applies to.\r
+  @param  PeriodicCallback      A pointer to a function of type PERIODIC_CALLBACK that is the main\r
+                                periodic entry point of the debug agent.\r
+                                \r
+  @retval EFI_SUCCESS           The function completed successfully.  \r
+  @retval EFI_ALREADY_STARTED   Non-NULL PeriodicCallback parameter when a callback\r
+                                function was previously registered.                \r
+  @retval EFI_OUT_OF_RESOURCES  System has insufficient memory resources to register new callback                               \r
+                                function. \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -170,40 +187,45 @@ RegisterPeriodicCallback (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  DebugSupport protocol member function.\r
+  Registers a function to be called when a given processor exception occurs.\r
 \r
   This code executes in boot services context.\r
 \r
   This code executes in boot services context.\r
-\r
-  @param  This              The DebugSupport instance\r
-  @param  ProcessorIndex    Which processor the callback applies to.\r
-  @param  NewCallback       Callback function\r
-  @param  ExceptionType     Which exception to hook\r
-\r
-  @retval EFI_SUCCESS        Indicates the callback was registered.\r
-  @retval others             Callback was not registered.\r
-\r
+    \r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+  @param  ProcessorIndex        Specifies which processor the callback function applies to.\r
+  @param  ExceptionCallback     A pointer to a function of type EXCEPTION_CALLBACK that is called\r
+                                when the processor exception specified by ExceptionType occurs.  \r
+  @param  ExceptionType         Specifies which processor exception to hook.                       \r
+                                \r
+  @retval EFI_SUCCESS           The function completed successfully.  \r
+  @retval EFI_ALREADY_STARTED   Non-NULL PeriodicCallback parameter when a callback\r
+                                function was previously registered.                \r
+  @retval EFI_OUT_OF_RESOURCES  System has insufficient memory resources to register new callback                               \r
+                                function.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 RegisterExceptionCallback (\r
   IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
   IN UINTN                      ProcessorIndex,\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 RegisterExceptionCallback (\r
   IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
   IN UINTN                      ProcessorIndex,\r
-  IN EFI_EXCEPTION_CALLBACK     NewCallback,\r
+  IN EFI_EXCEPTION_CALLBACK     ExceptionCallback,\r
   IN EFI_EXCEPTION_TYPE         ExceptionType\r
   )\r
 {\r
   IN EFI_EXCEPTION_TYPE         ExceptionType\r
   )\r
 {\r
-  return ManageIdtEntryTable (NewCallback, ExceptionType);\r
+  return ManageIdtEntryTable (ExceptionCallback, ExceptionType);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  DebugSupport protocol member function.  Calls assembly routine to flush cache.\r
-\r
-  @param  This              The DebugSupport instance\r
-  @param  ProcessorIndex    Which processor the callback applies to.\r
-  @param  Start             Physical base of the memory range to be invalidated\r
-  @param  Length            mininum number of bytes in instruction cache to invalidate\r
-\r
-  @retval EFI_SUCCESS       Always returned.\r
+  Invalidates processor instruction cache for a memory range. Subsequent execution in this range\r
+  causes a fresh memory fetch to retrieve code to be executed.                                  \r
+    \r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r
+  @param  ProcessorIndex        Specifies which processor's instruction cache is to be invalidated.\r
+  @param  Start                 Specifies the physical base of the memory range to be invalidated.                                \r
+  @param  Length                Specifies the minimum number of bytes in the processor's instruction\r
+                                cache to invalidate.                                                 \r
+                                \r
+  @retval EFI_SUCCESS           Always returned.\r
 \r
 **/\r
 EFI_STATUS\r
 \r
 **/\r
 EFI_STATUS\r
@@ -220,57 +242,32 @@ InvalidateInstructionCache (
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  Initializes driver's handler registration databas. \r
-  \r
-  This code executes in boot services context\r
-  Must be public because it's referenced from DebugSupport.c\r
+  Common piece of code that invokes the registered handlers.\r
 \r
 \r
-  @retval  EFI_UNSUPPORTED      If IA32 processor does not support FXSTOR/FXRSTOR instructions,\r
-                                the context save will fail, so these processor's are not supported.\r
-  @retval  EFI_OUT_OF_RESOURCES Fails to allocate memory.\r
-  @retval  EFI_SUCCESS          Initializes successfully.\r
+  This code executes in exception context so no efi calls are allowed.\r
+\r
+  @param  ExceptionType     Exception type\r
+  @param  ContextRecord     System context\r
 \r
 **/\r
 \r
 **/\r
-EFI_STATUS\r
-PlInitializeDebugSupportDriver (\r
-  VOID\r
+VOID\r
+InterruptDistrubutionHub (\r
+  EFI_EXCEPTION_TYPE      ExceptionType,\r
+  EFI_SYSTEM_CONTEXT_IA32 *ContextRecord\r
   )\r
 {\r
   )\r
 {\r
-  EFI_EXCEPTION_TYPE  ExceptionType;\r
-\r
-  if (!FxStorSupport ()) {\r
-    return EFI_UNSUPPORTED;\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
+  if (IdtEntryTable[ExceptionType].RegisteredCallback != NULL) {\r
+    if (ExceptionType != SYSTEM_TIMER_VECTOR) {\r
+      IdtEntryTable[ExceptionType].RegisteredCallback (ExceptionType, ContextRecord);\r
+    } else {\r
+      OrigVector = IdtEntryTable[ExceptionType].OrigVector;\r
+      IdtEntryTable[ExceptionType].RegisteredCallback (ContextRecord);\r
     }\r
   }\r
     }\r
   }\r
-  FreePool (IdtEntryTable);\r
-\r
-  return EFI_OUT_OF_RESOURCES;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
-  This is the callback that is written to the LoadedImage protocol instance\r
+  This is the callback that is written to the Loaded Image protocol instance\r
   on the image handle. It uninstalls all registered handlers and frees all entry\r
   stub memory.\r
 \r
   on the image handle. It uninstalls all registered handlers and frees all entry\r
   stub memory.\r
 \r
@@ -289,33 +286,71 @@ PlUnloadDebugSupportDriver (
 \r
   for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {\r
     ManageIdtEntryTable (NULL, ExceptionType);\r
 \r
   for (ExceptionType = 0; ExceptionType < NUM_IDT_ENTRIES; ExceptionType++) {\r
     ManageIdtEntryTable (NULL, ExceptionType);\r
+    //\r
+    // Free space for each Interrupt Stub precedure.\r
+    //\r
+    if (IdtEntryTable[ExceptionType].StubEntry != NULL) {\r
+      FreePool ((VOID *)(UINTN)IdtEntryTable[ExceptionType].StubEntry);\r
+    }\r
   }\r
 \r
   FreePool (IdtEntryTable);\r
   }\r
 \r
   FreePool (IdtEntryTable);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
   return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
-  Common piece of code that invokes the registered handlers.\r
-\r
-  This code executes in exception context so no efi calls are allowed.\r
+  Initializes driver's handler registration database. \r
+  \r
+  This code executes in boot services context.\r
+  Must be public because it's referenced from DebugSupport.c\r
 \r
 \r
-  @param  ExceptionType     Exception type\r
-  @param  ContextRecord     System context\r
+  @retval  EFI_UNSUPPORTED      If IA32/x64 processor does not support FXSTOR/FXRSTOR instructions,\r
+                                the context save will fail, so these processors are not supported.\r
+  @retval  EFI_OUT_OF_RESOURCES Fails to allocate memory.\r
+  @retval  EFI_SUCCESS          Initializes successfully.\r
 \r
 **/\r
 \r
 **/\r
-VOID\r
-InterruptDistrubutionHub (\r
-  EFI_EXCEPTION_TYPE      ExceptionType,\r
-  EFI_SYSTEM_CONTEXT_IA32 *ContextRecord\r
+EFI_STATUS\r
+PlInitializeDebugSupportDriver (\r
+  VOID\r
   )\r
 {\r
   )\r
 {\r
-  if (IdtEntryTable[ExceptionType].RegisteredCallback != NULL) {\r
-    if (ExceptionType != SYSTEM_TIMER_VECTOR) {\r
-      IdtEntryTable[ExceptionType].RegisteredCallback (ExceptionType, ContextRecord);\r
-    } else {\r
-      OrigVector = IdtEntryTable[ExceptionType].OrigVector;\r
-      IdtEntryTable[ExceptionType].RegisteredCallback (ContextRecord);\r
+  EFI_EXCEPTION_TYPE  ExceptionType;\r
+\r
+  //\r
+  // Check whether FxStor instructions are supported.\r
+  //\r
+  if (!FxStorSupport ()) {\r
+    return EFI_UNSUPPORTED;\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
+    //\r
+    // Copy Interrupt stub code.\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
     }\r
   }\r
+  FreePool (IdtEntryTable);\r
+\r
+  return EFI_OUT_OF_RESOURCES;\r
 }\r
 }\r
index 47e4e0e3508676e8ee5527c3e427e80291e68325..ff21ed7f2a35c4944876bdd5b50f04347f0e70cb 100644 (file)
@@ -15,23 +15,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "DebugSupport.h"\r
 \r
 /**\r
 #include "DebugSupport.h"\r
 \r
 /**\r
-  Get Procedure Entry Point from IDT Gate Descriptor.\r
+  Get Interrupt Handle from IDT Gate Descriptor.\r
 \r
 \r
-  @param  IdtGateDecriptor  IDT Gate Descriptor.\r
+  @param  IdtGateDescriptor  IDT Gate Descriptor.\r
 \r
 \r
-  @return Procedure Entry Point located in IDT Gate Descriptor.\r
+  @return Interrupt Handle stored in IDT Gate Descriptor.\r
 \r
 **/\r
 \r
 **/\r
-UINTN GetProcedureEntryPoint (\r
-  IN IA32_IDT_GATE_DESCRIPTOR  *IdtGateDecriptor\r
+UINTN\r
+GetInterruptHandleFromIdt (\r
+  IN IA32_IDT_GATE_DESCRIPTOR  *IdtGateDescriptor\r
   )\r
 {\r
   )\r
 {\r
-  UINTN      ProcedureEntryPoint;\r
+  UINTN      InterruptHandle;\r
  \r
  \r
-  ((UINT16 *) &ProcedureEntryPoint)[0] = (UINT16) IdtGateDecriptor->Bits.OffsetLow;\r
-  ((UINT16 *) &ProcedureEntryPoint)[1] = (UINT16) IdtGateDecriptor->Bits.OffsetHigh;\r
+  ((UINT16 *) &InterruptHandle)[0] = (UINT16) IdtGateDescriptor->Bits.OffsetLow;\r
+  ((UINT16 *) &InterruptHandle)[1] = (UINT16) IdtGateDescriptor->Bits.OffsetHigh;\r
 \r
 \r
-  return ProcedureEntryPoint;\r
+  return InterruptHandle;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -44,10 +45,8 @@ UINTN GetProcedureEntryPoint (
                           for.\r
   @param  Stub            On successful exit, *Stub contains the newly allocated entry stub.\r
 \r
                           for.\r
   @param  Stub            On successful exit, *Stub contains the newly allocated entry stub.\r
 \r
-  @retval EFI_SUCCESS     Always.\r
-\r
 **/\r
 **/\r
-EFI_STATUS\r
+VOID\r
 CreateEntryStub (\r
   IN EFI_EXCEPTION_TYPE     ExceptionType,\r
   OUT VOID                  **Stub\r
 CreateEntryStub (\r
   IN EFI_EXCEPTION_TYPE     ExceptionType,\r
   OUT VOID                  **Stub\r
@@ -80,7 +79,7 @@ CreateEntryStub (
   //\r
   *(UINT32 *) &StubCopy[0x0e] = (UINT32) CommonIdtEntry - (UINT32) &StubCopy[StubSize];\r
 \r
   //\r
   *(UINT32 *) &StubCopy[0x0e] = (UINT32) CommonIdtEntry - (UINT32) &StubCopy[StubSize];\r
 \r
-  return EFI_SUCCESS;\r
+  return ;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -94,16 +93,15 @@ CreateEntryStub (
                         be uninstalled.\r
   @param  ExceptionType Indicates which entry to manage.\r
 \r
                         be uninstalled.\r
   @param  ExceptionType Indicates which entry to manage.\r
 \r
-  @retval EFI_SUCCESS            Process is ok.\r
+  @retval EFI_SUCCESS            Installing or Uninstalling operation 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 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
 \r
 **/\r
 EFI_STATUS\r
 ManageIdtEntryTable (\r
-  VOID (*NewCallback)(),\r
+  VOID               (*NewCallback)(),\r
   EFI_EXCEPTION_TYPE ExceptionType\r
   )\r
 {\r
   EFI_EXCEPTION_TYPE ExceptionType\r
   )\r
 {\r
@@ -122,7 +120,7 @@ ManageIdtEntryTable (
         //\r
         Status = EFI_ALREADY_STARTED;\r
       } else {\r
         //\r
         Status = EFI_ALREADY_STARTED;\r
       } else {\r
-        Status = UnhookEntry (ExceptionType);\r
+        UnhookEntry (ExceptionType);\r
       }\r
     } else {\r
       //\r
       }\r
     } else {\r
       //\r
@@ -134,7 +132,7 @@ ManageIdtEntryTable (
         //\r
         Status = EFI_INVALID_PARAMETER;\r
       } else {\r
         //\r
         Status = EFI_INVALID_PARAMETER;\r
       } else {\r
-        Status = HookEntry (ExceptionType, NewCallback);\r
+        HookEntry (ExceptionType, NewCallback);\r
       }\r
     }\r
   }\r
       }\r
     }\r
   }\r
index 7b91ae4b6349788da511e6090fa317dba0de1b84..d358b425deeb02a7ea945bcf6b4c4fb15c384508 100644 (file)
@@ -19,11 +19,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 BOOLEAN  mInHandler = FALSE;\r
 \r
 \r
 BOOLEAN  mInHandler = FALSE;\r
 \r
-typedef struct {\r
-  UINT64  low;\r
-  UINT64  high;\r
-} BUNDLE;\r
-\r
 //\r
 // number of bundles to swap in ivt\r
 //\r
 //\r
 // number of bundles to swap in ivt\r
 //\r
@@ -50,88 +45,6 @@ UINT8     IpfContextBuf[sizeof (EFI_SYSTEM_CONTEXT_IPF) + 512];
 UINT8     PatchSaveBuffer[0x400];\r
 UINTN     ExternalInterruptCount;\r
 \r
 UINT8     PatchSaveBuffer[0x400];\r
 UINTN     ExternalInterruptCount;\r
 \r
-/**\r
-  This is the worker function that uninstalls and removes all handlers.\r
-\r
-  @param  ExceptionType     Exception Type\r
-  @param  NewBundles        New Boundles\r
-  @param  NewCallback       New Callback\r
-\r
-  @retval EFI_ALEADY_STARTED Ivt already hooked.\r
-  @retval others             Indicates the request was not satisfied.\r
-  @retval EFI_SUCCESS        Successfully uninstalled.\r
-\r
-**/\r
-EFI_STATUS\r
-ManageIvtEntryTable (\r
-  IN  EFI_EXCEPTION_TYPE    ExceptionType,\r
-  IN  BUNDLE                NewBundles[4],\r
-  IN  VOID                  (*NewCallback) ()\r
-  );\r
-\r
-/**\r
-  Saves original IVT contents and inserts a few new bundles which are fixed up\r
-  to store the ExceptionType and then call the common handler.\r
-\r
-  @param  ExceptionType      Exception Type\r
-  @param  NewBundles         New Boundles\r
-  @param  NewCallback        New Callback\r
-\r
-**/\r
-VOID\r
-HookEntry (\r
-  IN  EFI_EXCEPTION_TYPE    ExceptionType,\r
-  IN  BUNDLE                NewBundles[4],\r
-  IN  VOID                  (*NewCallback) ()\r
-  );\r
-\r
-/**\r
-  Restores original IVT contents when unregistering a callback function.\r
-\r
-  @param  ExceptionType     Exception Type\r
-\r
-**/\r
-VOID\r
-UnhookEntry (\r
-  IN  EFI_EXCEPTION_TYPE    ExceptionType\r
-  );\r
-\r
-/**\r
-  Sets up cache flush and calls assembly function to chain external interrupt.\r
-\r
-  Records new callback in IvtEntryTable.\r
-\r
-  @param  NewCallback     New Callback.\r
-\r
-**/\r
-VOID\r
-ChainExternalInterrupt (\r
-  IN  VOID                  (*NewCallback) ()\r
-  );\r
-\r
-/**\r
-  Sets up cache flush and calls assembly function to restore external interrupt.\r
-  Removes registered callback from IvtEntryTable.\r
-\r
-**/\r
-VOID\r
-UnchainExternalInterrupt (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Given an integer number, return the physical address of the entry point in the IFT.\r
-\r
-  @param  HandlerIndex       Index of the Handler \r
-  @param  EntryPoint         IFT Entrypoint\r
-\r
-**/\r
-VOID\r
-GetHandlerEntryPoint (\r
-  UINTN                     HandlerIndex,\r
-  VOID                      **EntryPoint\r
-  );\r
-\r
 \r
 /**\r
   IPF specific DebugSupport driver initialization. \r
 \r
 /**\r
   IPF specific DebugSupport driver initialization. \r
index f8f5532de7c663272172043133e4691b5b0377fa..e1e34a449caac6e47615b955d31fa1a64d1f72c6 100644 (file)
@@ -15,7 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _PLDEBUG_SUPPORT_H_\r
 #define _PLDEBUG_SUPPORT_H_\r
 \r
 #ifndef _PLDEBUG_SUPPORT_H_\r
 #define _PLDEBUG_SUPPORT_H_\r
 \r
-\r
 #include <Uefi.h>\r
 \r
 #include <Protocol/DebugSupport.h>\r
 #include <Uefi.h>\r
 \r
 #include <Protocol/DebugSupport.h>\r
@@ -29,11 +28,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #define DISABLE_INTERRUPTS  0UL\r
 \r
 \r
 #define DISABLE_INTERRUPTS  0UL\r
 \r
-//\r
-// The remaining definitions comprise the protocol members.\r
-//\r
 #define EFI_ISA IsaIpf\r
 \r
 #define EFI_ISA IsaIpf\r
 \r
+typedef struct {\r
+  UINT64  low;\r
+  UINT64  high;\r
+} BUNDLE;\r
+\r
 /**\r
   IPF specific DebugSupport driver initialization. \r
 \r
 /**\r
   IPF specific DebugSupport driver initialization. \r
 \r
@@ -217,4 +218,86 @@ CommonHandler (
   IN EFI_SYSTEM_CONTEXT Context\r
   );\r
 \r
   IN EFI_SYSTEM_CONTEXT Context\r
   );\r
 \r
+/**\r
+  This is the worker function that uninstalls and removes all handlers.\r
+\r
+  @param  ExceptionType     Exception Type\r
+  @param  NewBundles        New Boundles\r
+  @param  NewCallback       New Callback\r
+\r
+  @retval EFI_ALEADY_STARTED Ivt already hooked.\r
+  @retval others             Indicates the request was not satisfied.\r
+  @retval EFI_SUCCESS        Successfully uninstalled.\r
+\r
+**/\r
+EFI_STATUS\r
+ManageIvtEntryTable (\r
+  IN  EFI_EXCEPTION_TYPE    ExceptionType,\r
+  IN  BUNDLE                NewBundles[4],\r
+  IN  VOID                  (*NewCallback) ()\r
+  );\r
+\r
+/**\r
+  Saves original IVT contents and inserts a few new bundles which are fixed up\r
+  to store the ExceptionType and then call the common handler.\r
+\r
+  @param  ExceptionType      Exception Type\r
+  @param  NewBundles         New Boundles\r
+  @param  NewCallback        New Callback\r
+\r
+**/\r
+VOID\r
+HookEntry (\r
+  IN  EFI_EXCEPTION_TYPE    ExceptionType,\r
+  IN  BUNDLE                NewBundles[4],\r
+  IN  VOID                  (*NewCallback) ()\r
+  );\r
+\r
+/**\r
+  Restores original IVT contents when unregistering a callback function.\r
+\r
+  @param  ExceptionType     Exception Type\r
+\r
+**/\r
+VOID\r
+UnhookEntry (\r
+  IN  EFI_EXCEPTION_TYPE    ExceptionType\r
+  );\r
+\r
+/**\r
+  Sets up cache flush and calls assembly function to chain external interrupt.\r
+\r
+  Records new callback in IvtEntryTable.\r
+\r
+  @param  NewCallback     New Callback.\r
+\r
+**/\r
+VOID\r
+ChainExternalInterrupt (\r
+  IN  VOID                  (*NewCallback) ()\r
+  );\r
+\r
+/**\r
+  Sets up cache flush and calls assembly function to restore external interrupt.\r
+  Removes registered callback from IvtEntryTable.\r
+\r
+**/\r
+VOID\r
+UnchainExternalInterrupt (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Given an integer number, return the physical address of the entry point in the IFT.\r
+\r
+  @param  HandlerIndex       Index of the Handler \r
+  @param  EntryPoint         IFT Entrypoint\r
+\r
+**/\r
+VOID\r
+GetHandlerEntryPoint (\r
+  UINTN                     HandlerIndex,\r
+  VOID                      **EntryPoint\r
+  );\r
+\r
 #endif\r
 #endif\r
index 087e5490bbee592443871204d146f7f162a864c5..693d26e6e4bbf082289497f350034fc557dda596 100644 (file)
@@ -30,14 +30,6 @@ _StubSize:       .long   _InterruptEntryStubEnd - _InterruptEntryStub
 _FxStorSupport:\r
         ret\r
 \r
 _FxStorSupport:\r
         ret\r
 \r
-.globl _GetIdtr\r
-_GetIdtr:\r
-        ret\r
-\r
-.globl _WriteInterruptFlag\r
-_WriteInterruptFlag:\r
-        ret\r
-\r
 .globl _Vect2Desc\r
 _Vect2Desc:\r
         ret\r
 .globl _Vect2Desc\r
 _Vect2Desc:\r
         ret\r
index f486bd32b55457d7d37f23ae49e61bc63c875e88..d9ba0be1910654e24f4b019ae2b63cebc1a0624e 100644 (file)
@@ -131,36 +131,6 @@ FxStorSupport   PROC    PUBLIC
                 ret\r
 FxStorSupport   ENDP\r
 \r
                 ret\r
 FxStorSupport   ENDP\r
 \r
-\r
-\r
-\r
-;------------------------------------------------------------------------------\r
-; BOOLEAN\r
-; WriteInterruptFlag (\r
-;   BOOLEAN NewState // rcx\r
-;   )\r
-;\r
-; Abstract: Programs interrupt flag to the requested state and returns previous\r
-;           state.\r
-;\r
-WriteInterruptFlag  PROC PUBLIC\r
-\r
-                pushfq\r
-                pop     rax\r
-                and     rax, 200h\r
-                shr     rax, 9\r
-                cmp     rcx, 0\r
-                jnz     EnableIF\r
-                cli\r
-                ret\r
-EnableIF:\r
-                sti\r
-                ret\r
-\r
-WriteInterruptFlag  ENDP\r
-\r
-\r
-\r
 ;------------------------------------------------------------------------------\r
 ; void\r
 ; Vect2Desc (\r
 ;------------------------------------------------------------------------------\r
 ; void\r
 ; Vect2Desc (\r
index 943d2c6911b023865fb813216713274c7d0122ab..e898d822719adb133fbf2802b08450b102595928 100644 (file)
@@ -12,30 +12,28 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
 \r
 **/\r
 \r
-//\r
-// private header files\r
-//\r
 #include "DebugSupport.h"\r
 \r
 /**\r
 #include "DebugSupport.h"\r
 \r
 /**\r
-  Get Procedure Entry Point from IDT Gate Descriptor.\r
+  Get Interrupt Handle from IDT Gate Descriptor.\r
 \r
   @param  IdtGateDecriptor  IDT Gate Descriptor.\r
 \r
 \r
   @param  IdtGateDecriptor  IDT Gate Descriptor.\r
 \r
-  @return Procedure Entry Point located in IDT Gate Descriptor.\r
+  @return Interrupt Handle stored in IDT Gate Descriptor.\r
 \r
 **/\r
 \r
 **/\r
-UINTN GetProcedureEntryPoint (\r
+UINTN\r
+GetInterruptHandleFromIdt (\r
   IN IA32_IDT_GATE_DESCRIPTOR  *IdtGateDecriptor\r
   )\r
 {\r
   IN IA32_IDT_GATE_DESCRIPTOR  *IdtGateDecriptor\r
   )\r
 {\r
-  UINTN      ProcedureEntryPoint;\r
+  UINTN      InterruptHandle;\r
  \r
  \r
-  ((UINT16 *) &ProcedureEntryPoint)[0] = (UINT16) IdtGateDecriptor->Bits.OffsetLow;\r
-  ((UINT16 *) &ProcedureEntryPoint)[1] = (UINT16) IdtGateDecriptor->Bits.OffsetHigh;\r
-  ((UINT32 *) &ProcedureEntryPoint)[1] = (UINT32) IdtGateDecriptor->Bits.OffsetUpper;\r
+  ((UINT16 *) &InterruptHandle)[0] = (UINT16) IdtGateDecriptor->Bits.OffsetLow;\r
+  ((UINT16 *) &InterruptHandle)[1] = (UINT16) IdtGateDecriptor->Bits.OffsetHigh;\r
+  ((UINT32 *) &InterruptHandle)[1] = (UINT32) IdtGateDecriptor->Bits.OffsetUpper;\r
 \r
 \r
-  return ProcedureEntryPoint;\r
+  return InterruptHandle;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -48,10 +46,8 @@ UINTN GetProcedureEntryPoint (
                           for.\r
   @param  Stub            On successful exit, *Stub contains the newly allocated entry stub.\r
 \r
                           for.\r
   @param  Stub            On successful exit, *Stub contains the newly allocated entry stub.\r
 \r
-  @retval EFI_SUCCESS     Always.\r
-\r
 **/\r
 **/\r
-EFI_STATUS\r
+VOID\r
 CreateEntryStub (\r
   IN EFI_EXCEPTION_TYPE     ExceptionType,\r
   OUT VOID                  **Stub\r
 CreateEntryStub (\r
   IN EFI_EXCEPTION_TYPE     ExceptionType,\r
   OUT VOID                  **Stub\r
@@ -82,7 +78,7 @@ CreateEntryStub (
   //\r
   *(UINT32 *) &StubCopy[0x3] = (UINT32)((UINTN) CommonIdtEntry - (UINTN) &StubCopy[StubSize]);\r
 \r
   //\r
   *(UINT32 *) &StubCopy[0x3] = (UINT32)((UINTN) CommonIdtEntry - (UINTN) &StubCopy[StubSize]);\r
 \r
-  return EFI_SUCCESS;\r
+  return;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -123,7 +119,7 @@ ManageIdtEntryTable (
       //\r
       Status = EFI_ALREADY_STARTED;\r
     } else {\r
       //\r
       Status = EFI_ALREADY_STARTED;\r
     } else {\r
-      Status = UnhookEntry (ExceptionType);\r
+      UnhookEntry (ExceptionType);\r
     }\r
   } else {\r
     //\r
     }\r
   } else {\r
     //\r
@@ -135,7 +131,7 @@ ManageIdtEntryTable (
       //\r
       Status = EFI_INVALID_PARAMETER;\r
     } else {\r
       //\r
       Status = EFI_INVALID_PARAMETER;\r
     } else {\r
-      Status = HookEntry (ExceptionType, NewCallback);\r
+      HookEntry (ExceptionType, NewCallback);\r
     }\r
   }\r
  \r
     }\r
   }\r
  \r