]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Mem/Imem.h
MdeModulePkg/Core: allow HeapGuard even before CpuArchProtocol installed
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Mem / Imem.h
index 8a60d59f4c1c7aa9bb2febdc2255524e893f3503..e58a5d62babbd18eda6e6440ca5ade1be6b71a64 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Data structure and functions to allocate and free memory space.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2017, 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
 http://opensource.org/licenses/bsd-license.php\r
@@ -15,28 +15,27 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _IMEM_H_\r
 #define _IMEM_H_\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
-#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
+//\r
+// +---------------------------------------------------+\r
+// | 0..(EfiMaxMemoryType - 1)    - Normal memory type |\r
+// +---------------------------------------------------+\r
+// | EfiMaxMemoryType..0x6FFFFFFF - Invalid            |\r
+// +---------------------------------------------------+\r
+// | 0x70000000..0x7FFFFFFF       - OEM reserved       |\r
+// +---------------------------------------------------+\r
+// | 0x80000000..0xFFFFFFFF       - OS reserved        |\r
+// +---------------------------------------------------+\r
+//\r
+#define MEMORY_TYPE_OS_RESERVED_MIN                 0x80000000\r
+#define MEMORY_TYPE_OS_RESERVED_MAX                 0xFFFFFFFF\r
+#define MEMORY_TYPE_OEM_RESERVED_MIN                0x70000000\r
+#define MEMORY_TYPE_OEM_RESERVED_MAX                0x7FFFFFFF\r
 \r
 //\r
 // MEMORY_MAP_ENTRY\r
 //\r
 \r
-#define MEMORY_MAP_SIGNATURE   EFI_SIGNATURE_32('m','m','a','p')\r
+#define MEMORY_MAP_SIGNATURE   SIGNATURE_32('m','m','a','p')\r
 typedef struct {\r
   UINTN           Signature;\r
   LIST_ENTRY      Link;\r
@@ -62,6 +61,7 @@ typedef struct {
   @param  PoolType               The type of memory for the new pool pages\r
   @param  NumberOfPages          No of pages to allocate\r
   @param  Alignment              Bits to align.\r
+  @param  NeedGuard              Flag to indicate Guard page is needed or not\r
 \r
   @return The allocated memory, or NULL\r
 \r
@@ -70,7 +70,8 @@ VOID *
 CoreAllocatePoolPages (\r
   IN EFI_MEMORY_TYPE    PoolType,\r
   IN UINTN              NumberOfPages,\r
-  IN UINTN              Alignment\r
+  IN UINTN              Alignment,\r
+  IN BOOLEAN            NeedGuard\r
   );\r
 \r
 \r
@@ -96,6 +97,7 @@ CoreFreePoolPages (
 \r
   @param  PoolType               Type of pool to allocate\r
   @param  Size                   The amount of pool to allocate\r
+  @param  NeedGuard              Flag to indicate Guard page is needed or not\r
 \r
   @return The allocate pool, or NULL\r
 \r
@@ -103,7 +105,8 @@ CoreFreePoolPages (
 VOID *\r
 CoreAllocatePoolI (\r
   IN EFI_MEMORY_TYPE  PoolType,\r
-  IN UINTN            Size\r
+  IN UINTN            Size,\r
+  IN BOOLEAN          NeedGuard\r
   );\r
 \r
 \r
@@ -113,6 +116,7 @@ CoreAllocatePoolI (
   Caller must have the memory lock held\r
 \r
   @param  Buffer                 The allocated pool entry to free\r
+  @param  PoolType               Pointer to pool type\r
 \r
   @retval EFI_INVALID_PARAMETER  Buffer not valid\r
   @retval EFI_SUCCESS            Buffer successfully freed.\r
@@ -120,7 +124,8 @@ CoreAllocatePoolI (
 **/\r
 EFI_STATUS\r
 CoreFreePoolI (\r
-  IN VOID       *Buffer\r
+  IN VOID               *Buffer,\r
+  OUT EFI_MEMORY_TYPE   *PoolType OPTIONAL\r
   );\r
 \r
 \r
@@ -144,6 +149,34 @@ CoreReleaseMemoryLock (
   VOID\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
+  @param  NeedGuard              Flag to indicate Guard page is needed or not\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
+  IN BOOLEAN                NeedGuard\r
+  );\r
 \r
 //\r
 // Internal Global data\r