X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdePkg%2FLibrary%2FBaseExtractGuidedSectionLib%2FBaseExtractGuidedSectionLib.c;h=e6f479b829f68b603ecec35f0da21b798a2330cf;hb=2f88bd3a1296c522317f1c21377876de63de5be7;hp=b7059ec1093d6781c64a1bb65700f326900709e4;hpb=1436aea4d5707e672672a11bda72be2c63c936c3;p=mirror_edk2.git diff --git a/MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.c b/MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.c index b7059ec109..e6f479b829 100644 --- a/MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.c +++ b/MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.c @@ -13,14 +13,14 @@ #include #include -#define EXTRACT_HANDLER_INFO_SIGNATURE SIGNATURE_32 ('E', 'G', 'S', 'I') +#define EXTRACT_HANDLER_INFO_SIGNATURE SIGNATURE_32 ('E', 'G', 'S', 'I') typedef struct { - UINT32 Signature; - UINT32 NumberOfExtractHandler; - GUID *ExtractHandlerGuidTable; - EXTRACT_GUIDED_SECTION_DECODE_HANDLER *ExtractDecodeHandlerTable; - EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *ExtractGetInfoHandlerTable; + UINT32 Signature; + UINT32 NumberOfExtractHandler; + GUID *ExtractHandlerGuidTable; + EXTRACT_GUIDED_SECTION_DECODE_HANDLER *ExtractDecodeHandlerTable; + EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *ExtractGetInfoHandlerTable; } EXTRACT_GUIDED_SECTION_HANDLER_INFO; /** @@ -35,15 +35,15 @@ typedef struct { **/ RETURN_STATUS GetExtractGuidedSectionHandlerInfo ( - IN OUT EXTRACT_GUIDED_SECTION_HANDLER_INFO **InfoPointer + IN OUT EXTRACT_GUIDED_SECTION_HANDLER_INFO **InfoPointer ) { - EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; + EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; // // Set the available memory address to handler info. // - HandlerInfo = (EXTRACT_GUIDED_SECTION_HANDLER_INFO*)(VOID*)(UINTN) PcdGet64 (PcdGuidedExtractHandlerTableAddress); + HandlerInfo = (EXTRACT_GUIDED_SECTION_HANDLER_INFO *)(VOID *)(UINTN)PcdGet64 (PcdGuidedExtractHandlerTableAddress); if (HandlerInfo == NULL) { *InfoPointer = NULL; return EFI_OUT_OF_RESOURCES; @@ -75,17 +75,17 @@ GetExtractGuidedSectionHandlerInfo ( // // Init HandlerInfo structure // - HandlerInfo->NumberOfExtractHandler = 0; - HandlerInfo->ExtractHandlerGuidTable = (GUID *) (HandlerInfo + 1); - HandlerInfo->ExtractDecodeHandlerTable = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *) ( - (UINT8 *)HandlerInfo->ExtractHandlerGuidTable + - PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (GUID) - ); - HandlerInfo->ExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *) ( - (UINT8 *)HandlerInfo->ExtractDecodeHandlerTable + - PcdGet32 (PcdMaximumGuidedExtractHandler) * - sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER) - ); + HandlerInfo->NumberOfExtractHandler = 0; + HandlerInfo->ExtractHandlerGuidTable = (GUID *)(HandlerInfo + 1); + HandlerInfo->ExtractDecodeHandlerTable = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *)( + (UINT8 *)HandlerInfo->ExtractHandlerGuidTable + + PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (GUID) + ); + HandlerInfo->ExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *)( + (UINT8 *)HandlerInfo->ExtractDecodeHandlerTable + + PcdGet32 (PcdMaximumGuidedExtractHandler) * + sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER) + ); *InfoPointer = HandlerInfo; return RETURN_SUCCESS; } @@ -110,8 +110,8 @@ ExtractGuidedSectionGetGuidList ( OUT GUID **ExtractHandlerGuidTable ) { - RETURN_STATUS Status; - EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; + RETURN_STATUS Status; + EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; ASSERT (ExtractHandlerGuidTable != NULL); @@ -164,9 +164,9 @@ ExtractGuidedSectionRegisterHandlers ( IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER DecodeHandler ) { - UINT32 Index; - RETURN_STATUS Status; - EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; + UINT32 Index; + RETURN_STATUS Status; + EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; // // Check input parameter @@ -187,13 +187,13 @@ ExtractGuidedSectionRegisterHandlers ( // Search the match registered GetInfo handler for the input guided section. // ASSERT (HandlerInfo != NULL); - for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) { + for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index++) { if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionGuid)) { // // If the guided handler has been registered before, only update its handler. // - HandlerInfo->ExtractDecodeHandlerTable [Index] = DecodeHandler; - HandlerInfo->ExtractGetInfoHandlerTable [Index] = GetInfoHandler; + HandlerInfo->ExtractDecodeHandlerTable[Index] = DecodeHandler; + HandlerInfo->ExtractGetInfoHandlerTable[Index] = GetInfoHandler; return RETURN_SUCCESS; } } @@ -209,8 +209,8 @@ ExtractGuidedSectionRegisterHandlers ( // Register new Handler and guid value. // CopyGuid (HandlerInfo->ExtractHandlerGuidTable + HandlerInfo->NumberOfExtractHandler, SectionGuid); - HandlerInfo->ExtractDecodeHandlerTable [HandlerInfo->NumberOfExtractHandler] = DecodeHandler; - HandlerInfo->ExtractGetInfoHandlerTable [HandlerInfo->NumberOfExtractHandler++] = GetInfoHandler; + HandlerInfo->ExtractDecodeHandlerTable[HandlerInfo->NumberOfExtractHandler] = DecodeHandler; + HandlerInfo->ExtractGetInfoHandlerTable[HandlerInfo->NumberOfExtractHandler++] = GetInfoHandler; return RETURN_SUCCESS; } @@ -258,10 +258,10 @@ ExtractGuidedSectionGetInfo ( OUT UINT16 *SectionAttribute ) { - UINT32 Index; - RETURN_STATUS Status; - EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; - EFI_GUID *SectionDefinitionGuid; + UINT32 Index; + RETURN_STATUS Status; + EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; + EFI_GUID *SectionDefinitionGuid; // // Check input parameter @@ -280,26 +280,26 @@ ExtractGuidedSectionGetInfo ( } if (IS_SECTION2 (InputSection)) { - SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid); + SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid); } else { - SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid); + SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid); } // // Search the match registered GetInfo handler for the input guided section. // ASSERT (HandlerInfo != NULL); - for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) { + for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index++) { if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionDefinitionGuid)) { // // Call the match handler to get information for the input section data. // - return HandlerInfo->ExtractGetInfoHandlerTable [Index] ( - InputSection, - OutputBufferSize, - ScratchBufferSize, - SectionAttribute - ); + return HandlerInfo->ExtractGetInfoHandlerTable[Index]( + InputSection, + OutputBufferSize, + ScratchBufferSize, + SectionAttribute + ); } } @@ -353,10 +353,10 @@ ExtractGuidedSectionDecode ( OUT UINT32 *AuthenticationStatus ) { - UINT32 Index; - RETURN_STATUS Status; - EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; - EFI_GUID *SectionDefinitionGuid; + UINT32 Index; + RETURN_STATUS Status; + EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; + EFI_GUID *SectionDefinitionGuid; // // Check input parameter @@ -374,26 +374,26 @@ ExtractGuidedSectionDecode ( } if (IS_SECTION2 (InputSection)) { - SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid); + SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid); } else { - SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid); + SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid); } // // Search the match registered Extract handler for the input guided section. // ASSERT (HandlerInfo != NULL); - for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) { + for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index++) { if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionDefinitionGuid)) { // // Call the match handler to extract raw data for the input guided section. // - return HandlerInfo->ExtractDecodeHandlerTable [Index] ( - InputSection, - OutputBuffer, - ScratchBuffer, - AuthenticationStatus - ); + return HandlerInfo->ExtractDecodeHandlerTable[Index]( + InputSection, + OutputBuffer, + ScratchBuffer, + AuthenticationStatus + ); } } @@ -438,9 +438,9 @@ ExtractGuidedSectionGetHandlers ( OUT EXTRACT_GUIDED_SECTION_DECODE_HANDLER *DecodeHandler OPTIONAL ) { - UINT32 Index; - RETURN_STATUS Status; - EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; + UINT32 Index; + RETURN_STATUS Status; + EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo; // // Check input parameter @@ -459,20 +459,22 @@ ExtractGuidedSectionGetHandlers ( // Search the match registered GetInfo handler for the input guided section. // ASSERT (HandlerInfo != NULL); - for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) { + for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index++) { if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionGuid)) { - // // If the guided handler has been registered before, then return the registered handlers. // if (GetInfoHandler != NULL) { *GetInfoHandler = HandlerInfo->ExtractGetInfoHandlerTable[Index]; } + if (DecodeHandler != NULL) { *DecodeHandler = HandlerInfo->ExtractDecodeHandlerTable[Index]; } + return RETURN_SUCCESS; } } + return RETURN_NOT_FOUND; }