summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-01 10:53:51 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-01 10:53:51 +0000
commite889946d3a6d3a6574b2fa80eee19a6cce18624b (patch)
treef09734bb3907331f609a687c9ec74f444cac5e35
parent5b490e76a70a0da71c9f8ec6c81d60b94eb7527c (diff)
downloadedk2-platforms-e889946d3a6d3a6574b2fa80eee19a6cce18624b.tar.xz
EmbeddedPkg: Introduce PrePiMemoryAllocationLib (2)
Forgot the new files ... git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11944 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c (renamed from EmbeddedPkg/Library/PrePiLib/Memory.c)40
-rw-r--r--EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf39
2 files changed, 75 insertions, 4 deletions
diff --git a/EmbeddedPkg/Library/PrePiLib/Memory.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
index e6a649f149..7cfc28e1e7 100644
--- a/EmbeddedPkg/Library/PrePiLib/Memory.c
+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
@@ -13,7 +13,11 @@
**/
-#include <PrePi.h>
+#include <PiPei.h>
+
+#include <Library/BaseLib.h>
+#include <Library/PrePiLib.h>
+#include <Library/DebugLib.h>
@@ -30,7 +34,7 @@
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
-VOID *
+VOID *
EFIAPI
AllocatePages (
IN UINTN Pages
@@ -61,7 +65,15 @@ AllocatePages (
// This routine used to create a memory allocation HOB a la PEI, but that's not
// necessary for us.
-
+
+ //
+ // Create a memory allocation HOB.
+ //
+ BuildMemoryAllocationHob (
+ Hob.HandoffInformationTable->EfiFreeMemoryTop,
+ Pages * EFI_PAGE_SIZE,
+ EfiBootServicesData
+ );
return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;
}
}
@@ -112,7 +124,7 @@ AllocateAlignedPages (
if (Alignment == 0) {
AlignmentMask = Alignment;
} else {
- AlignmentMask = Alignment - 1;
+ AlignmentMask = Alignment - 1;
}
return (VOID *) (UINTN) (((UINTN) Memory + AlignmentMask) & ~AlignmentMask);
}
@@ -156,5 +168,25 @@ AllocatePool (
}
}
+/**
+ Frees a buffer that was previously allocated with one of the pool allocation functions in the
+ Memory Allocation Library.
+
+ Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
+ pool allocation services of the Memory Allocation Library. If it is not possible to free pool
+ resources, then this function will perform no actions.
+ If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
+ then ASSERT().
+ @param Buffer Pointer to the buffer to free.
+
+**/
+VOID
+EFIAPI
+FreePool (
+ IN VOID *Buffer
+ )
+{
+ // Not implemented yet
+}
diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
new file mode 100644
index 0000000000..2addc5a5a8
--- /dev/null
+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
@@ -0,0 +1,39 @@
+#/** @file
+#
+# Copyright (c) 2011, ARM Ltd. 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
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PrePiMemoryAllocationLib
+ FILE_GUID = 4f14c900-51a9-11e0-afbf-0002a5d5c51b
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = MemoryAllocationLib
+
+
+#
+# VALID_ARCHITECTURES = ARM
+#
+
+[Sources]
+ MemoryAllocationLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ EmbeddedPkg/EmbeddedPkg.dec
+
+[LibraryClasses]
+ DebugLib
+ BaseMemoryLib
+ PrePiLib
+ #PeiServicesLib
+