#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
+ Reallocates more 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_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
Registers the handlers specified by GetInfoHandler and DecodeHandler with the GUID specified by SectionGuid.\r
If the GUID value specified by SectionGuid has already been registered, then return RETURN_ALREADY_STARTED.\r
If there are not enough resources available to register the handlers then RETURN_OUT_OF_RESOURCES is returned.\r
+ \r
If SectionGuid is NULL, then ASSERT().\r
If GetInfoHandler is NULL, then ASSERT().\r
If DecodeHandler is NULL, then ASSERT().\r
allocated output buffer. \r
\r
@retval RETURN_SUCCESS The handlers were registered.\r
- @retval RETURN_ALREADY_STARTED Handlers have already been registered for the GUID specified by SectionGuid. \r
@retval RETURN_OUT_OF_RESOURCES There are not enough resources available to register the handlers.\r
\r
**/\r
//\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
of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()\r
is used to retrieve the OututBufferSize, ScratchSize, and Attributes values. The return status from the handler of\r
type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER is returned.\r
+ \r
If InputSection is NULL, then ASSERT().\r
If OutputBufferSize is NULL, then ASSERT().\r
If ScratchBufferSize is NULL, then ASSERT().\r
decode operation is returned in AuthenticationStatus. If the decoded buffer is identical to the data in InputSection,\r
then OutputBuffer is set to point at the data in InputSection. Otherwise, the decoded data will be placed in caller\r
allocated buffer specified by OutputBuffer. This function is responsible for computing the EFI_AUTH_STATUS_PLATFORM_OVERRIDE\r
- bit of in AuthenticationStatus. The return status from the handler of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER is returned. \r
+ bit of in AuthenticationStatus. The return status from the handler of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER is returned. \r
+ \r
If InputSection is NULL, then ASSERT().\r
If OutputBuffer is NULL, then ASSERT().\r
If ScratchBuffer is NULL and this decode operation requires a scratch buffer, then ASSERT().\r