summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/PeiMemoryAllocationLib
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2015-05-11 03:12:51 +0000
committerlzeng14 <lzeng14@Edk2>2015-05-11 03:12:51 +0000
commit34363594e3373601d41a5a5fcefefe64283a88f9 (patch)
tree24abdbb297cc71f8c9d2c53bf58261d6aac7eaf2 /MdePkg/Library/PeiMemoryAllocationLib
parentab6fb25a1f33f39b30ee10af03c50014221c0661 (diff)
downloadedk2-34363594e3373601d41a5a5fcefefe64283a88f9.tar.gz
edk2-34363594e3373601d41a5a5fcefefe64283a88f9.tar.bz2
edk2-34363594e3373601d41a5a5fcefefe64283a88f9.zip
MdePkg: Update PeiMemoryAllocationLib to allocate EfiReservedMemoryType memory directly.
The old implementation was to allocate EfiBootServicesData memory first, and then update the MemoryType of memory allocation hob to EfiReservedMemoryType. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17395 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/PeiMemoryAllocationLib')
-rw-r--r--MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c31
1 files changed, 2 insertions, 29 deletions
diff --git a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
index afc3909612..a6cce6c235 100644
--- a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
+++ b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
@@ -2,7 +2,7 @@
Support routines for memory allocation routines
based on PeiService for PEI phase drivers.
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -45,42 +45,15 @@ InternalAllocatePages (
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS Memory;
- EFI_MEMORY_TYPE RequestType;
- EFI_PEI_HOB_POINTERS Hob;
if (Pages == 0) {
return NULL;
}
- RequestType = MemoryType;
- if (MemoryType == EfiReservedMemoryType) {
- //
- // PEI AllocatePages() doesn't support EfiReservedMemoryType.
- // Change RequestType to EfiBootServicesData for memory allocation.
- //
- RequestType = EfiBootServicesData;
- }
-
- Status = PeiServicesAllocatePages (RequestType, Pages, &Memory);
+ Status = PeiServicesAllocatePages (MemoryType, Pages, &Memory);
if (EFI_ERROR (Status)) {
return NULL;
}
-
- if (MemoryType == EfiReservedMemoryType) {
- //
- // Memory type needs to be updated to EfiReservedMemoryType. Per PI spec Volume 1,
- // PEI AllocatePages() will automate the creation of the Memory Allocation HOB types.
- // Search Memory Allocation HOB and find the matched memory region,
- // then change its memory type to EfiReservedMemoryType.
- //
- Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
- while (Hob.Raw != NULL && Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress != Memory) {
- Hob.Raw = GET_NEXT_HOB (Hob);
- Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
- }
- ASSERT (Hob.Raw != NULL);
- Hob.MemoryAllocation->AllocDescriptor.MemoryType = EfiReservedMemoryType;
- }
return (VOID *) (UINTN) Memory;
}