]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DebugSupportDxe/Ia32/DebugSupport.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / Ia32 / DebugSupport.h
index 72765507d539103923aa2bb17fd9624ebcb1473a..cf12a2a6e8c2a8097dcc2d2228058930e28ca855 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
   Generic debug support macros, typedefs and prototypes for IA32/x64.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 #ifndef _DEBUG_SUPPORT_H_\r
 #define _DEBUG_SUPPORT_H_\r
 \r
-\r
 #include <Uefi.h>\r
 \r
 #include <Protocol/DebugSupport.h>\r
@@ -27,13 +20,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/BaseLib.h>\r
-#include <Library/PcdLib.h>\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
+#define NUM_IDT_ENTRIES      0x78\r
+#define SYSTEM_TIMER_VECTOR  0x68\r
 \r
 typedef\r
 VOID\r
@@ -41,19 +30,25 @@ VOID
   VOID\r
   );\r
 \r
+typedef\r
+VOID\r
+(EFIAPI *CALLBACK_FUNC)(\r
+  );\r
+\r
 typedef struct {\r
-  IA32_IDT_GATE_DESCRIPTOR  OrigDesc;\r
-  DEBUG_PROC                OrigVector;\r
-  IA32_IDT_GATE_DESCRIPTOR  NewDesc;\r
-  DEBUG_PROC                StubEntry;\r
-  VOID (*RegisteredCallback) ();\r
+  IA32_IDT_GATE_DESCRIPTOR    OrigDesc;\r
+  DEBUG_PROC                  OrigVector;\r
+  IA32_IDT_GATE_DESCRIPTOR    NewDesc;\r
+  DEBUG_PROC                  StubEntry;\r
+  CALLBACK_FUNC               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) (\r
+  VOID\r
+  );\r
+extern IDT_ENTRY                 *IdtEntryTable;\r
 extern IA32_IDT_GATE_DESCRIPTOR  NullDesc;\r
 \r
 /**\r
@@ -86,28 +81,13 @@ FxStorSupport (
 **/\r
 VOID\r
 Vect2Desc (\r
-  IA32_IDT_GATE_DESCRIPTOR DestDesc,\r
-  VOID (*Vector) (VOID)\r
+  IA32_IDT_GATE_DESCRIPTOR  *DestDesc,\r
+  VOID (                    *Vector )(VOID)\r
   );\r
 \r
 /**\r
-  Programs interrupt flag to the requested state and returns previous\r
-  state.\r
+  Initializes driver's handler registration database.\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
   This code executes in boot services context\r
   Must be public because it's referenced from DebugSupport.c\r
 \r
@@ -135,86 +115,97 @@ PlInitializeDebugSupportDriver (
 EFI_STATUS\r
 EFIAPI\r
 PlUnloadDebugSupportDriver (\r
-  IN EFI_HANDLE                       ImageHandle\r
+  IN EFI_HANDLE  ImageHandle\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
-  @param  This                The DebugSupport instance\r
-  @param  MaxProcessorIndex   The maximuim supported processor index\r
+  Hard coded to support only 1 processor for now.\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
 EFIAPI\r
 GetMaximumProcessorIndex (\r
-  IN EFI_DEBUG_SUPPORT_PROTOCOL       *This,\r
-  OUT UINTN                           *MaxProcessorIndex\r
+  IN EFI_DEBUG_SUPPORT_PROTOCOL  *This,\r
+  OUT UINTN                      *MaxProcessorIndex\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
 RegisterPeriodicCallback (\r
-  IN EFI_DEBUG_SUPPORT_PROTOCOL       *This,\r
-  IN UINTN                            ProcessorIndex,\r
-  IN EFI_PERIODIC_CALLBACK            PeriodicCallback\r
+  IN EFI_DEBUG_SUPPORT_PROTOCOL  *This,\r
+  IN UINTN                       ProcessorIndex,\r
+  IN EFI_PERIODIC_CALLBACK       PeriodicCallback\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
-  @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
+  @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
-  IN EFI_EXCEPTION_CALLBACK           NewCallback,\r
-  IN EFI_EXCEPTION_TYPE               ExceptionType\r
+  IN EFI_DEBUG_SUPPORT_PROTOCOL  *This,\r
+  IN UINTN                       ProcessorIndex,\r
+  IN EFI_EXCEPTION_CALLBACK      ExceptionCallback,\r
+  IN EFI_EXCEPTION_TYPE          ExceptionType\r
   );\r
 \r
 /**\r
-  DebugSupport protocol member function.  Calls assembly routine to flush cache.\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              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
+  @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
+  @retval EFI_SUCCESS           Always returned.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 InvalidateInstructionCache (\r
-  IN EFI_DEBUG_SUPPORT_PROTOCOL       *This,\r
-  IN UINTN                            ProcessorIndex,\r
-  IN VOID                             *Start,\r
-  IN UINT64                           Length\r
+  IN EFI_DEBUG_SUPPORT_PROTOCOL  *This,\r
+  IN UINTN                       ProcessorIndex,\r
+  IN VOID                        *Start,\r
+  IN UINT64                      Length\r
   );\r
 \r
 /**\r
@@ -227,24 +218,23 @@ InvalidateInstructionCache (
                           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
+VOID\r
 CreateEntryStub (\r
-  IN EFI_EXCEPTION_TYPE     ExceptionType,\r
-  OUT VOID                  **Stub\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
-  @return Procedure Entry Point located in IDT Gate Descriptor.\r
+  @return Interrupt Handle stored in IDT Gate Descriptor.\r
 \r
 **/\r
-UINTN GetProcedureEntryPoint (\r
+UINTN\r
+GetInterruptHandleFromIdt (\r
   IN IA32_IDT_GATE_DESCRIPTOR  *IdtGateDecriptor\r
   );\r
 \r
@@ -268,8 +258,8 @@ UINTN GetProcedureEntryPoint (
 **/\r
 EFI_STATUS\r
 ManageIdtEntryTable (\r
-  VOID (*NewCallback)(),\r
-  EFI_EXCEPTION_TYPE ExceptionType\r
+  CALLBACK_FUNC       NewCallback,\r
+  EFI_EXCEPTION_TYPE  ExceptionType\r
   );\r
 \r
 /**\r
@@ -283,13 +273,11 @@ ManageIdtEntryTable (
   @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
-EFI_STATUS\r
+VOID\r
 HookEntry (\r
-  IN EFI_EXCEPTION_TYPE            ExceptionType,\r
-  IN VOID                         (*NewCallback) ()\r
+  IN EFI_EXCEPTION_TYPE  ExceptionType,\r
+  IN CALLBACK_FUNC       NewCallback\r
   );\r
 \r
 /**\r
@@ -297,12 +285,10 @@ HookEntry (
 \r
   @param  ExceptionType   Specifies which entry to unhook\r
 \r
-  @retval EFI_SUCCESS     Always.\r
-\r
 **/\r
-EFI_STATUS\r
+VOID\r
 UnhookEntry (\r
-  IN EFI_EXCEPTION_TYPE           ExceptionType\r
+  IN EFI_EXCEPTION_TYPE  ExceptionType\r
   );\r
 \r
 #endif\r