]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg DxeCore: Enhance memory profile for memory leak detection
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / DxeMain.h
index 059a38336acdd4502becdcae202a488198b269b8..743221f6755e343e482218dcf04b3da9523eb29a 100644 (file)
@@ -2,7 +2,7 @@
   The internal header file includes the common header files, defines\r
   internal structure and functions used by DxeCore module.\r
 \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
 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
@@ -124,6 +124,31 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 ///\r
 #define DEPEX_STACK_SIZE_INCREMENT  0x1000\r
 \r
+#if defined (MDE_CPU_IPF)\r
+///\r
+/// For Itanium machines make the default allocations 8K aligned\r
+///\r
+#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT  (EFI_PAGE_SIZE * 2)\r
+#define DEFAULT_PAGE_ALLOCATION                     (EFI_PAGE_SIZE * 2)\r
+\r
+#elif defined (MDE_CPU_AARCH64)\r
+///\r
+/// 64-bit ARM systems allow the OS to execute with 64 KB page size,\r
+/// so for improved interoperability with the firmware, align the\r
+/// runtime regions to 64 KB as well\r
+///\r
+#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT  (SIZE_64KB)\r
+#define DEFAULT_PAGE_ALLOCATION                     (EFI_PAGE_SIZE)\r
+\r
+#else\r
+///\r
+/// For genric 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
+#endif\r
+\r
 typedef struct {\r
   EFI_GUID                    *ProtocolGuid;\r
   VOID                        **Protocol;\r
@@ -251,6 +276,8 @@ extern EFI_RUNTIME_SERVICES                     *gDxeCoreRT;
 extern EFI_DXE_SERVICES                         *gDxeCoreDS;\r
 extern EFI_HANDLE                               gDxeCoreImageHandle;\r
 \r
+extern BOOLEAN                                  gMemoryMapTerminated;\r
+\r
 extern EFI_DECOMPRESS_PROTOCOL                  gEfiDecompress;\r
 \r
 extern EFI_RUNTIME_ARCH_PROTOCOL                *gRuntime;\r
@@ -1244,33 +1271,6 @@ CoreAllocatePages (
   IN 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
-  @return Status. On success, Memory is filled in with the base address allocated\r
-  @retval EFI_INVALID_PARAMETER  Parameters violate checking rules defined in\r
-                                 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
-CoreInternalAllocatePages (\r
-  IN EFI_ALLOCATE_TYPE      Type,\r
-  IN EFI_MEMORY_TYPE        MemoryType,\r
-  IN UINTN                  NumberOfPages,\r
-  IN OUT EFI_PHYSICAL_ADDRESS  *Memory\r
-  );\r
-\r
 /**\r
   Frees previous allocated pages.\r
 \r
@@ -1289,24 +1289,6 @@ CoreFreePages (
   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
-CoreInternalFreePages (\r
-  IN EFI_PHYSICAL_ADDRESS   Memory,\r
-  IN UINTN                  NumberOfPages\r
-  );\r
-\r
 /**\r
   This function returns a copy of the current memory map. The map is an array of\r
   memory descriptors, each of which describes a contiguous block of memory.\r
@@ -1410,6 +1392,7 @@ CoreFreePool (
   Frees pool.\r
 \r
   @param  Buffer                 The allocated pool entry to free\r
+  @param  PoolType               Pointer to pool type\r
 \r
   @retval EFI_INVALID_PARAMETER  Buffer is not a valid value.\r
   @retval EFI_SUCCESS            Pool successfully freed.\r
@@ -1418,7 +1401,8 @@ CoreFreePool (
 EFI_STATUS\r
 EFIAPI\r
 CoreInternalFreePool (\r
-  IN VOID        *Buffer\r
+  IN VOID               *Buffer,\r
+  OUT EFI_MEMORY_TYPE   *PoolType OPTIONAL\r
   );\r
 \r
 /**\r
@@ -2796,11 +2780,13 @@ MemoryProfileInstallProtocol (
   @param DriverEntry    Image info.\r
   @param FileType       Image file type.\r
 \r
-  @retval TRUE          Register success.\r
-  @retval FALSE         Register fail.\r
+  @return EFI_SUCCESS           Register successfully.\r
+  @return EFI_UNSUPPORTED       Memory profile unsupported,\r
+                                or memory profile for the image is not required.\r
+  @return EFI_OUT_OF_RESOURCES  No enough resource for this register.\r
 \r
 **/\r
-BOOLEAN\r
+EFI_STATUS\r
 RegisterMemoryProfileImage (\r
   IN LOADED_IMAGE_PRIVATE_DATA  *DriverEntry,\r
   IN EFI_FV_FILETYPE            FileType\r
@@ -2811,11 +2797,13 @@ RegisterMemoryProfileImage (
 \r
   @param DriverEntry    Image info.\r
 \r
-  @retval TRUE          Unregister success.\r
-  @retval FALSE         Unregister fail.\r
+  @return EFI_SUCCESS           Unregister successfully.\r
+  @return EFI_UNSUPPORTED       Memory profile unsupported,\r
+                                or memory profile for the image is not required.\r
+  @return EFI_NOT_FOUND         The image is not found.\r
 \r
 **/\r
-BOOLEAN\r
+EFI_STATUS\r
 UnregisterMemoryProfileImage (\r
   IN LOADED_IMAGE_PRIVATE_DATA  *DriverEntry\r
   );\r
@@ -2826,20 +2814,31 @@ UnregisterMemoryProfileImage (
   @param CallerAddress  Address of caller who call Allocate or Free.\r
   @param Action         This Allocate or Free action.\r
   @param MemoryType     Memory type.\r
+                        EfiMaxMemoryType means the MemoryType is unknown.\r
   @param Size           Buffer size.\r
   @param Buffer         Buffer address.\r
+  @param ActionString   String for memory profile action.\r
+                        Only needed for user defined allocate action.\r
 \r
-  @retval TRUE          Profile udpate success.\r
-  @retval FALSE         Profile update fail.\r
+  @return EFI_SUCCESS           Memory profile is updated.\r
+  @return EFI_UNSUPPORTED       Memory profile is unsupported,\r
+                                or memory profile for the image is not required,\r
+                                or memory profile for the memory type is not required.\r
+  @return EFI_ACCESS_DENIED     It is during memory profile data getting.\r
+  @return EFI_ABORTED           Memory profile recording is not enabled.\r
+  @return EFI_OUT_OF_RESOURCES  No enough resource to update memory profile for allocate action.\r
+  @return EFI_NOT_FOUND         No matched allocate info found for free action.\r
 \r
 **/\r
-BOOLEAN\r
+EFI_STATUS\r
+EFIAPI\r
 CoreUpdateProfile (\r
   IN EFI_PHYSICAL_ADDRESS   CallerAddress,\r
   IN MEMORY_PROFILE_ACTION  Action,\r
-  IN EFI_MEMORY_TYPE        MemoryType, // Valid for AllocatePages/AllocatePool\r
+  IN EFI_MEMORY_TYPE        MemoryType,\r
   IN UINTN                  Size,       // Valid for AllocatePages/FreePages/AllocatePool\r
-  IN VOID                   *Buffer\r
+  IN VOID                   *Buffer,\r
+  IN CHAR8                  *ActionString OPTIONAL\r
   );\r
 \r
 /**\r
@@ -2850,12 +2849,6 @@ CoreUpdateProfile (
   @param  NumberOfPages          The number of pages to convert\r
   @param  NewAttributes          The new attributes value for the range.\r
 \r
-  @retval EFI_INVALID_PARAMETER  Invalid parameter\r
-  @retval EFI_NOT_FOUND          Could not find a descriptor cover the specified\r
-                                 range  or convertion not allowed.\r
-  @retval EFI_SUCCESS            Successfully converts the memory range to the\r
-                                 specified attributes.\r
-\r
 **/\r
 VOID\r
 CoreUpdateMemoryAttributes (\r
@@ -2864,4 +2857,52 @@ CoreUpdateMemoryAttributes (
   IN UINT64                NewAttributes\r
   );\r
 \r
+/**\r
+  Initialize PropertiesTable support.\r
+**/\r
+VOID\r
+EFIAPI\r
+CoreInitializePropertiesTable (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Initialize MemoryAttrubutesTable support.\r
+**/\r
+VOID\r
+EFIAPI\r
+CoreInitializeMemoryAttributesTable (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Install MemoryAttributesTable on memory allocation.\r
+\r
+  @param[in] MemoryType EFI memory type.\r
+**/\r
+VOID\r
+InstallMemoryAttributesTableOnMemoryAllocation (\r
+  IN EFI_MEMORY_TYPE    MemoryType\r
+  );\r
+\r
+/**\r
+  Insert image record.\r
+\r
+  @param  RuntimeImage    Runtime image information\r
+**/\r
+VOID\r
+InsertImageRecord (\r
+  IN EFI_RUNTIME_IMAGE_ENTRY  *RuntimeImage\r
+  );\r
+\r
+/**\r
+  Remove Image record.\r
+\r
+  @param  RuntimeImage    Runtime image information\r
+**/\r
+VOID\r
+RemoveImageRecord (\r
+  IN EFI_RUNTIME_IMAGE_ENTRY  *RuntimeImage\r
+  );\r
+\r
 #endif\r