]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DebugSupportDxe/X64/PlDebugSupport.c
ECC clean up.
[mirror_edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / X64 / PlDebugSupport.c
index f6af90f21be4b1ba656581aa81d6668e1210e955..24e5acc74a756fe64eae428d8a694e5d6f790450 100644 (file)
@@ -1,4 +1,4 @@
-/**@file\r
+/** @file\r
   X64 specific debug support functions\r
 \r
 Copyright (c) 2006 - 2007, Intel Corporation\r
@@ -23,25 +23,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 IDT_ENTRY   *IdtEntryTable  = NULL;\r
 DESCRIPTOR  NullDesc        = {0, 0};\r
 \r
+/**\r
+  Allocate pool for a new IDT entry stub.\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
+\r
+**/\r
 EFI_STATUS\r
 CreateEntryStub (\r
   IN EFI_EXCEPTION_TYPE     ExceptionType,\r
   OUT VOID                  **Stub\r
   )\r
-/*++\r
-\r
-Routine Description: Allocate pool for a new IDT entry stub.  Copy the generic\r
-    stub into the new buffer and fixup the vector number and jump target address.\r
-\r
-Arguments:\r
-    ExceptionType - This is the exception type that the new stub will be created\r
-                    for.\r
-    Stub - On successful exit, *Stub contains the newly allocated entry stub.\r
-Returns:\r
-  Typically EFI_SUCCESS\r
-  other possibilities are passed through from AllocatePool\r
-\r
---*/\r
 {\r
   UINT8       *StubCopy;\r
 \r
@@ -71,14 +70,7 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-HookEntry (\r
-  IN EFI_EXCEPTION_TYPE            ExceptionType,\r
-  IN VOID                         (*NewCallback) ()\r
-  )\r
-/*++\r
-\r
-Routine Description:\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
   with the new registered function.\r
@@ -86,15 +78,17 @@ Routine Description:
   This code executes in boot services context.  The stub entry executes in interrupt\r
   context.\r
 \r
-Arguments:\r
-  ExceptionType - specifies which vector to hook.\r
-  NewCallback - a pointer to the new function to be registered.\r
+  @param  ExceptionType      Specifies which vector to hook.\r
+  @param  NewCallback        A pointer to the new function to be registered.\r
 \r
-Returns:\r
-  EFI_SUCCESS\r
-  Other possibilities are passed through by CreateEntryStub\r
+  @retval EFI_SUCCESS        Always.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+HookEntry (\r
+  IN EFI_EXCEPTION_TYPE            ExceptionType,\r
+  IN VOID                         (*NewCallback) ()\r
+  )\r
 {\r
   BOOLEAN     OldIntFlagState;\r
   EFI_STATUS  Status;\r
@@ -102,7 +96,7 @@ Returns:
   Status = CreateEntryStub (ExceptionType, (VOID **) &IdtEntryTable[ExceptionType].StubEntry);\r
   if (Status == EFI_SUCCESS) {\r
     OldIntFlagState = WriteInterruptFlag (0);\r
-    ReadIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
+    READ_IDT (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
 \r
     ((UINT16 *) &IdtEntryTable[ExceptionType].OrigVector)[0]  = ((UINT16 *) &IdtEntryTable[ExceptionType].OrigDesc.Low)[0];\r
     ((UINT16 *) &IdtEntryTable[ExceptionType].OrigVector)[1]  = ((UINT16 *) &IdtEntryTable[ExceptionType].OrigDesc.Low)[3];\r
@@ -110,73 +104,64 @@ Returns:
 \r
     Vect2Desc (&IdtEntryTable[ExceptionType].NewDesc, IdtEntryTable[ExceptionType].StubEntry);\r
     IdtEntryTable[ExceptionType].RegisteredCallback = NewCallback;\r
-    WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].NewDesc));\r
+    WRITE_IDT (ExceptionType, &(IdtEntryTable[ExceptionType].NewDesc));\r
     WriteInterruptFlag (OldIntFlagState);\r
   }\r
 \r
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-UnhookEntry (\r
-  IN EFI_EXCEPTION_TYPE           ExceptionType\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
   Undoes HookEntry. This code executes in boot services context.\r
 \r
-Arguments:\r
-  ExceptionType - specifies which entry to unhook\r
+  @param  ExceptionType   Specifies which entry to unhook\r
 \r
-Returns:\r
-  EFI_SUCCESS\r
+  @retval EFI_SUCCESS     Always.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+UnhookEntry (\r
+  IN EFI_EXCEPTION_TYPE           ExceptionType\r
+  )\r
 {\r
   BOOLEAN     OldIntFlagState;\r
 \r
   OldIntFlagState = WriteInterruptFlag (0);\r
-  WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
+  WRITE_IDT (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
   WriteInterruptFlag (OldIntFlagState);\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-ManageIdtEntryTable (\r
-  VOID (*NewCallback)(),\r
-  EFI_EXCEPTION_TYPE ExceptionType\r
-  )\r
-/*++\r
-\r
-Routine Description:\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
-Arguments:\r
-  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
-  ExceptionType - Indicates which entry to manage\r
-\r
-Returns:\r
-  EFI_SUCCESS\r
-  EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has\r
-                          no handler registered for it\r
-  EFI_ALREADY_STARTED   - requested install to a vector that already has a handler registered.\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
-  Other possible return values are passed through from UnHookEntry and HookEntry.\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
+**/\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 (CompareDescriptor (&IdtEntryTable[ExceptionType].NewDesc, &NullDesc)) {\r
+  if (COMPARE_DESCRIPTOR (&IdtEntryTable[ExceptionType].NewDesc, &NullDesc)) {\r
     //\r
     // we've already installed to this vector\r
     //\r
@@ -205,29 +190,38 @@ Returns:
   return Status;\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
+\r
+  @retval EFI_SUCCESS         Always returned with **MaxProcessorIndex set to 0.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 GetMaximumProcessorIndex (\r
   IN EFI_DEBUG_SUPPORT_PROTOCOL       *This,\r
   OUT UINTN                           *MaxProcessorIndex\r
   )\r
-/*++\r
-\r
-Routine Description: This is a DebugSupport protocol member function.\r
-\r
-Arguments:\r
-  This              - The DebugSupport instance\r
-  MaxProcessorIndex - The maximuim supported processor index\r
-\r
-Returns:\r
-  Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0\r
-\r
---*/\r
 {\r
   *MaxProcessorIndex = 0;\r
   return (EFI_SUCCESS);\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
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 RegisterPeriodicCallback (\r
@@ -235,29 +229,24 @@ RegisterPeriodicCallback (
   IN UINTN                      ProcessorIndex,\r
   IN EFI_PERIODIC_CALLBACK      PeriodicCallback\r
   )\r
-/*++\r
-\r
-Routine Description: This is a DebugSupport protocol member function.\r
-\r
-Arguments:\r
-  This             - The DebugSupport instance\r
-  ProcessorIndex   - Which processor the callback applies to.\r
-  PeriodicCallback - Callback function\r
+{\r
+  return ManageIdtEntryTable (PeriodicCallback, SYSTEM_TIMER_VECTOR);\r
+}\r
 \r
-Returns:\r
+/**\r
+  DebugSupport protocol member function.\r
 \r
-  EFI_SUCCESS\r
-  EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has\r
-                          no handler registered for it\r
-  EFI_ALREADY_STARTED   - requested install to a vector that already has a handler registered.\r
+  This code executes in boot services context.\r
 \r
-  Other possible return values are passed through from UnHookEntry and HookEntry.\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
---*/\r
-{\r
-  return ManageIdtEntryTable (PeriodicCallback, SYSTEM_TIMER_VECTOR);\r
-}\r
+  @retval EFI_SUCCESS        Indicates the callback was registered.\r
+  @retval others             Callback was not registered.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 RegisterExceptionCallback (\r
@@ -266,33 +255,21 @@ RegisterExceptionCallback (
   IN EFI_EXCEPTION_CALLBACK     NewCallback,\r
   IN EFI_EXCEPTION_TYPE         ExceptionType\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  This is a DebugSupport protocol member function.\r
-\r
-  This code executes in boot services context.\r
-\r
-Arguments:\r
-  This             - The DebugSupport instance\r
-  ProcessorIndex   - Which processor the callback applies to.\r
-  NewCallback      - Callback function\r
-  ExceptionType    - Which exception to hook\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS\r
-  EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has\r
-                          no handler registered for it\r
-  EFI_ALREADY_STARTED   - requested install to a vector that already has a handler registered.\r
-\r
-  Other possible return values are passed through from UnHookEntry and HookEntry.\r
-\r
---*/\r
 {\r
   return ManageIdtEntryTable (NewCallback, 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
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 InvalidateInstructionCache (\r
@@ -301,49 +278,27 @@ InvalidateInstructionCache (
   IN VOID                             *Start,\r
   IN UINT64                           Length\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  This is a DebugSupport protocol member function.\r
-  Calls assembly routine to flush cache.\r
-\r
-Arguments:\r
-  This             - The DebugSupport instance\r
-  ProcessorIndex   - Which processor the callback applies to.\r
-  Start            - Physical base of the memory range to be invalidated\r
-  Length           - mininum number of bytes in instruction cache to invalidate\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS - always return success\r
-\r
---*/\r
 {\r
   AsmWbinvd ();\r
   return EFI_SUCCESS;\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
+\r
+  @retval  EFI_UNSUPPORTED      If x64 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
+\r
+**/\r
 EFI_STATUS\r
-plInitializeDebugSupportDriver (\r
+PlInitializeDebugSupportDriver (\r
   VOID\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Initializes driver's handler registration database.\r
-\r
-  This code executes in boot services context.\r
-\r
-Arguments:\r
-  None\r
-\r
-Returns:\r
-  EFI_SUCCESS\r
-  EFI_UNSUPPORTED - if X64 processor does not support FXSTOR/FXRSTOR instructions,\r
-                    the context save will fail, so these processor's are not supported.\r
-  EFI_OUT_OF_RESOURCES - not resource to finish initialization\r
-\r
---*/\r
 {\r
   EFI_EXCEPTION_TYPE  ExceptionType;\r
 \r
@@ -378,28 +333,21 @@ ErrorCleanup:
   return EFI_OUT_OF_RESOURCES;\r
 }\r
 \r
-EFI_STATUS\r
-EFIAPI\r
-plUnloadDebugSupportDriver (\r
-  IN EFI_HANDLE ImageHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
   This is the callback that is written to the LoadedImage protocol instance\r
   on the image handle. It uninstalls all registered handlers and frees all entry\r
   stub memory.\r
 \r
-  This code executes in boot services context.\r
-\r
-Arguments:\r
-  ImageHandle - The image handle of the unload handler\r
-\r
-Returns:\r
+  @param  ImageHandle    The firmware allocated handle for the EFI image.\r
 \r
-  EFI_SUCCESS - always return success\r
+  @retval EFI_SUCCESS    Always.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PlUnloadDebugSupportDriver (\r
+  IN EFI_HANDLE ImageHandle\r
+  )\r
 {\r
   EFI_EXCEPTION_TYPE  ExceptionType;\r
 \r
@@ -411,26 +359,20 @@ Returns:
   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
+\r
+  @param  ExceptionType     Exception type\r
+  @param  ContextRecord     System context\r
+\r
+**/\r
 VOID\r
 InterruptDistrubutionHub (\r
   EFI_EXCEPTION_TYPE      ExceptionType,\r
   EFI_SYSTEM_CONTEXT_IA32 *ContextRecord\r
   )\r
-/*++\r
-\r
-Routine Description: Common piece of code that invokes the registered handlers.\r
-\r
-  This code executes in exception context so no efi calls are allowed.\r
-\r
-Arguments:\r
-  ExceptionType - exception type\r
-  ContextRecord - system context\r
-\r
-Returns:\r
-\r
-  None\r
-\r
---*/\r
 {\r
   if (IdtEntryTable[ExceptionType].RegisteredCallback != NULL) {\r
     if (ExceptionType != SYSTEM_TIMER_VECTOR) {\r