summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-26 09:26:52 +0000
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-26 09:26:52 +0000
commit64ca68027bf23acc61f31e520b38b5c63ec36c45 (patch)
tree00ed300ca20c4f8d100905e3b3a30bcc0df13b97 /MdeModulePkg
parentded5aa23eb635dc9d4eb46ddee934201eb4fd6a7 (diff)
downloadedk2-64ca68027bf23acc61f31e520b38b5c63ec36c45.tar.gz
edk2-64ca68027bf23acc61f31e520b38b5c63ec36c45.tar.bz2
edk2-64ca68027bf23acc61f31e520b38b5c63ec36c45.zip
Add parameter checking for PEI service AllocatePages(), according to PI1.2 errata A.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10112 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Core/Pei/Memory/MemoryServices.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
index 7e1bb55242..b0dba662f4 100644
--- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
+++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c
@@ -110,20 +110,20 @@ PeiInstallPeiMemory (
}
/**
+ The purpose of the service is to publish an interface that allows
+ PEIMs to allocate memory ranges that are managed by the PEI Foundation.
- Memory allocation service on permanent memory,
- not usable prior to the memory installation.
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
+ @param MemoryType The type of memory to allocate.
+ @param Pages The number of contiguous 4 KB pages to allocate.
+ @param Memory Pointer to a physical address. On output, the address is set to the base
+ of the page range that was allocated.
-
- @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
- @param MemoryType Type of memory to allocate.
- @param Pages Number of pages to allocate.
- @param Memory Pointer of memory allocated.
-
- @retval EFI_SUCCESS The allocation was successful
- @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available
- @retval EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement
- to allocate the number of pages.
+ @retval EFI_SUCCESS The memory range was successfully allocated.
+ @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
+ @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,
+ EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,
+ EfiACPIReclaimMemory, or EfiACPIMemoryNVS.
**/
EFI_STATUS
@@ -141,6 +141,17 @@ PeiAllocatePages (
EFI_PHYSICAL_ADDRESS *FreeMemoryBottom;
UINTN RemainingPages;
+ if ((MemoryType != EfiLoaderCode) &&
+ (MemoryType != EfiLoaderData) &&
+ (MemoryType != EfiRuntimeServicesCode) &&
+ (MemoryType != EfiRuntimeServicesData) &&
+ (MemoryType != EfiBootServicesCode) &&
+ (MemoryType != EfiBootServicesData) &&
+ (MemoryType != EfiACPIReclaimMemory) &&
+ (MemoryType != EfiACPIMemoryNVS)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
Hob.Raw = PrivateData->HobList.Raw;