]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h
MdeModulePkg/CpuExceptionHandlerLib.h: Add a new API InitializeCpuExceptionHandlersEx
[mirror_edk2.git] / MdeModulePkg / Include / Library / CpuExceptionHandlerLib.h
index 6cd823012749af0daea7aaf1db79c363fed993d9..8cc9bac7609a0a2fc52a088350e055f51ff450bf 100644 (file)
 #include <Ppi/VectorHandoffInfo.h>\r
 #include <Protocol/Cpu.h>\r
 \r
+#define CPU_EXCEPTION_INIT_DATA_REV     1\r
+\r
+typedef union {\r
+  struct {\r
+    //\r
+    // Revision number of this structure.\r
+    //\r
+    UINT32                    Revision;\r
+    //\r
+    // The address of top of known good stack reserved for *ALL* exceptions\r
+    // listed in field StackSwitchExceptions.\r
+    //\r
+    UINTN                     KnownGoodStackTop;\r
+    //\r
+    // The size of known good stack for *ONE* exception only.\r
+    //\r
+    UINTN                     KnownGoodStackSize;\r
+    //\r
+    // Buffer of exception vector list for stack switch.\r
+    //\r
+    UINT8                     *StackSwitchExceptions;\r
+    //\r
+    // Number of exception vectors in StackSwitchExceptions.\r
+    //\r
+    UINTN                     StackSwitchExceptionNumber;\r
+    //\r
+    // Buffer of IDT table. It must be type of IA32_IDT_GATE_DESCRIPTOR.\r
+    // Normally there's no need to change IDT table size.\r
+    //\r
+    VOID                      *IdtTable;\r
+    //\r
+    // Size of buffer for IdtTable.\r
+    //\r
+    UINTN                     IdtTableSize;\r
+    //\r
+    // Buffer of GDT table. It must be type of IA32_SEGMENT_DESCRIPTOR.\r
+    //\r
+    VOID                      *GdtTable;\r
+    //\r
+    // Size of buffer for GdtTable.\r
+    //\r
+    UINTN                     GdtTableSize;\r
+    //\r
+    // Pointer to start address of descriptor of exception task gate in the\r
+    // GDT table. It must be type of IA32_TSS_DESCRIPTOR.\r
+    //\r
+    VOID                      *ExceptionTssDesc;\r
+    //\r
+    // Size of buffer for ExceptionTssDesc.\r
+    //\r
+    UINTN                     ExceptionTssDescSize;\r
+    //\r
+    // Buffer of task-state segment for exceptions. It must be type of\r
+    // IA32_TASK_STATE_SEGMENT.\r
+    //\r
+    VOID                      *ExceptionTss;\r
+    //\r
+    // Size of buffer for ExceptionTss.\r
+    //\r
+    UINTN                     ExceptionTssSize;\r
+    //\r
+    // Flag to indicate if default handlers should be initialized or not.\r
+    //\r
+    BOOLEAN                   InitDefaultHandlers;\r
+  } Ia32, X64;\r
+} CPU_EXCEPTION_INIT_DATA;\r
+\r
 /**\r
   Initializes all CPU exceptions entries and provides the default exception handlers.\r
   \r
@@ -41,6 +108,36 @@ InitializeCpuExceptionHandlers (
   IN EFI_VECTOR_HANDOFF_INFO       *VectorInfo OPTIONAL\r
   );\r
 \r
+/**\r
+  Initializes all CPU exceptions entries with optional extra initializations.\r
+\r
+  By default, this method should include all functionalities implemented by\r
+  InitializeCpuExceptionHandlers(), plus extra initialization works, if any.\r
+  This could be done by calling InitializeCpuExceptionHandlers() directly\r
+  in this method besides the extra works.\r
+\r
+  InitData is optional and its use and content are processor arch dependent.\r
+  The typical usage of it is to convey resources which have to be reserved\r
+  elsewhere and are necessary for the extra initializations of exception.\r
+\r
+  @param[in]  VectorInfo    Pointer to reserved vector list.\r
+  @param[in]  InitData      Pointer to data optional for extra initializations\r
+                            of exception.\r
+\r
+  @retval EFI_SUCCESS             The exceptions have been successfully\r
+                                  initialized.\r
+  @retval EFI_INVALID_PARAMETER   VectorInfo or InitData contains invalid\r
+                                  content.\r
+  @retval EFI_UNSUPPORTED         This function is not supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeCpuExceptionHandlersEx (\r
+  IN EFI_VECTOR_HANDOFF_INFO            *VectorInfo OPTIONAL,\r
+  IN CPU_EXCEPTION_INIT_DATA            *InitData OPTIONAL\r
+  );\r
+\r
 /**\r
   Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.\r
   \r