]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DebugSupportDxe/x64/plDebugSupport.h
Add DebugPort & DebugSupport drivers
[mirror_edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / x64 / plDebugSupport.h
diff --git a/MdeModulePkg/Universal/DebugSupportDxe/x64/plDebugSupport.h b/MdeModulePkg/Universal/DebugSupportDxe/x64/plDebugSupport.h
new file mode 100644 (file)
index 0000000..0f4e277
--- /dev/null
@@ -0,0 +1,342 @@
+/**@file\r
+  X64 specific debug support macros, typedefs and prototypes.\r
+\r
+Copyright (c) 2006, 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
+\r
+**/\r
+\r
+#ifndef _PLDEBUG_SUPPORT_H\r
+#define _PLDEBUG_SUPPORT_H\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiDxe.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/DebugSupport.h>\r
+#include <Protocol/LoadedImage.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseLib.h>\r
+\r
+#include <Library/PcdLib.h>\r
+#define NUM_IDT_ENTRIES                 0x78\r
+#define SYSTEM_TIMER_VECTOR             0x68\r
+#define VECTOR_ENTRY_PAGES              1\r
+#define CopyDescriptor(Dest, Src)       CopyMem ((Dest), (Src), sizeof (DESCRIPTOR))\r
+#define ZeroDescriptor(Dest)            CopyDescriptor ((Dest), &NullDesc)\r
+#define ReadIdt(Vector, Dest)           CopyDescriptor ((Dest), &((GetIdtr ())[(Vector)]))\r
+#define WriteIdt(Vector, Src)           CopyDescriptor (&((GetIdtr ())[(Vector)]), (Src))\r
+#define CompareDescriptor(Desc1, Desc2) CompareMem ((Desc1), (Desc2), sizeof (DESCRIPTOR))\r
+#define EFI_ISA                         IsaX64\r
+#define FF_FXSR                         (1 << 24)\r
+\r
+typedef struct {\r
+  UINT64 Low;\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
+  DEBUG_PROC  OrigVector;\r
+  DESCRIPTOR  NewDesc;\r
+  DEBUG_PROC  StubEntry;\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
+\r
+VOID\r
+CommonIdtEntry (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Generic IDT entry\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+\r
+BOOLEAN\r
+FxStorSupport (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Check whether FXSTOR is supported\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  TRUE  - supported\r
+  FALSE - not supported\r
+\r
+--*/\r
+;\r
+\r
+DESCRIPTOR  *\r
+GetIdtr (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Return the physical address of IDTR\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  The physical address of IDTR\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+Vect2Desc (\r
+  DESCRIPTOR * DestDesc,\r
+  VOID (*Vector) (VOID)\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Encodes an IDT descriptor with the given physical address\r
+\r
+Arguments:\r
+\r
+  DestDesc  - The IDT descriptor address\r
+  Vector    - The interrupt vector entry\r
+\r
+Returns:\r
+\r
+  None\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+WriteInterruptFlag (\r
+  BOOLEAN NewState\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Programs interrupt flag to the requested state and returns previous\r
+  state.\r
+\r
+Arguments:\r
+\r
+  NewState  - New interrupt status\r
+\r
+Returns:\r
+\r
+  Old interrupt status\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\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
+\r
+EFI_STATUS\r
+EFIAPI\r
+plUnloadDebugSupportDriver (\r
+  IN EFI_HANDLE                       ImageHandle\r
+  )\r
+/*++\r
+\r
+Routine Description:\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
+\r
+  EFI_SUCCESS - always return success\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// DebugSupport protocol member functions\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
+\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
+  )\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
+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
+\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
+  )\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
+\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
+  )\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
+\r
+#endif\r