]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
MdeModulePkg/SmmCore: Add Context in SmiHandlerProfileUnregister.
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / PiSmmCore.h
index 58590d5f6169e6ad2e18fb8adae20b5be0a41f79..c12805a2dd964c49df44f640ef017ed92fd56ef3 100644 (file)
@@ -2,7 +2,7 @@
   The internal header file includes the common header files, defines\r
   internal structure and functions used by SmmCore module.\r
 \r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available \r
   under the terms and conditions of the BSD License which accompanies this \r
   distribution.  The full text of the license may be found at        \r
@@ -38,6 +38,7 @@
 #include <Guid/EventLegacyBios.h>\r
 #include <Guid/MemoryProfile.h>\r
 #include <Guid/LoadModuleAtFixedAddress.h>\r
+#include <Guid/SmiHandlerProfile.h>\r
 \r
 #include <Library/BaseLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
@@ -69,6 +70,32 @@ typedef struct {
   BOOLEAN                       UnRegister;\r
 } SMM_CORE_SMI_HANDLERS;\r
 \r
+//\r
+// SMM_HANDLER - used for each SMM handler\r
+//\r
+\r
+#define SMI_ENTRY_SIGNATURE  SIGNATURE_32('s','m','i','e')\r
+\r
+ typedef struct {\r
+  UINTN       Signature;\r
+  LIST_ENTRY  AllEntries;  // All entries\r
+\r
+  EFI_GUID    HandlerType; // Type of interrupt\r
+  LIST_ENTRY  SmiHandlers; // All handlers\r
+} SMI_ENTRY;\r
+\r
+#define SMI_HANDLER_SIGNATURE  SIGNATURE_32('s','m','i','h')\r
+\r
+ typedef struct {\r
+  UINTN                         Signature;\r
+  LIST_ENTRY                    Link;        // Link on SMI_ENTRY.SmiHandlers\r
+  EFI_SMM_HANDLER_ENTRY_POINT2  Handler;     // The smm handler's entry point\r
+  UINTN                         CallerAddr;  // The address of caller who register the SMI handler.\r
+  SMI_ENTRY                     *SmiEntry;\r
+  VOID                          *Context;    // for profile\r
+  UINTN                         ContextSize; // for profile\r
+} SMI_HANDLER;\r
+\r
 //\r
 // Structure for recording the state of an SMM Driver\r
 //\r
@@ -1064,11 +1091,71 @@ SmmCoreGetMemoryMap (
   OUT UINT32                    *DescriptorVersion\r
   );\r
 \r
-///\r
-/// For generic EFI machines make the default allocations 4K aligned\r
-///\r
-#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT  (EFI_PAGE_SIZE)\r
-#define DEFAULT_PAGE_ALLOCATION                     (EFI_PAGE_SIZE)\r
+/**\r
+  Initialize SmiHandler profile feature.\r
+**/\r
+VOID\r
+SmmCoreInitializeSmiHandlerProfile (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function is called by SmmChildDispatcher module to report\r
+  a new SMI handler is registered, to SmmCore.\r
+\r
+  @param This            The protocol instance\r
+  @param HandlerGuid     The GUID to identify the type of the handler.\r
+                         For the SmmChildDispatch protocol, the HandlerGuid\r
+                         must be the GUID of SmmChildDispatch protocol.\r
+  @param Handler         The SMI handler.\r
+  @param CallerAddress   The address of the module who registers the SMI handler.\r
+  @param Context         The context of the SMI handler.\r
+                         For the SmmChildDispatch protocol, the Context\r
+                         must match the one defined for SmmChildDispatch protocol.\r
+  @param ContextSize     The size of the context in bytes.\r
+                         For the SmmChildDispatch protocol, the Context\r
+                         must match the one defined for SmmChildDispatch protocol.\r
+\r
+  @retval EFI_SUCCESS           The information is recorded.\r
+  @retval EFI_OUT_OF_RESOURCES  There is no enough resource to record the information.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmiHandlerProfileRegisterHandler (\r
+  IN SMI_HANDLER_PROFILE_PROTOCOL   *This,\r
+  IN EFI_GUID                       *HandlerGuid,\r
+  IN EFI_SMM_HANDLER_ENTRY_POINT2   Handler,\r
+  IN PHYSICAL_ADDRESS               CallerAddress,\r
+  IN VOID                           *Context, OPTIONAL\r
+  IN UINTN                          ContextSize OPTIONAL\r
+  );\r
+\r
+/**\r
+  This function is called by SmmChildDispatcher module to report\r
+  an existing SMI handler is unregistered, to SmmCore.\r
+\r
+  @param This            The protocol instance\r
+  @param HandlerGuid     The GUID to identify the type of the handler.\r
+                         For the SmmChildDispatch protocol, the HandlerGuid\r
+                         must be the GUID of SmmChildDispatch protocol.\r
+  @param Handler         The SMI handler.\r
+  @param Context         The context of the SMI handler.\r
+                         If it is NOT NULL, it will be used to check what is registered.\r
+  @param ContextSize     The size of the context in bytes.\r
+                         If Context is NOT NULL, it will be used to check what is registered.\r
+\r
+  @retval EFI_SUCCESS           The original record is removed.\r
+  @retval EFI_NOT_FOUND         There is no record for the HandlerGuid and handler.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmiHandlerProfileUnregisterHandler (\r
+  IN SMI_HANDLER_PROFILE_PROTOCOL   *This,\r
+  IN EFI_GUID                       *HandlerGuid,\r
+  IN EFI_SMM_HANDLER_ENTRY_POINT2   Handler,\r
+  IN VOID                           *Context, OPTIONAL\r
+  IN UINTN                          ContextSize OPTIONAL\r
+  );\r
 \r
 extern UINTN                    mFullSmramRangeCount;\r
 extern EFI_SMRAM_DESCRIPTOR     *mFullSmramRanges;\r