]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
EmbeddedPkg: Add AllocateRuntimePages in PrePiMemoryAllocationLib
[mirror_edk2.git] / EmbeddedPkg / Library / PrePiMemoryAllocationLib / MemoryAllocationLib.c
index 78f8da5e9527aa69e84eb3fad5bdaa45b2c168e1..2cc2a711219790279cad73bc879e158ca9cce548 100644 (file)
 #include <Library/PrePiLib.h>\r
 #include <Library/DebugLib.h>\r
 \r
-/**\r
-  Allocates one or more 4KB pages of type EfiBootServicesData.\r
-\r
-  Allocates the number of 4KB pages of MemoryType and returns a pointer to the\r
-  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
-  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
-  returned.\r
-\r
-  @param  Pages                 The number of 4 KB pages to allocate.\r
-\r
-  @return A pointer to the allocated buffer or NULL if allocation fails.\r
-\r
-**/\r
+STATIC\r
 VOID *\r
 EFIAPI\r
-AllocatePages (\r
-  IN UINTN  Pages\r
+InternalAllocatePages (\r
+  IN UINTN            Pages,\r
+  IN EFI_MEMORY_TYPE  MemoryType\r
   )\r
 {\r
   EFI_PEI_HOB_POINTERS  Hob;\r
@@ -65,12 +54,56 @@ AllocatePages (
     BuildMemoryAllocationHob (\r
       Hob.HandoffInformationTable->EfiFreeMemoryTop,\r
       Pages * EFI_PAGE_SIZE,\r
-      EfiBootServicesData\r
+      MemoryType\r
       );\r
     return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;\r
   }\r
 }\r
 \r
+/**\r
+  Allocates one or more 4KB pages of type EfiBootServicesData.\r
+\r
+  Allocates the number of 4KB pages of MemoryType and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocatePages (\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  return InternalAllocatePages (Pages, EfiBootServicesData);\r
+}\r
+\r
+/**\r
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData.\r
+\r
+  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the\r
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL\r
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is\r
+  returned.\r
+\r
+  @param  Pages                 The number of 4 KB pages to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+AllocateRuntimePages (\r
+  IN UINTN  Pages\r
+  )\r
+{\r
+  return InternalAllocatePages (Pages, EfiRuntimeServicesData);\r
+}\r
+\r
 /**\r
   Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.\r
 \r