]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg: Add AllocateRuntimePages in PrePiMemoryAllocationLib
authorMin M Xu <min.m.xu@intel.com>
Wed, 22 Jun 2022 01:00:23 +0000 (09:00 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 6 Sep 2022 07:21:42 +0000 (07:21 +0000)
AllocateRuntimePages is used to allocate one or more 4KB pages of
type EfiRuntimeServicesData.

Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Abner Chang <abner.chang@hpe.com>
Cc: Daniel Schaefer <daniel.schaefer@hpe.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb+tianocore@kernel.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
EmbeddedPkg/Include/Library/PrePiLib.h
EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

index 7b2cea296f1c849dca156707f567cc27beb7456b..3741b08c44780d4eafff37a5df645d82160420f7 100644 (file)
@@ -665,6 +665,25 @@ AllocatePages (
   IN UINTN  Pages\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
 /**\r
   Allocates a buffer of type EfiBootServicesData.\r
 \r
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