From: vanjeff Date: Thu, 29 Mar 2007 06:58:38 +0000 (+0000) Subject: 1. Use MemoryAllocationLib to replace boot services memory services functions in... X-Git-Tag: edk2-stable201903~23384 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=c8dd259d6174c01569f2a6da7243d74d727b2678 1. Use MemoryAllocationLib to replace boot services memory services functions in EdkModulePkg. 2. Added NULL pointer check before calling FreePool () to fix bugs when free memory. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2513 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/EdkModulePkg/Universal/ConPlatform/Dxe/ConPlatform.c b/EdkModulePkg/Universal/ConPlatform/Dxe/ConPlatform.c index 9e8dbbee7b..15e7693d1d 100644 --- a/EdkModulePkg/Universal/ConPlatform/Dxe/ConPlatform.c +++ b/EdkModulePkg/Universal/ConPlatform/Dxe/ConPlatform.c @@ -1,18 +1,18 @@ /*++ -Copyright (c) 2006, 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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2007, 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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: ConPlatform.c - + Abstract: --*/ @@ -47,7 +47,7 @@ ConPlatformTextInDriverBindingSupported ( /*++ Routine Description: - Supported + Supported Arguments: (Standard DriverBinding Protocol Supported() function) @@ -76,7 +76,7 @@ ConPlatformTextOutDriverBindingSupported ( /*++ Routine Description: - Supported + Supported Arguments: (Standard DriverBinding Protocol Supported() function) @@ -105,7 +105,7 @@ ConPlatformDriverBindingSupported ( /*++ Routine Description: - Supported + Supported Arguments: (Standard DriverBinding Protocol Supported() function) @@ -551,7 +551,7 @@ Returns: Caller is repsoncible freeing the buffer. NULL - Variable was not read - + --*/ { EFI_STATUS Status; @@ -576,8 +576,8 @@ Returns: // // Allocate the buffer to return // - Status = gBS->AllocatePool (EfiBootServicesData, BufferSize, &Buffer); - if (EFI_ERROR (Status)) { + Buffer = AllocatePool (BufferSize); + if (Buffer == NULL) { return NULL; } // @@ -591,7 +591,7 @@ Returns: Buffer ); if (EFI_ERROR (Status)) { - gBS->FreePool (Buffer); + FreePool (Buffer); Buffer = NULL; } } @@ -616,18 +616,18 @@ Arguments: Multi - A pointer to a multi-instance device path data structure. Single - A pointer to a single-instance device path data structure. - + NewDevicePath - If Delete is TRUE, this parameter must not be null, and it - points to the remaining device path data structure. + points to the remaining device path data structure. (remaining device path = Multi - Single.) - + Delete - If TRUE, means removing Single from Multi. - If FALSE, the routine just check whether Single matches + If FALSE, the routine just check whether Single matches with any instance in Multi. Returns: - The function returns EFI_SUCCESS if the Single is contained within Multi. + The function returns EFI_SUCCESS if the Single is contained within Multi. Otherwise, EFI_NOT_FOUND is returned. --*/ @@ -658,7 +658,7 @@ Returns: while (DevicePathInst) { if (CompareMem (Single, DevicePathInst, Size) == 0) { if (!Delete) { - gBS->FreePool (DevicePathInst); + FreePool (DevicePathInst); return EFI_SUCCESS; } } else { @@ -667,12 +667,14 @@ Returns: TempDevicePath1, DevicePathInst ); - gBS->FreePool (TempDevicePath1); + if (TempDevicePath1 != NULL) { + FreePool (TempDevicePath1); + } TempDevicePath1 = TempDevicePath2; } } - gBS->FreePool (DevicePathInst); + FreePool (DevicePathInst); DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size); } @@ -693,7 +695,7 @@ ConPlatformUpdateDeviceVariable ( /*++ Routine Description: - + Arguments: @@ -730,7 +732,9 @@ Returns: // // The device path is already in the variable // - gBS->FreePool (VariableDevicePath); + if (VariableDevicePath != NULL) { + FreePool (VariableDevicePath); + } return Status; } @@ -760,7 +764,9 @@ Returns: ); } - gBS->FreePool (VariableDevicePath); + if (VariableDevicePath != NULL) { + FreePool (VariableDevicePath); + } if (EFI_ERROR (Status)) { return Status; @@ -774,7 +780,7 @@ Returns: NewVariableDevicePath ); - gBS->FreePool (NewVariableDevicePath); + FreePool (NewVariableDevicePath); return Status; } diff --git a/EdkModulePkg/Universal/ConPlatform/Dxe/ConPlatform.msa b/EdkModulePkg/Universal/ConPlatform/Dxe/ConPlatform.msa index e6fe04f280..c00a95ce92 100644 --- a/EdkModulePkg/Universal/ConPlatform/Dxe/ConPlatform.msa +++ b/EdkModulePkg/Universal/ConPlatform/Dxe/ConPlatform.msa @@ -46,6 +46,9 @@ DevicePathLib + + MemoryAllocationLib + ConPlatform.c diff --git a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Boolean.c b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Boolean.c index d3f77e09f5..138725d7be 100644 --- a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Boolean.c +++ b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Boolean.c @@ -1,13 +1,13 @@ /*++ -Copyright (c) 2006, 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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2007, 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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: @@ -49,7 +49,7 @@ Arguments: Returns: - NONE + NONE --*/ { @@ -76,7 +76,7 @@ Returns: // // Free The Old Stack // - gBS->FreePool (mBooleanEvaluationStack); + FreePool (mBooleanEvaluationStack); } mBooleanEvaluationStack = NewStack; @@ -96,11 +96,11 @@ Routine Description: Arguments: - NONE + NONE Returns: - NONE + NONE --*/ { @@ -201,7 +201,7 @@ GrowBooleanExpression ( // // Free The Old buffer // - gBS->FreePool (*BooleanExpression); + FreePool (*BooleanExpression); } else { // // Copy data into new buffer @@ -484,7 +484,7 @@ Returns: Width = (*PIterator)->Width; - // + // // Because INVALID_OFFSET_VALUE - 1 is reserved for TRUE or FALSE, omit them. // if ((*PIterator)->QuestionId1 != INVALID_OFFSET_VALUE && @@ -498,7 +498,7 @@ Returns: MapValue = (UINT8) *MapBuffer; } - gBS->FreePool (MapBuffer); + FreePool (MapBuffer); } if (MapBuffer2 != NULL) { @@ -508,16 +508,16 @@ Returns: MapValue2 = (UINT8) *MapBuffer2; } - gBS->FreePool (MapBuffer2); + FreePool (MapBuffer2); } } switch ((*PIterator)->Operand) { case EFI_IFR_EQ_VAR_VAL_OP: UnicodeValueToString ( - VariableName, - FALSE, - (UINTN) (*PIterator)->QuestionId1, + VariableName, + FALSE, + (UINTN) (*PIterator)->QuestionId1, (sizeof (VariableName) / sizeof (VariableName[0])) - 1 ); @@ -727,7 +727,7 @@ Returns: return Operator; } - // + // // Because INVALID_OFFSET_VALUE - 1 is reserved for TRUE or FALSE, omit them. // if (Iterator->QuestionId1 != INVALID_OFFSET_VALUE && @@ -741,7 +741,7 @@ Returns: MapValue = (UINT8) *MapBuffer; } - gBS->FreePool (MapBuffer); + FreePool (MapBuffer); } if (MapBuffer2 != NULL) { @@ -751,7 +751,7 @@ Returns: MapValue2 = (UINT8) *MapBuffer2; } - gBS->FreePool (MapBuffer2); + FreePool (MapBuffer2); } } @@ -814,9 +814,9 @@ Returns: } UnicodeValueToString ( - VariableName, - FALSE, - (UINTN) Iterator->QuestionId1, + VariableName, + FALSE, + (UINTN) Iterator->QuestionId1, (sizeof (VariableName) / sizeof (VariableName[0])) - 1 ); @@ -913,7 +913,7 @@ Returns: MapValue = (UINT8) *MapBuffer; } - gBS->FreePool (MapBuffer); + FreePool (MapBuffer); } if (MapBuffer2 != NULL) { @@ -923,7 +923,7 @@ Returns: MapValue2 = (UINT8) *MapBuffer2; } - gBS->FreePool (MapBuffer2); + FreePool (MapBuffer2); } } @@ -947,9 +947,9 @@ Returns: // case EFI_IFR_EQ_VAR_VAL_OP: UnicodeValueToString ( - VariableName, - FALSE, - (UINTN) Iterator->QuestionId1, + VariableName, + FALSE, + (UINTN) Iterator->QuestionId1, (sizeof (VariableName) / sizeof (VariableName[0])) - 1 ); @@ -1049,7 +1049,7 @@ Returns: MapValue = (UINT8) *MapBuffer; } - gBS->FreePool (MapBuffer); + FreePool (MapBuffer); } if (MapBuffer2 != NULL) { @@ -1059,7 +1059,7 @@ Returns: MapValue2 = (UINT8) *MapBuffer2; } - gBS->FreePool (MapBuffer2); + FreePool (MapBuffer2); } } @@ -1083,9 +1083,9 @@ Returns: // case EFI_IFR_EQ_VAR_VAL_OP: UnicodeValueToString ( - VariableName, - FALSE, - (UINTN) Iterator->QuestionId1, + VariableName, + FALSE, + (UINTN) Iterator->QuestionId1, (sizeof (VariableName) / sizeof (VariableName[0])) - 1 ); @@ -1205,7 +1205,7 @@ Returns: MapValue = (UINT8) *MapBuffer; } - gBS->FreePool (MapBuffer); + FreePool (MapBuffer); } if (MapBuffer2 != NULL) { @@ -1215,7 +1215,7 @@ Returns: MapValue2 = (UINT8) *MapBuffer2; } - gBS->FreePool (MapBuffer2); + FreePool (MapBuffer2); } } @@ -1231,9 +1231,9 @@ Returns: // case EFI_IFR_EQ_VAR_VAL_OP: UnicodeValueToString ( - VariableName, - FALSE, - (UINTN) Iterator->QuestionId1, + VariableName, + FALSE, + (UINTN) Iterator->QuestionId1, (sizeof (VariableName) / sizeof (VariableName[0])) - 1 ); @@ -1295,7 +1295,7 @@ Returns: PushBool (&StackPtr, Operator); } break; - + case EFI_IFR_TRUE_OP: // // To check whether Ifr is legacy. Once every boolean expression. diff --git a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/InputHandler.c b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/InputHandler.c index 332898f8ad..85e1a0cf98 100644 --- a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/InputHandler.c +++ b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/InputHandler.c @@ -14,7 +14,7 @@ Module Name: InputHandler.C Abstract: - + Implementation for handling user input from the User Interface Revision History @@ -86,7 +86,7 @@ ReadString( // CreatePopUp (ScreenSize, 4, &NullCharacter, PromptForDataString, Space, &NullCharacter); - gBS->FreePool (PromptForDataString); + FreePool (PromptForDataString); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_BLACK, EFI_LIGHTGRAY)); @@ -107,8 +107,8 @@ ReadString( break; case SCAN_ESC: - gBS->FreePool (TempString); - gBS->FreePool (BufferedString); + FreePool (TempString); + FreePool (BufferedString); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->EnableCursor (gST->ConOut, CursorVisible); return EFI_DEVICE_ERROR; @@ -122,8 +122,8 @@ ReadString( case CHAR_CARRIAGE_RETURN: if (GetStringWidth (StringPtr) >= MenuOption->ThisTag->Minimum) { SelectionComplete = TRUE; - gBS->FreePool (TempString); - gBS->FreePool (BufferedString); + FreePool (TempString); + FreePool (BufferedString); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->EnableCursor (gST->ConOut, CursorVisible); return EFI_SUCCESS; @@ -137,8 +137,8 @@ ReadString( do { Status = WaitForKeyStroke (&Key); } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN); - gBS->FreePool (TempString); - gBS->FreePool (BufferedString); + FreePool (TempString); + FreePool (BufferedString); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->EnableCursor (gST->ConOut, CursorVisible); return EFI_DEVICE_ERROR; @@ -309,7 +309,7 @@ Error: WidthOfString = GetStringWidth (Packet->String); ScreenSize = EFI_MAX(WidthOfString, GetStringWidth (gPressEnter)) / 2; CreatePopUp (ScreenSize, 4, &NullCharacter, Packet->String, gPressEnter, &NullCharacter); - gBS->FreePool (Packet); + FreePool (Packet); do { Status = WaitForKeyStroke (&Key); @@ -422,7 +422,7 @@ Error: WidthOfString = GetStringWidth (Packet->String); ScreenSize = EFI_MAX (WidthOfString, GetStringWidth (gPressEnter)) / 2; CreatePopUp (ScreenSize, 4, &NullCharacter, Packet->String, gPressEnter, &NullCharacter); - gBS->FreePool (Packet); + FreePool (Packet); } StringPtr[0] = CHAR_NULL; @@ -571,8 +571,8 @@ Error: } while (1); Done: - gBS->FreePool (TempString); - gBS->FreePool (TempString2); + FreePool (TempString); + FreePool (TempString2); return Status; } @@ -600,7 +600,7 @@ EncodePassword ( CopyMem (Password, Buffer, MaxSize); - gBS->FreePool (Buffer); + FreePool (Buffer); return ; } @@ -880,7 +880,7 @@ EnterCarriageReturn: case CHAR_CARRIAGE_RETURN: SelectionComplete = TRUE; - gBS->FreePool (StringPtr); + FreePool (StringPtr); break; default: @@ -1083,7 +1083,7 @@ GetSelectionInputPopUp ( PopUpWidth = StrLen (StringPtr); } - gBS->FreePool (StringPtr); + FreePool (StringPtr); } } // @@ -1224,7 +1224,7 @@ GetSelectionInputPopUp ( TempStringPtr = AllocateZeroPool (sizeof (CHAR16) * (PopUpWidth - 1)); ASSERT (TempStringPtr != NULL); CopyMem (TempStringPtr, StringPtr, (sizeof (CHAR16) * (PopUpWidth - 5))); - gBS->FreePool (StringPtr); + FreePool (StringPtr); StringPtr = TempStringPtr; StrCat (StringPtr, (CHAR16 *) L"..."); } @@ -1256,7 +1256,7 @@ GetSelectionInputPopUp ( PrintStringAt (Start + 2, Index2, StringPtr); } - gBS->FreePool (StringPtr); + FreePool (StringPtr); Index2 = Index2 + 1; } } @@ -1520,7 +1520,7 @@ TheKey: case SCAN_ESC: gST->ConOut->SetAttribute (gST->ConOut, SavedAttribute); if (ValueArrayBackup != NULL) { - gBS->FreePool (ValueArrayBackup); + FreePool (ValueArrayBackup); } return EFI_DEVICE_ERROR; @@ -1537,7 +1537,7 @@ TheKey: // if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) { CopyMem (ValueArray, ValueArrayBackup, ValueCount); - gBS->FreePool (ValueArrayBackup); + FreePool (ValueArrayBackup); } else { *Value = TempValue; } diff --git a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Presentation.c b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Presentation.c index 8c81fd8c54..6bbe810ee2 100644 --- a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Presentation.c +++ b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Presentation.c @@ -1,12 +1,12 @@ /*++ -Copyright (c) 2006, 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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2007, 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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: Presentation.c @@ -60,7 +60,7 @@ ClearLines ( gST->ConOut->SetCursorPosition (gST->ConOut, LeftColumn, TopRow); - gBS->FreePool (Buffer); + FreePool (Buffer); return ; } @@ -237,7 +237,7 @@ DisplayPageFrame ( break; } - gBS->FreePool (StrFrontPageBanner); + FreePool (StrFrontPageBanner); } } } @@ -318,7 +318,7 @@ DisplayPageFrame ( } } - gBS->FreePool (Buffer); + FreePool (Buffer); } @@ -327,7 +327,7 @@ DisplayPageFrame ( ?F2=Previous Page Setup Page ? +------------------------------------------------------------------------------+ - + @@ -437,7 +437,7 @@ DisplayForm ( // // Remove Buffer allocated for StringPtr after it has been used. // - gBS->FreePool (StringPtr); + FreePool (StringPtr); for (Index = 0; FormTags.Tags[Index].Operand != EFI_IFR_END_FORM_OP; Index++) { GrayOut = FALSE; @@ -595,7 +595,7 @@ GetOut: FormTags.Tags[Index].NumberOfLines++; } - gBS->FreePool (OutputString); + FreePool (OutputString); } ArrayEntry = 0; @@ -1113,9 +1113,9 @@ Routine Description: The function does the most of the works when the EFI_TAG that user selects on is EFI_IFR_FLAG_INTERACTIVE or EFI_IFR_PASSWORD_OP: invoke CallBack, update the new form data. - + Arguments: - + Selection - The current selection of the form. CallbackData - The pointer to host the data passed back by the callback function. FileFormTagsHead - Prompt string token of the one-of box @@ -1123,10 +1123,10 @@ Arguments: FormHandle - Output the the handle of the form. TitleToken - Output the TitleToken of the new page. FormTags - Output the FormFags of the new page. - -Returns: + +Returns: VOID - + --*/ { UINTN Index; @@ -1212,7 +1212,7 @@ Returns: ); if (EFI_ERROR (Status)) { - gBS->FreePool (LocalTags->Tags); + FreePool (LocalTags->Tags); return ; } @@ -1317,7 +1317,7 @@ Returns: } if (Packet != NULL) { - gBS->FreePool (Packet); + FreePool (Packet); } for (BackupIndex = 0; LocalTags->Tags[BackupIndex].Operand != EFI_IFR_END_FORM_OP; BackupIndex++) { @@ -1347,7 +1347,7 @@ Returns: // Delete the buffer associated with previous dynamic page // We will re-allocate a buffer.... // - gBS->FreePool (LocalTags->Tags); + FreePool (LocalTags->Tags); Length = 0xF000; Buffer = AllocateZeroPool (Length); diff --git a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Print.c b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Print.c index a051b47827..a751727f30 100644 --- a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Print.c +++ b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Print.c @@ -1,13 +1,13 @@ /*++ -Copyright (c) 2006, 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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006, 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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: @@ -16,9 +16,9 @@ Module Name: Abstract: Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very - simple implemenation of SPrint() and Print() to support debug. + simple implemenation of SPrint() and Print() to support debug. - You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a + You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a time. This makes the implementation very simple. VSPrint, Print, SPrint format specification has the follwoing form @@ -122,8 +122,8 @@ _IPrint ( // Out->OutputString (Out, &BackupBuffer[PreviousIndex]); - gBS->FreePool (Buffer); - gBS->FreePool (BackupBuffer); + FreePool (Buffer); + FreePool (BackupBuffer); return EFI_SUCCESS; } @@ -202,51 +202,6 @@ Returns: return Print ((CHAR16 *) L"%c", Character); } -/* -UINTN -PrintToken ( - IN EFI_HII_HANDLE Handle, - IN UINT16 Token, - IN CHAR16 *Language, - ... - ) -{ - VA_LIST args; - UINTN NumberOfHiiHandles; - EFI_HANDLE *HandleBuffer; - EFI_HII_PROTOCOL *Hii; - - // - // There should only be one HII image - // - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiHiiProtocolGuid, - NULL, - &NumberOfHiiHandles, - &HandleBuffer - ); - - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Retrieve the Hii protocol interface - // - Status = gBS->HandleProtocol ( - HandleBuffer[0], - &gEfiHiiProtocolGuid, - &Hii - ); - - Hii->GetString (Hii, Handle, Token, FALSE, Language, - - VA_START (args, fmt); - return _IPrint ((UINTN) -1, (UINTN) -1, gST->ConOut, fmt, args); -} - -*/ UINTN PrintAt ( IN UINTN Column, @@ -258,7 +213,7 @@ PrintAt ( Routine Description: - Prints a formatted unicode string to the default console, at + Prints a formatted unicode string to the default console, at the supplied cursor position Arguments: @@ -289,7 +244,7 @@ PrintStringAt ( Routine Description: - Prints a unicode string to the default console, at + Prints a unicode string to the default console, at the supplied cursor position, using L"%s" format. Arguments: @@ -317,7 +272,7 @@ PrintCharAt ( Routine Description: - Prints a chracter to the default console, at + Prints a chracter to the default console, at the supplied cursor position, using L"%c" format. Arguments: diff --git a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/ProcessOptions.c b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/ProcessOptions.c index 2484f5089c..a2dc808346 100644 --- a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/ProcessOptions.c +++ b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/ProcessOptions.c @@ -138,7 +138,7 @@ AdjustNvMap ( } } - gBS->FreePool (VariableDefinition->NvRamMap); + FreePool (VariableDefinition->NvRamMap); VariableDefinition->NvRamMap = NvRamMap; VariableDefinition->VariableFakeSize = (UINT16) SizeRequired; } @@ -226,7 +226,7 @@ ProcessOptions ( ); if (*OptionString != NULL) { - gBS->FreePool (*OptionString); + FreePool (*OptionString); *OptionString = NULL; } @@ -311,7 +311,7 @@ ProcessOptions ( if (!EFI_ERROR (Status)) { if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) { CopyMem (NvRamMap, ValueArray, MenuOption->ThisTag->StorageWidth); - gBS->FreePool (ValueArray); + FreePool (ValueArray); } else { // // Since the value can be one byte long or two bytes long, do a CopyMem based on StorageWidth @@ -359,7 +359,7 @@ ProcessOptions ( // Since the value can be one byte long or two bytes long, do a CopyMem based on StorageWidth // CopyMem (NvRamMap, &Number, MenuOption->ThisTag->StorageWidth); - gBS->FreePool (StringPtr); + FreePool (StringPtr); break; default: @@ -372,7 +372,7 @@ ProcessOptions ( UpdateStatusBar (NV_UPDATE_REQUIRED, Tag->Flags, TRUE); } else { if (Tag->Operand == EFI_IFR_ORDERED_LIST_OP) { - gBS->FreePool (ValueArray); + FreePool (ValueArray); } return EFI_SUCCESS; @@ -434,7 +434,7 @@ ProcessOptions ( // // Remove Buffer allocated for StringPtr after it has been used. // - gBS->FreePool (StringPtr); + FreePool (StringPtr); } else { // // The option value is the same as what is stored in NV store. Print this. @@ -447,7 +447,7 @@ ProcessOptions ( // // Remove Buffer allocated for StringPtr after it has been used. // - gBS->FreePool (StringPtr); + FreePool (StringPtr); Default = 0; break; } @@ -475,7 +475,7 @@ ProcessOptions ( // // Remove Buffer allocated for StringPtr after it has been used. // - gBS->FreePool (StringPtr); + FreePool (StringPtr); } } break; @@ -1028,7 +1028,7 @@ ProcessOptions ( UpdateStatusBar (NV_UPDATE_REQUIRED, Tag->Flags, TRUE); } - gBS->FreePool (StringPtr); + FreePool (StringPtr); return Status; } else { for (Index = 0; Index < gOptionBlockWidth; Index++) { @@ -1073,13 +1073,13 @@ ProcessOptions ( if (EFI_ERROR (Status)) { if (Status == EFI_NOT_READY) { - gBS->FreePool (StringPtr); + FreePool (StringPtr); return EFI_SUCCESS; } } Status = ReadPassword (MenuOption, TRUE, Tag, PageData, TRUE, FileFormTags, StringPtr); - gBS->FreePool (StringPtr); + FreePool (StringPtr); return EFI_SUCCESS; } @@ -1090,7 +1090,7 @@ ProcessOptions ( // Status = ReadPassword (MenuOption, TRUE, Tag, PageData, FALSE, FileFormTags, StringPtr); if (EFI_ERROR (Status)) { - gBS->FreePool (StringPtr); + FreePool (StringPtr); return EFI_SUCCESS; } @@ -1102,7 +1102,7 @@ ProcessOptions ( } if (Status != 0) { - gBS->FreePool (StringPtr); + FreePool (StringPtr); return EFI_SUCCESS; } else { break; @@ -1123,7 +1123,7 @@ ProcessOptions ( // // User couldn't figure out how to type two identical passwords // - gBS->FreePool (StringPtr); + FreePool (StringPtr); return EFI_SUCCESS; } // @@ -1180,8 +1180,8 @@ ProcessOptions ( ); } - gBS->FreePool (TmpNvRamMap); - gBS->FreePool (StringPtr); + FreePool (TmpNvRamMap); + FreePool (StringPtr); break; } diff --git a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Setup.c b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Setup.c index 759eb5efb9..a0a7f1ba78 100644 --- a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Setup.c +++ b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Setup.c @@ -1,14 +1,14 @@ /**@file Entry and initialization module for the browser. - + Copyright (c) 2006 - 2007 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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ @@ -21,7 +21,7 @@ FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = { // { { - 0x847bc3fe, + 0x847bc3fe, 0xb974, 0x446d, { @@ -162,7 +162,7 @@ SendForm ( Routine Description: This is the routine which an external caller uses to direct the browser - where to obtain it's information. + where to obtain it's information. Arguments: @@ -185,7 +185,7 @@ Arguments: needs to provide to the browser the current settings for the "fake" NV variable. If used, no saving of an NV variable will be possible. This parameter is also ignored if HandleCount > 1. -Returns: +Returns: --*/ { @@ -292,7 +292,7 @@ Returns: ); if (EFI_ERROR (Status)) { - gBS->FreePool (CallbackData); + FreePool (CallbackData); return Status;; } @@ -304,7 +304,7 @@ Returns: Status = InitializeBinaryStructures (Handle, UseDatabase, Packet, NvMapOverride, HandleCount, &FileFormTagsHead); if (EFI_ERROR (Status)) { - gBS->FreePool (CallbackData); + FreePool (CallbackData); return Status; } // @@ -327,7 +327,7 @@ Returns: if (UseDatabase && (HandleCount > 1)) { if (Selection == NULL) { - gBS->FreePool (CallbackData); + FreePool (CallbackData); return EFI_SUCCESS; } } @@ -357,12 +357,12 @@ Returns: *Handle = BackupHandle; if (EFI_ERROR (Status)) { - gBS->FreePool (CallbackData); + FreePool (CallbackData); return Status; } if (Callback && (AltSelection == NULL)) { - gBS->FreePool (CallbackData); + FreePool (CallbackData); return Status; } @@ -379,7 +379,7 @@ Returns: // // If this is the FrontPage, return after every selection // - gBS->FreePool (Selection); + FreePool (Selection); UiFreeMenu (); // @@ -390,11 +390,11 @@ Returns: gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->ClearScreen (gST->ConOut); - gBS->FreePool (CallbackData); + FreePool (CallbackData); return EFI_SUCCESS; } - gBS->FreePool (Selection); + FreePool (Selection); UiFreeMenu (); // @@ -405,14 +405,14 @@ Returns: gST->ConOut->ClearScreen (gST->ConOut); if (!Callback) { - gBS->FreePool (CallbackData); + FreePool (CallbackData); return EFI_SUCCESS; } } } while (!EFI_ERROR (Status)); - gBS->FreePool (CallbackData); + FreePool (CallbackData); return Status; } @@ -426,11 +426,11 @@ InitializeSetup ( Routine Description: Initialize Setup - + Arguments: (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT) -Returns: +Returns: EFI_SUCCESS - Setup loaded. other - Setup Error @@ -491,7 +491,7 @@ Returns: Status = Hii->NewPack (Hii, PackageList, &gHiiHandle); - gBS->FreePool (PackageList); + FreePool (PackageList); // // Install protocol interface @@ -532,7 +532,7 @@ Arguments: Index - Offset of the current opcode in the Ifr raw data. FileFormTags - Pointer of current EFI_FILE_FORM_TAGS structure. CurrentVariable - Current variable number. - + Returns: None. --*/ @@ -605,7 +605,7 @@ Arguments: NumberOfLines - Number of lines this opcode occupied. FileFormTags - Pointer of current EFI_FILE_FORM_TAGS structure. CurrentVariable - Current variable number. - + Returns: None. --*/ @@ -661,7 +661,7 @@ Returns: CopyMem (&Tag->Value, &Tag->Default, sizeof (UINT16)); } break; - } + } } } @@ -713,11 +713,11 @@ AddNextInconsistentTag ( Routine Description: Initialize the next inconsistent tag data and add it to the inconsistent tag list. - + Arguments: InconsistentTagsPtr - Pointer of the inconsistent tag's pointer. -Returns: +Returns: None. --*/ @@ -829,13 +829,14 @@ InitializeTagStructures ( // for (Index = 0; Index < NumberOfTags; Index++) { if (FormTags->Tags[Index].IntList != NULL) { - gBS->FreePool (FormTags->Tags[Index].IntList); + FreePool (FormTags->Tags[Index].IntList); } } - gBS->FreePool (FormTags->Tags); - gBS->FreePool (FormTags->Next); - FormTags->Next = NULL; + FreePool (FormTags->Tags); + + ASSERT (FormTags->Next == NULL); + FormTags->Tags = NULL; FormTags = SavedFormTags; @@ -1350,7 +1351,7 @@ InitializeTagStructures ( // Since this op-code doesn't use the next field(s), initialize them with something invalid. // Unfortunately 0 is a valid offset value for a QuestionId // - + // // Reserve INVALID_OFFSET_VALUE - 1 for TRUE or FALSE because they are inconsistency tags also, but // have no coresponding id. The examination of id is needed by evaluating boolean expression. @@ -1571,8 +1572,8 @@ InitPage ( HomeEscapeString ); gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); - gBS->FreePool (HomeEscapeString); - gBS->FreePool (HomePageString); + FreePool (HomeEscapeString); + FreePool (HomePageString); return ; } @@ -1585,14 +1586,14 @@ GetToken ( /*++ Routine Description: - + Get the string based on the TokenID and HII Handle. Arguments: Token - The Token ID. HiiHandle - Handle of Ifr to be fetched. - + Returns: The output string. @@ -1618,7 +1619,7 @@ Returns: // // Free the old pool // - gBS->FreePool (Buffer); + FreePool (Buffer); // // Allocate new pool with correct value @@ -1955,8 +1956,8 @@ InitializeBinaryStructures ( // // Free the buffer that was allocated that was too small // - gBS->FreePool (VariableDefinition->NvRamMap); - gBS->FreePool (VariableDefinition->FakeNvRamMap); + FreePool (VariableDefinition->NvRamMap); + FreePool (VariableDefinition->FakeNvRamMap); VariableDefinition->NvRamMap = AllocateZeroPool (SizeOfNvStore); VariableDefinition->FakeNvRamMap = AllocateZeroPool (SizeOfNvStore + VariableDefinition->VariableFakeSize); @@ -1986,18 +1987,18 @@ InitializeBinaryStructures ( // if the variable was not found, we will retrieve default values // if (Status == EFI_NOT_FOUND) { - + if (0 == CompareMem (VariableDefinition->VariableName, L"Setup", 10)) { NvMapListHead = NULL; - + Status = Hii->GetDefaultImage (Hii, Handle[HandleIndex], EFI_IFR_FLAG_DEFAULT, &NvMapListHead); if (!EFI_ERROR (Status)) { ASSERT_EFI_ERROR (NULL != NvMapListHead); - + NvMapListNode = NvMapListHead; - + while (NULL != NvMapListNode) { if (VariableDefinition->VariableId == NvMapListNode->VariablePack->VariableId) { NvMap = (VOID *) ((CHAR8 *) NvMapListNode->VariablePack + sizeof (EFI_HII_VARIABLE_PACK) + NvMapListNode->VariablePack->VariableNameLength); @@ -2006,25 +2007,25 @@ InitializeBinaryStructures ( } NvMapListNode = NvMapListNode->NextVariablePack; } - + // // Free the buffer that was allocated. // - gBS->FreePool (VariableDefinition->NvRamMap); - gBS->FreePool (VariableDefinition->FakeNvRamMap); - + FreePool (VariableDefinition->NvRamMap); + FreePool (VariableDefinition->FakeNvRamMap); + // // Allocate, copy the NvRamMap. // VariableDefinition->VariableFakeSize = (UINT16) (VariableDefinition->VariableFakeSize - VariableDefinition->VariableSize); VariableDefinition->VariableSize = (UINT16) NvMapSize; VariableDefinition->VariableFakeSize = (UINT16) (VariableDefinition->VariableFakeSize + VariableDefinition->VariableSize); - + VariableDefinition->NvRamMap = AllocateZeroPool (VariableDefinition->VariableSize); VariableDefinition->FakeNvRamMap = AllocateZeroPool (NvMapSize + VariableDefinition->VariableFakeSize); CopyMem (VariableDefinition->NvRamMap, NvMap, NvMapSize); - gBS->FreePool (NvMapListHead); + FreePool (NvMapListHead); } } @@ -2060,7 +2061,7 @@ Arguments: HiiHandle - Handle of Ifr to be fetched. Packet - Pointer to IFR packet. BinaryData - Buffer to copy the string into - + Returns: Returns the number of CHAR16 characters that were copied into the OutputString buffer. @@ -2098,7 +2099,7 @@ Returns: if (Status == EFI_BUFFER_TOO_SMALL) { - gBS->FreePool (Buffer); + FreePool (Buffer); // // Allocate memory for our Form binary @@ -2121,7 +2122,7 @@ Returns: Status = Hii->NewPack (Hii, PackageList, &HiiHandle); - gBS->FreePool (PackageList); + FreePool (PackageList); } if (EFI_ERROR (Status)) { diff --git a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Ui.c b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Ui.c index 48b02bf332..40bd826023 100644 --- a/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Ui.c +++ b/EdkModulePkg/Universal/UserInterface/SetupBrowser/Dxe/Ui.c @@ -1,14 +1,14 @@ /**@file Implementation for UI. - -Copyright (c) 2006 - 2007, 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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Copyright (c) 2006 - 2007, 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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ @@ -63,7 +63,7 @@ Routine Description: Initialize Menu option list. Arguments: - + Returns: --*/ @@ -81,7 +81,7 @@ Routine Description: Initialize Menu option list. Arguments: - + Returns: --*/ @@ -100,7 +100,7 @@ Routine Description: Remove Menu option list. Arguments: - + Returns: --*/ @@ -119,7 +119,7 @@ Returns: (*PreviousSelection)->Handle = UiMenuList->Selection.Handle; gEntryNumber = UiMenuList->FormerEntryNumber; RemoveEntryList (&UiMenuList->MenuLink); - gBS->FreePool (UiMenuList); + FreePool (UiMenuList); } } @@ -133,7 +133,7 @@ Routine Description: Free Menu option linked list. Arguments: - + Returns: --*/ @@ -143,7 +143,7 @@ Returns: while (!IsListEmpty (&gMenuList)) { UiMenuList = CR (gMenuList.ForwardLink, UI_MENU_LIST, MenuLink, UI_MENU_LIST_SIGNATURE); RemoveEntryList (&UiMenuList->MenuLink); - gBS->FreePool (UiMenuList); + FreePool (UiMenuList); } } @@ -157,7 +157,7 @@ Routine Description: Add one menu entry to the linked lst Arguments: - + Returns: --*/ @@ -183,7 +183,7 @@ Routine Description: Free Menu option linked list. Arguments: - + Returns: --*/ @@ -197,8 +197,8 @@ Returns: // // We allocated space for this description when we did a GetToken, free it here // - gBS->FreePool (MenuOption->Description); - gBS->FreePool (MenuOption); + FreePool (MenuOption->Description); + FreePool (MenuOption); } } @@ -213,7 +213,7 @@ Routine Description: Refresh screen with current date and/or time based on screen context Arguments: - + Returns: --*/ @@ -256,7 +256,7 @@ Returns: } if (OptionString != NULL) { - gBS->FreePool (OptionString); + FreePool (OptionString); } } @@ -373,7 +373,7 @@ Routine Description: Arguments: String - String description for this option. Context - Context data for entry. - + Returns: --*/ @@ -414,7 +414,7 @@ Routine Description: Arguments: String - String description for this option. Context - Context data for entry. - + Returns: --*/ @@ -457,7 +457,7 @@ Routine Description: Arguments: NumberOfLines - The number of lines for the dialog box - HotKey - Defines whether a single character is parsed (TRUE) and returned in KeyValue + HotKey - Defines whether a single character is parsed (TRUE) and returned in KeyValue or a string is returned in StringBuffer. Two special characters are considered when entering a string, a SCAN_ESC and an CHAR_CARRIAGE_RETURN. SCAN_ESC terminates string input and returns MaximumStringSize - The maximum size in bytes of a typed in string (each character is a CHAR16) and the minimum string returned is two bytes @@ -465,7 +465,7 @@ Arguments: KeyValue - The EFI_KEY value returned if HotKey is TRUE.. String - Pointer to the first string in the list ... - A series of (quantity == NumberOfLines) text strings which will be used to construct the dialog box - + Returns: EFI_SUCCESS - Displayed dialog and received user interaction EFI_INVALID_PARAMETER - One of the parameters was invalid (e.g. (StringBuffer == NULL) && (HotKey == FALSE)) @@ -572,8 +572,8 @@ Returns: case CHAR_NULL: switch (Key.ScanCode) { case SCAN_ESC: - gBS->FreePool (TempString); - gBS->FreePool (BufferedString); + FreePool (TempString); + FreePool (BufferedString); gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute); gST->ConOut->EnableCursor (gST->ConOut, TRUE); return EFI_DEVICE_ERROR; @@ -586,8 +586,8 @@ Returns: case CHAR_CARRIAGE_RETURN: SelectionComplete = TRUE; - gBS->FreePool (TempString); - gBS->FreePool (BufferedString); + FreePool (TempString); + FreePool (BufferedString); gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute); gST->ConOut->EnableCursor (gST->ConOut, TRUE); return EFI_SUCCESS; @@ -829,8 +829,8 @@ UpdateStatusBar ( break; } - gBS->FreePool (InputErrorMessage); - gBS->FreePool (NvUpdateMessage); + FreePool (InputErrorMessage); + FreePool (NvUpdateMessage); return ; } @@ -843,11 +843,11 @@ FreeData ( /*++ Routine Description: - + Used to remove the allocated data instances Arguments: - + Returns: --*/ @@ -867,11 +867,11 @@ Returns: FileForm = FileFormTagsHead; if (FormattedString != NULL) { - gBS->FreePool (FormattedString); + FreePool (FormattedString); } if (OptionString != NULL) { - gBS->FreePool (OptionString); + FreePool (OptionString); } for (; FileForm != NULL;) { @@ -908,17 +908,17 @@ Returns: } if (FormTags->Tags[Index].IntList != NULL) { - gBS->FreePool (FormTags->Tags[Index].IntList); + FreePool (FormTags->Tags[Index].IntList); } } if (PreviousFormTags != NULL) { - gBS->FreePool (FormTags->Tags); + FreePool (FormTags->Tags); FormTags = PreviousFormTags; - gBS->FreePool (FormTags->Next); + FreePool (FormTags->Next); FormTags->Next = NULL; } else { - gBS->FreePool (FormTags->Tags); + FreePool (FormTags->Tags); FormTags = NULL; } } @@ -942,7 +942,7 @@ Returns: // // Free the current entry // - gBS->FreePool (Inconsistent); + FreePool (Inconsistent); // // Restore the Previous pointer @@ -963,26 +963,32 @@ Returns: PreviousVariableDefinition = VariableDefinition; } - gBS->FreePool (VariableDefinition->VariableName); - gBS->FreePool (VariableDefinition->NvRamMap); - gBS->FreePool (VariableDefinition->FakeNvRamMap); + FreePool (VariableDefinition->VariableName); + + if (VariableDefinition->NvRamMap != NULL) { + FreePool (VariableDefinition->NvRamMap); + } + + if (VariableDefinition->FakeNvRamMap != NULL) { + FreePool (VariableDefinition->FakeNvRamMap); + } if (PreviousVariableDefinition != NULL) { VariableDefinition = PreviousVariableDefinition; - gBS->FreePool (VariableDefinition->Next); + FreePool (VariableDefinition->Next); VariableDefinition->Next = NULL; } else { - gBS->FreePool (VariableDefinition); + FreePool (VariableDefinition); VariableDefinition = NULL; } } if (PreviousFileForm != NULL) { FileForm = PreviousFileForm; - gBS->FreePool (FileForm->NextFile); + FreePool (FileForm->NextFile); FileForm->NextFile = NULL; } else { - gBS->FreePool (FileForm); + FreePool (FileForm); FileForm = NULL; } } @@ -1000,40 +1006,40 @@ Returns: PreviousIfrBinary = IfrBinary; } - gBS->FreePool (IfrBinary->IfrPackage); + FreePool (IfrBinary->IfrPackage); if (PreviousIfrBinary != NULL) { IfrBinary = PreviousIfrBinary; - gBS->FreePool (IfrBinary->Next); + FreePool (IfrBinary->Next); IfrBinary->Next = NULL; } else { - gBS->FreePool (IfrBinary); + FreePool (IfrBinary); IfrBinary = NULL; } } - gBS->FreePool (gPreviousValue); + FreePool (gPreviousValue); gPreviousValue = NULL; // // Free Browser Strings // - gBS->FreePool (gPressEnter); - gBS->FreePool (gConfirmError); - gBS->FreePool (gConfirmPassword); - gBS->FreePool (gPromptForNewPassword); - gBS->FreePool (gPromptForPassword); - gBS->FreePool (gToggleCheckBox); - gBS->FreePool (gNumericInput); - gBS->FreePool (gMakeSelection); - gBS->FreePool (gMoveHighlight); - gBS->FreePool (gEscapeString); - gBS->FreePool (gEnterCommitString); - gBS->FreePool (gEnterString); - gBS->FreePool (gFunctionOneString); - gBS->FreePool (gFunctionTwoString); - gBS->FreePool (gFunctionNineString); - gBS->FreePool (gFunctionTenString); + FreePool (gPressEnter); + FreePool (gConfirmError); + FreePool (gConfirmPassword); + FreePool (gPromptForNewPassword); + FreePool (gPromptForPassword); + FreePool (gToggleCheckBox); + FreePool (gNumericInput); + FreePool (gMakeSelection); + FreePool (gMoveHighlight); + FreePool (gEscapeString); + FreePool (gEnterCommitString); + FreePool (gEnterString); + FreePool (gFunctionOneString); + FreePool (gFunctionTwoString); + FreePool (gFunctionNineString); + FreePool (gFunctionTenString); return ; } @@ -1046,11 +1052,11 @@ SelectionsAreValid ( /*++ Routine Description: - Initiate late consistency checks against the current page. + Initiate late consistency checks against the current page. Arguments: None - + Returns: --*/ @@ -1103,7 +1109,7 @@ Returns: // Since the value can be one byte long or two bytes long, do a CopyMem based on StorageWidth // CopyMem (NvRamMap, &Tag->OldValue, Tag->StorageWidth); - gBS->FreePool (StringPtr); + FreePool (StringPtr); break; default: @@ -1133,7 +1139,7 @@ Routine Description: Arguments: Tag - The Tag structure passed in. Handle - The handle in the HII database being used - + Returns: Returns the number of CHAR16 characters that is support. @@ -1151,7 +1157,7 @@ Returns: if ((Tag->Operand == EFI_IFR_TEXT_OP) && (Tag->TextTwo != 0)) { String = GetToken (Tag->TextTwo, Handle); Size = StrLen (String); - gBS->FreePool (String); + FreePool (String); } if ((Tag->Operand == EFI_IFR_SUBTITLE_OP) || @@ -1188,7 +1194,7 @@ Arguments: LineWidth - Width of the desired string to extract in CHAR16 characters Index - Where in InputString to start the copy process OutputString - Buffer to copy the string into - + Returns: Returns the number of CHAR16 characters that were copied into the OutputString buffer. @@ -1213,14 +1219,14 @@ Returns: // Ensure we have got a valid buffer // if (*OutputString != NULL) { - + // //NARROW_CHAR can not be printed in screen, so if a line only contain the two CHARs: 'NARROW_CHAR + CHAR_CARRIAGE_RETURN' , it is a empty line in Screen. //To avoid displaying this empty line in screen, just skip the two CHARs here. // if ((InputString[*Index] == NARROW_CHAR) && (InputString[*Index + 1] == CHAR_CARRIAGE_RETURN)) { *Index = *Index + 2; - } + } // // Fast-forward the string and see if there is a carriage-return in the string @@ -1323,7 +1329,7 @@ UpdateOptionSkipLines ( } } - gBS->FreePool (OutputString); + FreePool (OutputString); if (SkipValue != 0) { SkipValue--; } @@ -1382,9 +1388,9 @@ Arguments: SubMenu - Indicate is sub menu. FileFormTagsHead - A pointer to the EFI_FILE_FORM_TAGS structure. PageData - A pointer to the EFI_IFR_DATA_ARRAY. - + Returns: - Return the pointer of the menu which selected, + Return the pointer of the menu which selected, otherwise return NULL. --*/ @@ -1548,7 +1554,7 @@ Returns: while (gMenuRefreshHead != NULL) { OldMenuRefreshEntry = gMenuRefreshHead->Next; - gBS->FreePool (gMenuRefreshHead); + FreePool (gMenuRefreshHead); gMenuRefreshHead = OldMenuRefreshEntry; } @@ -1586,7 +1592,7 @@ Returns: } } - gBS->FreePool (OutputString); + FreePool (OutputString); if (Temp != 0) { Temp--; } @@ -1681,7 +1687,7 @@ Returns: } } - gBS->FreePool (OutputString); + FreePool (OutputString); if (Temp2 != 0) { Temp2--; } @@ -1723,14 +1729,14 @@ Returns: } } - gBS->FreePool (OutputString); + FreePool (OutputString); if (Temp2 != 0) { Temp2--; } } Row = OriginalRow; - gBS->FreePool (StringPtr); + FreePool (StringPtr); } } else { // @@ -1848,7 +1854,7 @@ Returns: MenuOption->Row++; } - gBS->FreePool (OutputString); + FreePool (OutputString); } MenuOption->Row = OriginalRow; @@ -1876,7 +1882,7 @@ Returns: MenuOption->Row++; } - gBS->FreePool (OutputString); + FreePool (OutputString); } MenuOption->Row = OriginalRow; @@ -1969,7 +1975,7 @@ Returns: MenuOption->Row++; } - gBS->FreePool (OutputString); + FreePool (OutputString); } MenuOption->Row = OriginalRow; @@ -1990,7 +1996,7 @@ Returns: MenuOption->Row++; } - gBS->FreePool (OutputString); + FreePool (OutputString); } MenuOption->Row = OriginalRow; @@ -2022,10 +2028,10 @@ Returns: case CfUpdateHelpString: ControlFlag = CfPrepareToReadKey; - if (SubMenu && - (Repaint || NewLine || + if (SubMenu && + (Repaint || NewLine || (MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) || - (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP)) && + (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP)) && !(gClassOfVfr == EFI_GENERAL_APPLICATION_SUBCLASS)) { // // Don't print anything if it is a NULL help token @@ -2305,7 +2311,7 @@ Returns: while (gMenuRefreshHead != NULL) { OldMenuRefreshEntry = gMenuRefreshHead->Next; - gBS->FreePool (gMenuRefreshHead); + FreePool (gMenuRefreshHead); gMenuRefreshHead = OldMenuRefreshEntry; } @@ -2328,7 +2334,7 @@ Returns: ExtractRequestedNvMap (FileFormTags, MenuOption->ThisTag->VariableNumber, &VariableDefinition); if (SubMenu) { - if ((MenuOption->ThisTag->Operand == EFI_IFR_TEXT_OP && + if ((MenuOption->ThisTag->Operand == EFI_IFR_TEXT_OP && !(MenuOption->ThisTag->Flags & EFI_IFR_FLAG_INTERACTIVE)) || (MenuOption->ThisTag->GrayOut) || (MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) || @@ -2966,9 +2972,9 @@ Returns: if (!EFI_ERROR (Status)) { ASSERT_EFI_ERROR (NULL != NvMapListHead); - + NvMapListNode = NvMapListHead; - + while (NULL != NvMapListNode) { if (FileFormTags->VariableDefinitions->VariableId == NvMapListNode->VariablePack->VariableId) { NvMap = (VOID *) ((CHAR8 *) NvMapListNode->VariablePack + sizeof (EFI_HII_VARIABLE_PACK) + NvMapListNode->VariablePack->VariableNameLength); @@ -2977,20 +2983,20 @@ Returns: } NvMapListNode = NvMapListNode->NextVariablePack; } - + // // Free the buffer that was allocated. // - gBS->FreePool (FileFormTags->VariableDefinitions->NvRamMap); - gBS->FreePool (FileFormTags->VariableDefinitions->FakeNvRamMap); - + FreePool (FileFormTags->VariableDefinitions->NvRamMap); + FreePool (FileFormTags->VariableDefinitions->FakeNvRamMap); + // // Allocate, copy the NvRamMap. // FileFormTags->VariableDefinitions->VariableFakeSize = (UINT16) (FileFormTags->VariableDefinitions->VariableFakeSize - FileFormTags->VariableDefinitions->VariableSize); FileFormTags->VariableDefinitions->VariableSize = (UINT16) NvMapSize; FileFormTags->VariableDefinitions->VariableFakeSize = (UINT16) (FileFormTags->VariableDefinitions->VariableFakeSize + FileFormTags->VariableDefinitions->VariableSize); - + FileFormTags->VariableDefinitions->NvRamMap = AllocateZeroPool (FileFormTags->VariableDefinitions->VariableSize); ASSERT (FileFormTags->VariableDefinitions->NvRamMap != NULL); @@ -2998,7 +3004,7 @@ Returns: ASSERT (FileFormTags->VariableDefinitions->FakeNvRamMap != NULL); CopyMem (FileFormTags->VariableDefinitions->NvRamMap, NvMap, NvMapSize); - gBS->FreePool (NvMapListHead); + FreePool (NvMapListHead); } UpdateStatusBar (NV_UPDATE_REQUIRED, MenuOption->ThisTag->Flags, TRUE); @@ -3017,7 +3023,7 @@ Returns: while (gMenuRefreshHead != NULL) { OldMenuRefreshEntry = gMenuRefreshHead->Next; - gBS->FreePool (gMenuRefreshHead); + FreePool (gMenuRefreshHead); gMenuRefreshHead = OldMenuRefreshEntry; } @@ -3043,11 +3049,11 @@ ValueIsScroll ( /*++ Routine Description: - Determine if the menu is the last menu that can be selected. + Determine if the menu is the last menu that can be selected. Arguments: Direction - the scroll direction. False is down. True is up. - + Returns: FALSE -- the menu isn't the last menu that can be selected. TRUE -- the menu is the last menu that can be selected. @@ -3087,9 +3093,9 @@ Routine Description: Arguments: Direction - the up or down direction. False is down. True is up. CurrentPos - Current position. - + Returns: - Return line number to pad. It is possible that we stand on a zero-advance + Return line number to pad. It is possible that we stand on a zero-advance data or time opcode, so pad one line when we judge if we are going to scroll outside. --*/ { diff --git a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 98137c6a3f..e224558651 100644 --- a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -424,13 +424,9 @@ Returns: Variable = NextVariable; } - Status = gBS->AllocatePool ( - EfiBootServicesData, - ValidBufferSize, - (VOID **) &ValidBuffer - ); - if (EFI_ERROR (Status)) { - return Status; + ValidBuffer = AllocatePool (ValidBufferSize); + if (ValidBuffer == NULL) { + return EFI_OUT_OF_RESOURCES; } SetMem (ValidBuffer, ValidBufferSize, 0xff); @@ -481,7 +477,7 @@ Returns: } } - gBS->FreePool (ValidBuffer); + FreePool (ValidBuffer); if (EFI_ERROR (Status)) { *LastVariableOffset = 0; @@ -1253,13 +1249,13 @@ Returns: *RemainingVariableStorageSize -= VariableSize; } } - + // // Go to the next one // Variable = NextVariable; } - + ReleaseLockOnlyAtBootTime (&Global->VariableServicesLock); return EFI_SUCCESS; } @@ -1308,14 +1304,9 @@ Returns: UINTN Index; UINT8 Data; - Status = gBS->AllocatePool ( - EfiRuntimeServicesData, - sizeof (ESAL_VARIABLE_GLOBAL), - (VOID **) &mVariableModuleGlobal - ); - - if (EFI_ERROR (Status)) { - return Status; + mVariableModuleGlobal = AllocateRuntimePool (sizeof (ESAL_VARIABLE_GLOBAL)); + if (mVariableModuleGlobal == NULL) { + return EFI_OUT_OF_RESOURCES; } EfiInitializeLock(&mVariableModuleGlobal->VariableGlobal[Physical].VariableServicesLock, EFI_TPL_NOTIFY); @@ -1323,15 +1314,10 @@ Returns: // // Allocate memory for volatile variable store // - Status = gBS->AllocatePool ( - EfiRuntimeServicesData, - VARIABLE_STORE_SIZE + SCRATCH_SIZE, - (VOID **) &VolatileVariableStore - ); - - if (EFI_ERROR (Status)) { - gBS->FreePool (mVariableModuleGlobal); - return Status; + VolatileVariableStore = AllocateRuntimePool (VARIABLE_STORE_SIZE + SCRATCH_SIZE); + if (VolatileVariableStore == NULL) { + FreePool (mVariableModuleGlobal); + return EFI_OUT_OF_RESOURCES; } SetMem (VolatileVariableStore, VARIABLE_STORE_SIZE + SCRATCH_SIZE, 0xff); @@ -1367,8 +1353,8 @@ Returns: Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor); if (EFI_ERROR (Status)) { - gBS->FreePool (mVariableModuleGlobal); - gBS->FreePool (VolatileVariableStore); + FreePool (mVariableModuleGlobal); + FreePool (VolatileVariableStore); return EFI_UNSUPPORTED; } @@ -1378,8 +1364,8 @@ Returns: GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME ); if (EFI_ERROR (Status)) { - gBS->FreePool (mVariableModuleGlobal); - gBS->FreePool (VolatileVariableStore); + FreePool (mVariableModuleGlobal); + FreePool (VolatileVariableStore); return EFI_UNSUPPORTED; } // @@ -1448,8 +1434,8 @@ Returns: } if (EFI_ERROR (Status)) { - gBS->FreePool (mVariableModuleGlobal); - gBS->FreePool (VolatileVariableStore); + FreePool (mVariableModuleGlobal); + FreePool (VolatileVariableStore); return Status; } @@ -1473,8 +1459,8 @@ Returns: } if (EFI_ERROR (Status)) { - gBS->FreePool (mVariableModuleGlobal); - gBS->FreePool (VolatileVariableStore); + FreePool (mVariableModuleGlobal); + FreePool (VolatileVariableStore); } return Status; diff --git a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.msa b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.msa index d1e6f3bb93..3607bc4f7f 100644 --- a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.msa +++ b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.msa @@ -52,6 +52,9 @@ BaseLib + + MemoryAllocationLib + Variable.h diff --git a/EdkModulePkg/Universal/Variable/RuntimeDxe/VariableIpf.msa b/EdkModulePkg/Universal/Variable/RuntimeDxe/VariableIpf.msa index 11ca3086ba..564fc61e6e 100644 --- a/EdkModulePkg/Universal/Variable/RuntimeDxe/VariableIpf.msa +++ b/EdkModulePkg/Universal/Variable/RuntimeDxe/VariableIpf.msa @@ -55,6 +55,9 @@ BaseLib + + MemoryAllocationLib + Variable.h diff --git a/EdkModulePkg/Universal/Variable/RuntimeDxe/reclaim.c b/EdkModulePkg/Universal/Variable/RuntimeDxe/reclaim.c index 00ebcf84fd..4c7249046c 100644 --- a/EdkModulePkg/Universal/Variable/RuntimeDxe/reclaim.c +++ b/EdkModulePkg/Universal/Variable/RuntimeDxe/reclaim.c @@ -1,20 +1,20 @@ /*++ -Copyright (c) 2006, 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 -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2007, 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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: reclaim.c - + Abstract: - + Handles non-volatile variable store garbage collection, using FTW (Fault Tolerant Write) protocol. @@ -82,7 +82,7 @@ GetFvbHandleByAddress ( } } - gBS->FreePool (HandleBuffer); + FreePool (HandleBuffer); return Status; } @@ -216,8 +216,8 @@ Returns: // Prepare for the variable data // FtwBufferSize = ((VARIABLE_STORE_HEADER *) ((UINTN) VariableBase))->Size; - Status = gBS->AllocatePool (EfiRuntimeServicesData, FtwBufferSize, (VOID **) &FtwBuffer); - if (EFI_ERROR (Status)) { + FtwBuffer = AllocateRuntimePool (FtwBufferSize); + if (FtwBuffer == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -236,6 +236,6 @@ Returns: FtwBuffer ); - gBS->FreePool (FtwBuffer); + FreePool (FtwBuffer); return Status; }