From 5be1d046ef90b8b29f90b85d5bdff37e352df55f Mon Sep 17 00:00:00 2001 From: vanjeff Date: Thu, 9 May 2013 02:54:01 +0000 Subject: [PATCH] Sync patches r13208, r13473, r13563, r13638, r13642, r13647, r13650 and r13656 from main trunk. 1. MdeModulePkg PiSmmCore: Fix a bug in SmmLoadImage() in PiSmmCore that in-correct status codes may be returned. 2. Check whether has storage for date/time opcode, if it has storage, also generate the offset/width info for it. 3. Close the corresponding GUIDed section extraction protocol notify event in CloseSectionStream. 4. Fix incorrect sizeof () usage. 5. Add missing break and add comment to non-necessary break. 6. IntelFrameworkModulePkg/IdeBusDxe: Add error check on the return status of invoking AtaSoftReset(). 7. Enhance the code to make the code logic more clear. 8. Initialize the variable before use it. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/UDK2010.SR1@14330 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Bus/Pci/IdeBusDxe/IdeBus.c | 2 +- .../SectionExtractionDxe/SectionExtraction.c | 36 +++-- .../SectionExtraction/CoreSectionExtraction.c | 28 ++-- MdeModulePkg/Core/PiSmmCore/Dispatcher.c | 16 +- .../Console/TerminalDxe/TerminalConIn.c | 4 +- .../DevicePathDxe/DevicePathFromText.c | 3 +- .../Universal/HiiDatabaseDxe/ConfigRouting.c | 138 +++++++++++++++++- .../Universal/HiiDatabaseDxe/String.c | 3 +- .../Universal/SetupBrowserDxe/Setup.c | 4 +- MdeModulePkg/Universal/SetupBrowserDxe/Ui.c | 7 +- .../Library/BasePrintLib/PrintLibInternal.c | 3 + 11 files changed, 206 insertions(+), 38 deletions(-) diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c index 54c2ee1776..ab2ec8071a 100644 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c +++ b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c @@ -1475,7 +1475,7 @@ ClearInterrupt ( // Reset IDE device to force it de-assert interrupt pin // Note: this will reset all devices on this IDE channel // - AtaSoftReset (IdeDev); + Status = AtaSoftReset (IdeDev); if (EFI_ERROR (Status)) { return; } diff --git a/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c b/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c index 0c72490649..dfe3070268 100644 --- a/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c +++ b/IntelFrameworkModulePkg/Universal/SectionExtractionDxe/SectionExtraction.c @@ -76,6 +76,11 @@ typedef struct { // UINTN EncapsulatedStreamHandle; EFI_GUID *EncapsulationGuid; + // + // If the section REQUIRES an extraction protocol, register for RPN + // when the required GUIDed extraction protocol becomes available. + // + EFI_EVENT Event; } FRAMEWORK_SECTION_CHILD_NODE; #define FRAMEWORK_SECTION_STREAM_SIGNATURE SIGNATURE_32('S','X','S','S') @@ -101,7 +106,6 @@ typedef struct { FRAMEWORK_SECTION_CHILD_NODE *ChildNode; FRAMEWORK_SECTION_STREAM_NODE *ParentStream; VOID *Registration; - EFI_EVENT Event; } RPN_EVENT_CONTEXT; /** @@ -650,12 +654,13 @@ NotifyGuidedExtraction ( } // - // If above, the stream did not close successfully, it indicates it's - // alread been closed by someone, so just destroy the event and be done with + // If above, the stream did not close successfully, it indicates it's + // already been closed by someone, so just destroy the event and be done with // it. // gBS->CloseEvent (Event); + Context->ChildNode->Event = NULL; FreePool (Context); } @@ -684,14 +689,14 @@ CreateGuidedExtractionRpnEvent ( Context->ChildNode = ChildNode; Context->ParentStream = ParentStream; - Context->Event = CreateProtocolNotifyEvent ( - Context->ChildNode->EncapsulationGuid, - TPL_NOTIFY, - NotifyGuidedExtraction, - Context, - &Context->Registration, - FALSE - ); + Context->ChildNode->Event = CreateProtocolNotifyEvent ( + Context->ChildNode->EncapsulationGuid, + TPL_NOTIFY, + NotifyGuidedExtraction, + Context, + &Context->Registration, + FALSE + ); } /** @@ -743,7 +748,7 @@ CreateChildNode ( // // Allocate a new node // - *ChildNode = AllocatePool (sizeof (FRAMEWORK_SECTION_CHILD_NODE)); + *ChildNode = AllocateZeroPool (sizeof (FRAMEWORK_SECTION_CHILD_NODE)); Node = *ChildNode; if (Node == NULL) { return EFI_OUT_OF_RESOURCES; @@ -1092,6 +1097,7 @@ FindChildNode ( CurrentChildNode = CHILD_SECTION_NODE_FROM_LINK (GetFirstNode(&SourceStream->Children)); for (;;) { + ASSERT (CurrentChildNode != NULL); if (ChildIsType (SourceStream, CurrentChildNode, SearchType, SectionDefinitionGuid)) { // // The type matches, so check the instance count to see if it's the one we want @@ -1108,7 +1114,6 @@ FindChildNode ( } } - ASSERT (CurrentChildNode != NULL); if (CurrentChildNode->EncapsulatedStreamHandle != NULL_STREAM_HANDLE) { // // If the current node is an encapsulating node, recurse into it... @@ -1386,6 +1391,11 @@ FreeChildNode ( // CloseSectionStream (&mSectionExtraction, ChildNode->EncapsulatedStreamHandle); } + + if (ChildNode->Event != NULL) { + gBS->CloseEvent (ChildNode->Event); + } + // // Last, free the child node itself // diff --git a/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c b/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c index a0d9d6992d..ad3f58fa21 100644 --- a/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c +++ b/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c @@ -66,6 +66,11 @@ typedef struct { // UINTN EncapsulatedStreamHandle; EFI_GUID *EncapsulationGuid; + // + // If the section REQUIRES an extraction protocol, register for RPN + // when the required GUIDed extraction protocol becomes available. + // + EFI_EVENT Event; } CORE_SECTION_CHILD_NODE; #define CORE_SECTION_STREAM_SIGNATURE SIGNATURE_32('S','X','S','S') @@ -91,7 +96,6 @@ typedef struct { CORE_SECTION_CHILD_NODE *ChildNode; CORE_SECTION_STREAM_NODE *ParentStream; VOID *Registration; - EFI_EVENT Event; } RPN_EVENT_CONTEXT; @@ -604,6 +608,7 @@ NotifyGuidedExtraction ( // Close the event when done. // gBS->CloseEvent (Event); + Context->ChildNode->Event = NULL; FreePool (Context); } @@ -631,13 +636,13 @@ CreateGuidedExtractionRpnEvent ( Context->ChildNode = ChildNode; Context->ParentStream = ParentStream; - Context->Event = EfiCreateProtocolNotifyEvent ( - Context->ChildNode->EncapsulationGuid, - TPL_NOTIFY, - NotifyGuidedExtraction, - Context, - &Context->Registration - ); + Context->ChildNode->Event = EfiCreateProtocolNotifyEvent ( + Context->ChildNode->EncapsulationGuid, + TPL_NOTIFY, + NotifyGuidedExtraction, + Context, + &Context->Registration + ); } /** @@ -692,7 +697,7 @@ CreateChildNode ( // // Allocate a new node // - *ChildNode = AllocatePool (sizeof (CORE_SECTION_CHILD_NODE)); + *ChildNode = AllocateZeroPool (sizeof (CORE_SECTION_CHILD_NODE)); Node = *ChildNode; if (Node == NULL) { return EFI_OUT_OF_RESOURCES; @@ -1334,6 +1339,11 @@ FreeChildNode ( // CloseSectionStream (ChildNode->EncapsulatedStreamHandle); } + + if (ChildNode->Event != NULL) { + gBS->CloseEvent (ChildNode->Event); + } + // // Last, free the child node itself // diff --git a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c index 3b476f3794..b2e3d6a1e7 100644 --- a/MdeModulePkg/Core/PiSmmCore/Dispatcher.c +++ b/MdeModulePkg/Core/PiSmmCore/Dispatcher.c @@ -405,7 +405,7 @@ SmmLoadImage ( if (EFI_ERROR (Status)) { if (Buffer != NULL) { - Status = gBS->FreePool (Buffer); + gBS->FreePool (Buffer); } return Status; } @@ -453,7 +453,7 @@ SmmLoadImage ( Status = PeCoffLoaderGetImageInfo (&ImageContext); if (EFI_ERROR (Status)) { if (Buffer != NULL) { - Status = gBS->FreePool (Buffer); + gBS->FreePool (Buffer); } return Status; } @@ -489,7 +489,7 @@ SmmLoadImage ( ); if (EFI_ERROR (Status)) { if (Buffer != NULL) { - Status = gBS->FreePool (Buffer); + gBS->FreePool (Buffer); } return Status; } @@ -507,7 +507,7 @@ SmmLoadImage ( ); if (EFI_ERROR (Status)) { if (Buffer != NULL) { - Status = gBS->FreePool (Buffer); + gBS->FreePool (Buffer); } return Status; } @@ -526,7 +526,7 @@ SmmLoadImage ( Status = PeCoffLoaderLoadImage (&ImageContext); if (EFI_ERROR (Status)) { if (Buffer != NULL) { - Status = gBS->FreePool (Buffer); + gBS->FreePool (Buffer); } SmmFreePages (DstBuffer, PageCount); return Status; @@ -538,7 +538,7 @@ SmmLoadImage ( Status = PeCoffLoaderRelocateImage (&ImageContext); if (EFI_ERROR (Status)) { if (Buffer != NULL) { - Status = gBS->FreePool (Buffer); + gBS->FreePool (Buffer); } SmmFreePages (DstBuffer, PageCount); return Status; @@ -562,7 +562,7 @@ SmmLoadImage ( Status = gBS->AllocatePool (EfiBootServicesData, sizeof (EFI_LOADED_IMAGE_PROTOCOL), (VOID **)&DriverEntry->LoadedImage); if (EFI_ERROR (Status)) { if (Buffer != NULL) { - Status = gBS->FreePool (Buffer); + gBS->FreePool (Buffer); } SmmFreePages (DstBuffer, PageCount); return Status; @@ -583,7 +583,7 @@ SmmLoadImage ( Status = gBS->AllocatePool (EfiBootServicesData, GetDevicePathSize (FilePath), (VOID **)&DriverEntry->LoadedImage->FilePath); if (EFI_ERROR (Status)) { if (Buffer != NULL) { - Status = gBS->FreePool (Buffer); + gBS->FreePool (Buffer); } SmmFreePages (DstBuffer, PageCount); return Status; diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c index 547ef832f6..c30e3a589c 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c @@ -369,7 +369,7 @@ TerminalConInRegisterKeyNotify ( NewNotify->Signature = TERMINAL_CONSOLE_IN_EX_NOTIFY_SIGNATURE; NewNotify->KeyNotificationFn = KeyNotificationFunction; NewNotify->NotifyHandle = (EFI_HANDLE) NewNotify; - CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData)); + CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA)); InsertTailList (&TerminalDevice->NotifyList, &NewNotify->NotifyEntry); *NotifyHandle = NewNotify->NotifyHandle; @@ -1458,6 +1458,7 @@ UnicodeToEfiKey ( if (TerminalDevice->TerminalType == PCANSITYPE) { Key.ScanCode = SCAN_F10; } + break; case '?': if (TerminalDevice->TerminalType == VT100TYPE) { Key.ScanCode = SCAN_PAGE_UP; @@ -1472,6 +1473,7 @@ UnicodeToEfiKey ( if (TerminalDevice->TerminalType == PCANSITYPE) { Key.ScanCode = SCAN_F9; } + break; case '/': if (TerminalDevice->TerminalType == VT100TYPE) { Key.ScanCode = SCAN_PAGE_DOWN; diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c index 11f5c159df..d94e149e58 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c @@ -1,7 +1,7 @@ /** @file DevicePathFromText protocol as defined in the UEFI 2.0 specification. -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
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 @@ -2006,6 +2006,7 @@ DevPathFromTextUart ( case L'S': Uart->Parity = 5; + break; default: Uart->Parity = 0xff; diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 6f8d84c252..1cb754bde0 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -1,7 +1,7 @@ /** @file Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL. -Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
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 @@ -997,6 +997,8 @@ ParseIfrData ( EFI_IFR_CHECKBOX *IfrCheckBox; EFI_IFR_PASSWORD *IfrPassword; EFI_IFR_STRING *IfrString; + EFI_IFR_DATE *IfrDate; + EFI_IFR_TIME *IfrTime; IFR_DEFAULT_DATA DefaultData; IFR_DEFAULT_DATA *DefaultDataPtr; IFR_BLOCK_DATA *BlockData; @@ -1505,6 +1507,140 @@ ParseIfrData ( InsertDefaultValue (BlockData, &DefaultData); break; + case EFI_IFR_DATE_OP: + // + // offset by question header + // width MaxSize * sizeof (CHAR16) + // no default value, only block array + // + + // + // Date question is not in IFR Form. This IFR form is not valid. + // + if (VarStorageData->Size == 0) { + Status = EFI_INVALID_PARAMETER; + goto Done; + } + // + // Check whether this question is for the requested varstore. + // + IfrDate = (EFI_IFR_DATE *) IfrOpHdr; + if (IfrDate->Question.VarStoreId != VarStorageData->VarStoreId) { + break; + } + + // + // Get Offset/Width by Question header and OneOf Flags + // + VarOffset = IfrDate->Question.VarStoreInfo.VarOffset; + VarWidth = (UINT16) sizeof (EFI_HII_DATE); + + // + // Check whether this question is in requested block array. + // + if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth)) { + // + // This question is not in the requested array. Skip it. + // + break; + } + + // + // Check this var question is in the var storage + // + if ((VarOffset + VarWidth) > VarStorageData->Size) { + Status = EFI_INVALID_PARAMETER; + goto Done; + } + + // + // Set Block Data + // + BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); + if (BlockData == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + BlockData->Offset = VarOffset; + BlockData->Width = VarWidth; + BlockData->QuestionId = IfrDate->Question.QuestionId; + BlockData->OpCode = IfrOpHdr->OpCode; + BlockData->Scope = IfrOpHdr->Scope; + InitializeListHead (&BlockData->DefaultValueEntry); + + // + // Add Block Data into VarStorageData BlockEntry + // + InsertBlockData (&VarStorageData->BlockEntry, &BlockData); + break; + + case EFI_IFR_TIME_OP: + // + // offset by question header + // width MaxSize * sizeof (CHAR16) + // no default value, only block array + // + + // + // Time question is not in IFR Form. This IFR form is not valid. + // + if (VarStorageData->Size == 0) { + Status = EFI_INVALID_PARAMETER; + goto Done; + } + // + // Check whether this question is for the requested varstore. + // + IfrTime = (EFI_IFR_TIME *) IfrOpHdr; + if (IfrTime->Question.VarStoreId != VarStorageData->VarStoreId) { + break; + } + + // + // Get Offset/Width by Question header and OneOf Flags + // + VarOffset = IfrTime->Question.VarStoreInfo.VarOffset; + VarWidth = (UINT16) sizeof (EFI_HII_TIME); + + // + // Check whether this question is in requested block array. + // + if (!BlockArrayCheck (RequestBlockArray, VarOffset, VarWidth)) { + // + // This question is not in the requested array. Skip it. + // + break; + } + + // + // Check this var question is in the var storage + // + if ((VarOffset + VarWidth) > VarStorageData->Size) { + Status = EFI_INVALID_PARAMETER; + goto Done; + } + + // + // Set Block Data + // + BlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA)); + if (BlockData == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + BlockData->Offset = VarOffset; + BlockData->Width = VarWidth; + BlockData->QuestionId = IfrTime->Question.QuestionId; + BlockData->OpCode = IfrOpHdr->OpCode; + BlockData->Scope = IfrOpHdr->Scope; + InitializeListHead (&BlockData->DefaultValueEntry); + + // + // Add Block Data into VarStorageData BlockEntry + // + InsertBlockData (&VarStorageData->BlockEntry, &BlockData); + break; + case EFI_IFR_STRING_OP: // // offset by question header diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c index a76e5b64c9..c55305886f 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c @@ -2,7 +2,7 @@ Implementation for EFI_HII_STRING_PROTOCOL. -Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
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 @@ -899,6 +899,7 @@ SetStringWorker ( EFI_STRING_ID StartStringId; StartStringId = 0; + StringSize = 0; ASSERT (Private != NULL && StringPackage != NULL && String != NULL); ASSERT (Private->Signature == HII_DATABASE_PRIVATE_DATA_SIGNATURE); // diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 1317b8f112..0e743a6bb1 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -750,7 +750,7 @@ GetToken ( String = HiiGetString (HiiHandle, Token, NULL); if (String == NULL) { - String = AllocateCopyPool (sizeof (mUnknownString), mUnknownString); + String = AllocateCopyPool (StrSize (mUnknownString), mUnknownString); ASSERT (String != NULL); } return (CHAR16 *) String; @@ -3262,7 +3262,7 @@ ExtractDefault ( // // Initilize Questions' Value // - LoadFormSetConfig (NULL, LocalFormSet); + Status = LoadFormSetConfig (NULL, LocalFormSet); if (EFI_ERROR (Status)) { DestroyFormSet (LocalFormSet); continue; diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c index f302b7caa8..1688d546ca 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c @@ -767,7 +767,9 @@ UiAddMenuOption ( // MenuOption->GrayOut = TRUE; } - + // + // break skipped on purpose + // default: MenuOption->IsQuestion = FALSE; break; @@ -955,6 +957,9 @@ CreateDialog ( TempString[Index - 1] = CHAR_NULL; StrCpy (StringBuffer, TempString); } + // + // break skipped on purpose + // default: // diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c index 8a0cfa6e20..34e9d12767 100644 --- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c +++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c @@ -517,6 +517,9 @@ BasePrintLibSPrintMarker ( if (sizeof (VOID *) > 4) { Flags |= LONG_TYPE; } + // + // break skipped on purpose + // case 'X': Flags |= PREFIX_ZERO; //