]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add parameter checking for PEI service AllocatePages(), according to PI1.2 errata A.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Feb 2010 09:26:52 +0000 (09:26 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Feb 2010 09:26:52 +0000 (09:26 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10112 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Pei/Memory/MemoryServices.c

index 7e1bb55242cc9f1448c9b65ff6fa86f01077c065..b0dba662f43870b87778d36bf2161b0de6ecd8b4 100644 (file)
@@ -110,20 +110,20 @@ PeiInstallPeiMemory (
 }\r
 \r
 /**\r
+  The purpose of the service is to publish an interface that allows \r
+  PEIMs to allocate memory ranges that are managed by the PEI Foundation.\r
 \r
-  Memory allocation service on permanent memory,\r
-  not usable prior to the memory installation.\r
+  @param  PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param  MemoryType       The type of memory to allocate.\r
+  @param  Pages            The number of contiguous 4 KB pages to allocate.\r
+  @param  Memory           Pointer to a physical address. On output, the address is set to the base \r
+                           of the page range that was allocated.\r
 \r
-\r
-  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param MemoryType      Type of memory to allocate.\r
-  @param Pages           Number of pages to allocate.\r
-  @param Memory          Pointer of memory allocated.\r
-\r
-  @retval EFI_SUCCESS              The allocation was successful\r
-  @retval EFI_NOT_AVAILABLE_YET    Called with permanent memory not available\r
-  @retval EFI_OUT_OF_RESOURCES     There is not enough HOB heap to satisfy the requirement\r
-                                   to allocate the number of pages.\r
+  @retval EFI_SUCCESS           The memory range was successfully allocated.\r
+  @retval EFI_OUT_OF_RESOURCES  The pages could not be allocated.\r
+  @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode, \r
+                                EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,\r
+                                EfiACPIReclaimMemory, or EfiACPIMemoryNVS.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -141,6 +141,17 @@ PeiAllocatePages (
   EFI_PHYSICAL_ADDRESS                    *FreeMemoryBottom;\r
   UINTN                                   RemainingPages;\r
 \r
+  if ((MemoryType != EfiLoaderCode) &&\r
+      (MemoryType != EfiLoaderData) &&\r
+      (MemoryType != EfiRuntimeServicesCode) &&\r
+      (MemoryType != EfiRuntimeServicesData) &&\r
+      (MemoryType != EfiBootServicesCode) &&\r
+      (MemoryType != EfiBootServicesData) &&\r
+      (MemoryType != EfiACPIReclaimMemory) &&\r
+      (MemoryType != EfiACPIMemoryNVS)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
   Hob.Raw     = PrivateData->HobList.Raw;\r
   \r