]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Apply ReallocatePool API in DxeExtractGuidedSectionLib when the allocated resource...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 11 Dec 2008 07:36:58 +0000 (07:36 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 11 Dec 2008 07:36:58 +0000 (07:36 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6994 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Protocol/Mtftp4.h
MdePkg/Include/Uefi/UefiSpec.h
MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf

index 15cfd98831e852c93b649043ba41a0ad6fa31fa1..c13851ef6c9670d34e460c589dabc4e7f3daca62 100644 (file)
@@ -526,7 +526,7 @@ struct _EFI_MTFTP4_TOKEN {
   ///\r
   UINT8                       *Filename;\r
   ///\r
-  /// Pointer to the ASCIIZ mode string. If NULL, ¡°octet¡± is used.\r
+  /// Pointer to the ASCIIZ mode string. If NULL, "octet" is used.\r
   ///\r
   UINT8                       *ModeStr;\r
   ///\r
index f68023051267d19947bc9bb7066ec146ddc44121..906bf68899db79c1cc3feb626824b64f84a8af19 100644 (file)
@@ -704,7 +704,7 @@ typedef struct {
   ///\r
   UINT32    Accuracy;\r
   ///\r
-  /// A TRUE indicates that a time set operation clears the device¡¯s\r
+  /// A TRUE indicates that a time set operation clears the device's\r
   /// time below the Resolution reporting level. A FALSE\r
   /// indicates that the state below the Resolution level of the\r
   /// device is not cleared when the time is set. Normal PC-AT CMOS\r
index 5f03a982cf77945fce60830059d6a9864578db15..58caa1ff805623d219f033e3a4f7de13f74ec63d 100644 (file)
 #include <PiDxe.h>\r
 \r
 #include <Library/DebugLib.h>\r
-#include <Library/PcdLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/ExtractGuidedSectionLib.h>\r
 \r
-GUID                 *mExtractHandlerGuidTable;\r
+#define EXTRACT_HANDLER_TABLE_SIZE   0x10\r
+\r
 UINT32               mNumberOfExtractHandler = 0;\r
+UINT32               mMaxNumberOfExtractHandler = 0;\r
 \r
-EXTRACT_GUIDED_SECTION_DECODE_HANDLER   *mExtractDecodeHandlerTable;\r
-EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *mExtractGetInfoHandlerTable;\r
+GUID                 *mExtractHandlerGuidTable = NULL;\r
+EXTRACT_GUIDED_SECTION_DECODE_HANDLER   *mExtractDecodeHandlerTable = NULL;\r
+EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *mExtractGetInfoHandlerTable = NULL;\r
 \r
 /**\r
-  Constructor allocates the global memory to store the registered guid and Handler list.\r
-\r
-  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
-  @param  SystemTable   A pointer to the EFI System Table.\r
+  Reallocates more global memory to store the registered guid and Handler list.\r
 \r
-  @retval  RETURN_SUCCESS            Allocate the global memory space to store guid and function tables.\r
+  @retval  RETURN_SUCCESS            Reallocate more global memory space to store guid and function tables.\r
   @retval  RETURN_OUT_OF_RESOURCES   No enough memory to allocated.\r
 **/\r
 RETURN_STATUS\r
 EFIAPI\r
-DxeExtractGuidedSectionLibConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
+ReallocateExtractHandlerTable (\r
   )\r
-{\r
+{ \r
   //\r
-  // Allocate global pool space to store the registered handler and its guid value.\r
+  // Reallocate memory for GuidTable\r
   //\r
-  mExtractHandlerGuidTable    = (GUID *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (GUID));\r
+  mExtractHandlerGuidTable = ReallocatePool (\r
+                               mMaxNumberOfExtractHandler * sizeof (GUID), \r
+                               (mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE) * sizeof (GUID), \r
+                               mExtractHandlerGuidTable\r
+                             );\r
+\r
   if (mExtractHandlerGuidTable == NULL) {\r
-    return RETURN_OUT_OF_RESOURCES;\r
+    goto Done;\r
   }\r
-  \r
-  mExtractDecodeHandlerTable  = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER));\r
+\r
+  //\r
+  // Reallocate memory for Decode handler Table\r
+  //\r
+  mExtractDecodeHandlerTable = ReallocatePool (\r
+                               mMaxNumberOfExtractHandler * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER), \r
+                               (mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE) * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER), \r
+                               mExtractDecodeHandlerTable\r
+                             );\r
+\r
   if (mExtractDecodeHandlerTable == NULL) {\r
-    FreePool (mExtractHandlerGuidTable);\r
-    return RETURN_OUT_OF_RESOURCES;\r
+    goto Done;\r
   }\r
 \r
-  mExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *) AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER));\r
+  //\r
+  // Reallocate memory for GetInfo handler Table\r
+  //\r
+  mExtractGetInfoHandlerTable = ReallocatePool (\r
+                               mMaxNumberOfExtractHandler * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER), \r
+                               (mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE) * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER), \r
+                               mExtractGetInfoHandlerTable\r
+                             );\r
+\r
   if (mExtractGetInfoHandlerTable == NULL) {\r
+    goto Done;\r
+  }\r
+  \r
+  //\r
+  // Increase max handler number\r
+  //\r
+  mMaxNumberOfExtractHandler = mMaxNumberOfExtractHandler + EXTRACT_HANDLER_TABLE_SIZE;\r
+  return RETURN_SUCCESS;\r
+\r
+Done:\r
+  if (mExtractHandlerGuidTable != NULL) {\r
     FreePool (mExtractHandlerGuidTable);\r
+  }\r
+  if (mExtractDecodeHandlerTable != NULL) {\r
     FreePool (mExtractDecodeHandlerTable);\r
-    return RETURN_OUT_OF_RESOURCES;\r
+  }\r
+  if (mExtractGetInfoHandlerTable != NULL) {\r
+    FreePool (mExtractGetInfoHandlerTable);\r
   }\r
   \r
-  return RETURN_SUCCESS;\r
+  return RETURN_OUT_OF_RESOURCES;\r
+}\r
+/**\r
+  Constructor allocates the global memory to store the registered guid and Handler list.\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval  RETURN_SUCCESS            Allocate the global memory space to store guid and function tables.\r
+  @retval  RETURN_OUT_OF_RESOURCES   No enough memory to allocated.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+DxeExtractGuidedSectionLibConstructor (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  return ReallocateExtractHandlerTable ();\r
 }\r
 \r
 /**\r
@@ -149,8 +199,10 @@ ExtractGuidedSectionRegisterHandlers (
   //\r
   // Check the global table is enough to contain new Handler.\r
   //\r
-  if (mNumberOfExtractHandler >= PcdGet32 (PcdMaximumGuidedExtractHandler)) {\r
-    return RETURN_OUT_OF_RESOURCES;\r
+  if (mNumberOfExtractHandler >= mMaxNumberOfExtractHandler) {\r
+    if (ReallocateExtractHandlerTable () != RETURN_SUCCESS) {\r
+      return RETURN_OUT_OF_RESOURCES;\r
+    }\r
   }\r
   \r
   //\r
index a03b413cdb409e65b5c24f7994554892ee0cef26..0c21a66ab10d517d499a0802c36ab715bbc631ca 100644 (file)
@@ -44,7 +44,3 @@
   DebugLib\r
   PcdLib\r
 \r
-[Pcd.common]\r
-  gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler \r
-\r
-\r