summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/DxeExtractGuidedSectionLib
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2008-12-11 07:36:58 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2008-12-11 07:36:58 +0000
commitde2314f85cb6bf138b39ec020d3d1f11b6069470 (patch)
treea501fd6003f4bc594fedf46211da6c0f25072fc4 /MdePkg/Library/DxeExtractGuidedSectionLib
parent8ef155106f6f10f5be50153b239df3e5422cc770 (diff)
downloadedk2-de2314f85cb6bf138b39ec020d3d1f11b6069470.tar.gz
edk2-de2314f85cb6bf138b39ec020d3d1f11b6069470.tar.bz2
edk2-de2314f85cb6bf138b39ec020d3d1f11b6069470.zip
Apply ReallocatePool API in DxeExtractGuidedSectionLib when the allocated resource is used out. And remove PCD.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6994 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/DxeExtractGuidedSectionLib')
-rw-r--r--MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c102
-rw-r--r--MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf4
2 files changed, 77 insertions, 29 deletions
diff --git a/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c b/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
index 5f03a982cf..58caa1ff80 100644
--- a/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
+++ b/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
@@ -15,55 +15,105 @@
#include <PiDxe.h>
#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/ExtractGuidedSectionLib.h>
-GUID *mExtractHandlerGuidTable;
+#define EXTRACT_HANDLER_TABLE_SIZE 0x10
+
UINT32 mNumberOfExtractHandler = 0;
+UINT32 mMaxNumberOfExtractHandler = 0;
-EXTRACT_GUIDED_SECTION_DECODE_HANDLER *mExtractDecodeHandlerTable;
-EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *mExtractGetInfoHandlerTable;
+GUID *mExtractHandlerGuidTable = NULL;
+EXTRACT_GUIDED_SECTION_DECODE_HANDLER *mExtractDecodeHandlerTable = NULL;
+EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *mExtractGetInfoHandlerTable = NULL;
/**
- Constructor allocates the global memory to store the registered guid and Handler list.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
+ Reallocates more global memory to store the registered guid and Handler list.
- @retval RETURN_SUCCESS Allocate the global memory space to store guid and function tables.
+ @retval RETURN_SUCCESS Reallocate more global memory space to store guid and function tables.
@retval RETURN_OUT_OF_RESOURCES No enough memory to allocated.
**/
RETURN_STATUS
EFIAPI
-DxeExtractGuidedSectionLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ReallocateExtractHandlerTable (
)
-{
+{
//
- // Allocate global pool space to store the registered handler and its guid value.
+ // Reallocate memory for GuidTable
//
- mExtractHandlerGuidTable = (GUID *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (GUID));
+ mExtractHandlerGuidTable = ReallocatePool (
+ mMaxNumberOfExtractHandler * sizeof (GUID),
+ (mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE) * sizeof (GUID),
+ mExtractHandlerGuidTable
+ );
+
if (mExtractHandlerGuidTable == NULL) {
- return RETURN_OUT_OF_RESOURCES;
+ goto Done;
}
-
- mExtractDecodeHandlerTable = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER));
+
+ //
+ // Reallocate memory for Decode handler Table
+ //
+ mExtractDecodeHandlerTable = ReallocatePool (
+ mMaxNumberOfExtractHandler * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER),
+ (mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE) * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER),
+ mExtractDecodeHandlerTable
+ );
+
if (mExtractDecodeHandlerTable == NULL) {
- FreePool (mExtractHandlerGuidTable);
- return RETURN_OUT_OF_RESOURCES;
+ goto Done;
}
- mExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER));
+ //
+ // Reallocate memory for GetInfo handler Table
+ //
+ mExtractGetInfoHandlerTable = ReallocatePool (
+ mMaxNumberOfExtractHandler * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER),
+ (mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE) * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER),
+ mExtractGetInfoHandlerTable
+ );
+
if (mExtractGetInfoHandlerTable == NULL) {
+ goto Done;
+ }
+
+ //
+ // Increase max handler number
+ //
+ mMaxNumberOfExtractHandler = mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE;
+ return RETURN_SUCCESS;
+
+Done:
+ if (mExtractHandlerGuidTable != NULL) {
FreePool (mExtractHandlerGuidTable);
+ }
+ if (mExtractDecodeHandlerTable != NULL) {
FreePool (mExtractDecodeHandlerTable);
- return RETURN_OUT_OF_RESOURCES;
+ }
+ if (mExtractGetInfoHandlerTable != NULL) {
+ FreePool (mExtractGetInfoHandlerTable);
}
- return RETURN_SUCCESS;
+ return RETURN_OUT_OF_RESOURCES;
+}
+/**
+ Constructor allocates the global memory to store the registered guid and Handler list.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval RETURN_SUCCESS Allocate the global memory space to store guid and function tables.
+ @retval RETURN_OUT_OF_RESOURCES No enough memory to allocated.
+**/
+RETURN_STATUS
+EFIAPI
+DxeExtractGuidedSectionLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return ReallocateExtractHandlerTable ();
}
/**
@@ -149,8 +199,10 @@ ExtractGuidedSectionRegisterHandlers (
//
// Check the global table is enough to contain new Handler.
//
- if (mNumberOfExtractHandler >= PcdGet32 (PcdMaximumGuidedExtractHandler)) {
- return RETURN_OUT_OF_RESOURCES;
+ if (mNumberOfExtractHandler >= mMaxNumberOfExtractHandler) {
+ if (ReallocateExtractHandlerTable () != RETURN_SUCCESS) {
+ return RETURN_OUT_OF_RESOURCES;
+ }
}
//
diff --git a/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf b/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
index a03b413cdb..0c21a66ab1 100644
--- a/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
+++ b/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
@@ -44,7 +44,3 @@
DebugLib
PcdLib
-[Pcd.common]
- gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler
-
-