]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
MdeModulePkg DxeCore/PiSmmCore: Add UEFI memory and SMRAM profile support.
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / PiSmmCore.h
index 5cd123705600b0e5ad67add6a3c058ae7ec42f52..d494519d2c2047bab9a92d4e845bc00f7c1ac155 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 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2014, 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
@@ -20,6 +20,7 @@
 \r
 #include <Protocol/DxeSmmReadyToLock.h>\r
 #include <Protocol/SmmReadyToLock.h>\r
+#include <Protocol/SmmEndOfDxe.h>\r
 #include <Protocol/CpuIo2.h>\r
 #include <Protocol/SmmCommunication.h>\r
 #include <Protocol/SmmAccess2.h>\r
 #include <Protocol/LoadedImage.h>       \r
 #include <Protocol/DevicePath.h>        \r
 #include <Protocol/Security.h>          \r
+#include <Protocol/Security2.h>\r
 \r
 #include <Guid/Apriori.h>\r
 #include <Guid/EventGroup.h>\r
 #include <Guid/EventLegacyBios.h>\r
+#include <Guid/ZeroGuid.h>\r
+#include <Guid/MemoryProfile.h>\r
 \r
 #include <Library/BaseLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
@@ -43,6 +47,9 @@
 #include <Library/UefiLib.h>                   \r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/SmmCorePlatformHookLib.h>\r
+#include <Library/PerformanceLib.h>\r
+#include <Library/TimerLib.h>\r
 \r
 #include "PiSmmCorePrivateData.h"\r
 \r
@@ -266,6 +273,31 @@ SmmAllocatePages (
   OUT     EFI_PHYSICAL_ADDRESS      *Memory\r
   );\r
 \r
+/**\r
+  Allocates pages from the memory map.\r
+\r
+  @param  Type                   The type of allocation to perform\r
+  @param  MemoryType             The type of memory to turn the allocated pages\r
+                                 into\r
+  @param  NumberOfPages          The number of pages to allocate\r
+  @param  Memory                 A pointer to receive the base allocated memory\r
+                                 address\r
+\r
+  @retval EFI_INVALID_PARAMETER  Parameters violate checking rules defined in spec.\r
+  @retval EFI_NOT_FOUND          Could not allocate pages match the requirement.\r
+  @retval EFI_OUT_OF_RESOURCES   No enough pages to allocate.\r
+  @retval EFI_SUCCESS            Pages successfully allocated.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmInternalAllocatePages (\r
+  IN      EFI_ALLOCATE_TYPE         Type,\r
+  IN      EFI_MEMORY_TYPE           MemoryType,\r
+  IN      UINTN                     NumberOfPages,\r
+  OUT     EFI_PHYSICAL_ADDRESS      *Memory\r
+  );\r
+\r
 /**\r
   Frees previous allocated pages.\r
 \r
@@ -284,6 +316,24 @@ SmmFreePages (
   IN      UINTN                     NumberOfPages\r
   );\r
 \r
+/**\r
+  Frees previous allocated pages.\r
+\r
+  @param  Memory                 Base address of memory being freed\r
+  @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
+  @return EFI_SUCCESS            Pages successfully freed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmInternalFreePages (\r
+  IN      EFI_PHYSICAL_ADDRESS      Memory,\r
+  IN      UINTN                     NumberOfPages\r
+  );\r
+\r
 /**\r
   Allocate pool of a particular type.\r
 \r
@@ -305,6 +355,27 @@ SmmAllocatePool (
   OUT     VOID                      **Buffer\r
   );\r
 \r
+/**\r
+  Allocate pool of a particular type.\r
+\r
+  @param  PoolType               Type of pool to allocate\r
+  @param  Size                   The amount of pool to allocate\r
+  @param  Buffer                 The address to return a pointer to the allocated\r
+                                 pool\r
+\r
+  @retval EFI_INVALID_PARAMETER  PoolType not valid\r
+  @retval EFI_OUT_OF_RESOURCES   Size exceeds max pool size or allocation failed.\r
+  @retval EFI_SUCCESS            Pool successfully allocated.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmInternalAllocatePool (\r
+  IN      EFI_MEMORY_TYPE           PoolType,\r
+  IN      UINTN                     Size,\r
+  OUT     VOID                      **Buffer\r
+  );\r
+\r
 /**\r
   Frees pool.\r
 \r
@@ -320,6 +391,21 @@ SmmFreePool (
   IN      VOID                      *Buffer\r
   );\r
 \r
+/**\r
+  Frees pool.\r
+\r
+  @param  Buffer                 The allocated pool entry to free\r
+\r
+  @retval EFI_INVALID_PARAMETER  Buffer is not a valid value.\r
+  @retval EFI_SUCCESS            Pool successfully freed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmInternalFreePool (\r
+  IN      VOID                      *Buffer\r
+  );\r
+\r
 /**\r
   Installs a protocol interface into the boot services environment.\r
 \r
@@ -582,6 +668,28 @@ SmmReadyToLockHandler (
   IN OUT UINTN                    *CommBufferSize  OPTIONAL\r
   );\r
 \r
+/**\r
+  This function is the main entry point for an SMM handler dispatch\r
+  or communicate-based callback.\r
+\r
+  @param  DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().\r
+  @param  Context         Points to an optional handler context which was specified when the handler was registered.\r
+  @param  CommBuffer      A pointer to a collection of data in memory that will\r
+                          be conveyed from a non-SMM environment into an SMM environment.\r
+  @param  CommBufferSize  The size of the CommBuffer.\r
+\r
+  @return Status Code\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SmmEndOfDxeHandler (\r
+  IN     EFI_HANDLE               DispatchHandle,\r
+  IN     CONST VOID               *Context,        OPTIONAL\r
+  IN OUT VOID                     *CommBuffer,     OPTIONAL\r
+  IN OUT UINTN                    *CommBufferSize  OPTIONAL\r
+  );\r
+\r
 /**\r
   Place holder function until all the SMM System Table Service are available.\r
 \r
@@ -714,4 +822,101 @@ SmmIsSchedulable (
   IN  EFI_SMM_DRIVER_ENTRY   *DriverEntry\r
   );\r
 \r
+//\r
+// SmramProfile\r
+//\r
+\r
+/**\r
+  Initialize SMRAM profile.\r
+\r
+**/\r
+VOID\r
+SmramProfileInit (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Register SMM image to SMRAM profile.\r
+\r
+  @param DriverEntry    SMM image info.\r
+  @param RegisterToDxe  Register image to DXE.\r
+\r
+  @retval TRUE          Register success.\r
+  @retval FALSE         Register fail.\r
+\r
+**/\r
+BOOLEAN\r
+RegisterSmramProfileImage (\r
+  IN EFI_SMM_DRIVER_ENTRY   *DriverEntry,\r
+  IN BOOLEAN                RegisterToDxe\r
+  );\r
+\r
+/**\r
+  Unregister image from SMRAM profile.\r
+\r
+  @param DriverEntry        SMM image info.\r
+  @param UnregisterToDxe    Unregister image from DXE.\r
+\r
+  @retval TRUE              Unregister success.\r
+  @retval FALSE             Unregister fail.\r
+\r
+**/\r
+BOOLEAN\r
+UnregisterSmramProfileImage (\r
+  IN EFI_SMM_DRIVER_ENTRY   *DriverEntry,\r
+  IN BOOLEAN                UnregisterToDxe\r
+  );\r
+\r
+/**\r
+  Update SMRAM profile information.\r
+\r
+  @param CallerAddress  Address of caller who call Allocate or Free.\r
+  @param Action         This Allocate or Free action.\r
+  @param MemoryType     Memory type.\r
+  @param Size           Buffer size.\r
+  @param Buffer         Buffer address.\r
+\r
+  @retval TRUE          Profile udpate success.\r
+  @retval FALSE         Profile update fail.\r
+\r
+**/\r
+BOOLEAN\r
+SmmCoreUpdateProfile (\r
+  IN EFI_PHYSICAL_ADDRESS CallerAddress,\r
+  IN MEMORY_PROFILE_ACTION Action,\r
+  IN EFI_MEMORY_TYPE      MemoryType, // Valid for AllocatePages/AllocatePool\r
+  IN UINTN                Size,       // Valid for AllocatePages/FreePages/AllocatePool\r
+  IN VOID                 *Buffer\r
+  );\r
+\r
+/**\r
+  Register SMRAM profile handler.\r
+\r
+**/\r
+VOID\r
+RegisterSmramProfileHandler (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  SMRAM profile ready to lock callback function.\r
+\r
+**/\r
+VOID\r
+SmramProfileReadyToLock (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Dump SMRAM infromation.\r
+\r
+**/\r
+VOID\r
+DumpSmramInfo (\r
+  VOID\r
+  );\r
+\r
+extern UINTN                    mFullSmramRangeCount;\r
+extern EFI_SMRAM_DESCRIPTOR     *mFullSmramRanges;\r
+\r
 #endif\r