]> 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 e2fee549f8d82742c196fbf15aec7781d296e86f..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
@@ -37,6 +37,8 @@
 #include <Guid/EventGroup.h>\r
 #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
@@ -68,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
@@ -312,7 +340,7 @@ SmmInternalAllocatePages (
   @param  NumberOfPages          The number of pages to free\r
 \r
   @retval EFI_NOT_FOUND          Could not find the entry that covers the range\r
-  @retval EFI_INVALID_PARAMETER  Address not aligned\r
+  @retval EFI_INVALID_PARAMETER  Address not aligned, Address is zero or NumberOfPages is zero.\r
   @return EFI_SUCCESS            Pages successfully freed.\r
 \r
 **/\r
@@ -330,7 +358,7 @@ SmmFreePages (
   @param  NumberOfPages          The number of pages to free\r
 \r
   @retval EFI_NOT_FOUND          Could not find the entry that covers the range\r
-  @retval EFI_INVALID_PARAMETER  Address not aligned\r
+  @retval EFI_INVALID_PARAMETER  Address not aligned, Address is zero or NumberOfPages is zero.\r
   @return EFI_SUCCESS            Pages successfully freed.\r
 \r
 **/\r
@@ -1063,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
@@ -1109,8 +1197,9 @@ extern LIST_ENTRY  mSmmMemoryMap;
 #define MAX_POOL_INDEX  (MAX_POOL_SHIFT - MIN_POOL_SHIFT + 1)\r
 \r
 typedef struct {\r
-  UINTN        Size;\r
-  BOOLEAN      Available;\r
+  UINTN           Size;\r
+  BOOLEAN         Available;\r
+  EFI_MEMORY_TYPE Type;\r
 } POOL_HEADER;\r
 \r
 typedef struct {\r
@@ -1118,6 +1207,12 @@ typedef struct {
   LIST_ENTRY   Link;\r
 } FREE_POOL_HEADER;\r
 \r
-extern LIST_ENTRY  mSmmPoolLists[MAX_POOL_INDEX];\r
+typedef enum {\r
+  SmmPoolTypeCode,\r
+  SmmPoolTypeData,\r
+  SmmPoolTypeMax,\r
+} SMM_POOL_TYPE;\r
+\r
+extern LIST_ENTRY  mSmmPoolLists[SmmPoolTypeMax][MAX_POOL_INDEX];\r
 \r
 #endif\r