From 80a047f04a9005c37580532307d8c7c4b337fe4b Mon Sep 17 00:00:00 2001 From: ydong10 Date: Tue, 22 Jan 2013 09:49:44 +0000 Subject: [PATCH] Update the code of processing device path info in browser to follow UEFI spec. Signed-off-by: Eric Dong Reviewed-by: Liming Gao git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14076 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Universal/SetupBrowserDxe/Expression.c | 27 +++--- .../Universal/SetupBrowserDxe/Presentation.c | 4 +- .../Universal/SetupBrowserDxe/Setup.c | 11 ++- .../Universal/SetupBrowserDxe/Setup.h | 6 +- .../SetupBrowserDxe/SetupBrowserDxe.inf | 3 +- .../SetupBrowserDxe/SetupBrowserStr.uni | Bin 14292 -> 14784 bytes MdeModulePkg/Universal/SetupBrowserDxe/Ui.c | 79 +++++------------- MdeModulePkg/Universal/SetupBrowserDxe/Ui.h | 15 +--- 8 files changed, 57 insertions(+), 88 deletions(-) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c index 1a47f2b0a9..4a431f0dec 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c @@ -1,7 +1,7 @@ /** @file Utility functions for expression evaluation. -Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2013, 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 @@ -2470,22 +2470,21 @@ EvaluateExpression ( } if (OpCode->DevicePath != 0) { - StrPtr = GetToken (OpCode->DevicePath, FormSet->HiiHandle); - if (StrPtr == NULL) { - Value->Type = EFI_IFR_TYPE_UNDEFINED; - break; - } - - DevicePath = ConvertDevicePathFromText(StrPtr); + Value->Type = EFI_IFR_TYPE_UNDEFINED; - if (!GetQuestionValueFromForm(DevicePath, NULL, &OpCode->Guid, Value->Value.u16, &QuestionVal)){ - Value->Type = EFI_IFR_TYPE_UNDEFINED; - } else { - Value = &QuestionVal; + StrPtr = GetToken (OpCode->DevicePath, FormSet->HiiHandle); + if (StrPtr != NULL && mPathFromText != NULL) { + DevicePath = mPathFromText->ConvertTextToDevicePath(StrPtr); + if (DevicePath != NULL && GetQuestionValueFromForm(DevicePath, NULL, &OpCode->Guid, Value->Value.u16, &QuestionVal)) { + Value = &QuestionVal; + } + if (DevicePath != NULL) { + FreePool (DevicePath); + } } - if (DevicePath != NULL) { - FreePool (DevicePath); + if (StrPtr != NULL) { + FreePool (StrPtr); } } else if (CompareGuid (&OpCode->Guid, &gZeroGuid) != 0) { if (!GetQuestionValueFromForm(NULL, FormSet->HiiHandle, &OpCode->Guid, Value->Value.u16, &QuestionVal)){ diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index 62811c751a..ee8ab75a28 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -1,7 +1,7 @@ /** @file Utility functions for UI presentation. -Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2013, 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 @@ -602,6 +602,7 @@ InitializeBrowserStrings ( gSaveChanges = GetToken (STRING_TOKEN (SAVE_CHANGES), gHiiHandle); gOptionMismatch = GetToken (STRING_TOKEN (OPTION_MISMATCH), gHiiHandle); gFormSuppress = GetToken (STRING_TOKEN (FORM_SUPPRESSED), gHiiHandle); + gProtocolNotFound = GetToken (STRING_TOKEN (PROTOCOL_NOT_FOUND), gHiiHandle); return ; } @@ -642,6 +643,7 @@ FreeBrowserStrings ( FreePool (gSaveChanges); FreePool (gOptionMismatch); FreePool (gFormSuppress); + FreePool (gProtocolNotFound); return ; } diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index bcc8e020fd..33b3a8eec5 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -1,7 +1,7 @@ /** @file Entry and initialization module for the browser. -Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2013, 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 @@ -32,6 +32,7 @@ SETUP_DRIVER_PRIVATE_DATA mPrivateData = { EFI_HII_DATABASE_PROTOCOL *mHiiDatabase; EFI_HII_STRING_PROTOCOL *mHiiString; EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting; +EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mPathFromText; UINTN gBrowserContextCount = 0; LIST_ENTRY gBrowserContextList = INITIALIZE_LIST_HEAD_VARIABLE (gBrowserContextList); @@ -84,6 +85,7 @@ CHAR16 *gAdjustNumber; CHAR16 *gSaveChanges; CHAR16 *gOptionMismatch; CHAR16 *gFormSuppress; +CHAR16 *gProtocolNotFound; CHAR16 *mUnknownString = L"!"; @@ -662,6 +664,12 @@ InitializeSetup ( ); ASSERT_EFI_ERROR (Status); + Status = gBS->LocateProtocol ( + &gEfiDevicePathFromTextProtocolGuid, + NULL, + (VOID **) &mPathFromText + ); + // // Publish our HII data // @@ -4184,6 +4192,7 @@ RestoreBrowserContext ( gHelpBlockWidth = Context->HelpBlockWidth; gOldFormSet = Context->OldFormSet; gMenuRefreshHead = Context->MenuRefreshHead; + gProtocolNotFound = Context->ProtocolNotFound; CopyMem (&gScreenDimensions, &Context->ScreenDimensions, sizeof (gScreenDimensions)); CopyMem (&gMenuOption, &Context->MenuOption, sizeof (gMenuOption)); diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h index e11cdc16d7..8e32cb4e4a 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -1,7 +1,7 @@ /** @file Private MACRO, structure and function definitions for Setup Browser module. -Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2013, 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 @@ -30,6 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include @@ -546,6 +547,7 @@ typedef struct { CHAR16 *SaveChanges; CHAR16 *OptionMismatch; CHAR16 *FormSuppress; + CHAR16 *ProtocolNotFound; CHAR16 PromptBlockWidth; CHAR16 OptionBlockWidth; CHAR16 HelpBlockWidth; @@ -597,6 +599,7 @@ typedef enum { extern EFI_HII_DATABASE_PROTOCOL *mHiiDatabase; extern EFI_HII_STRING_PROTOCOL *mHiiString; extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting; +extern EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mPathFromText; extern BANNER_DATA *gBannerData; extern EFI_HII_HANDLE gFrontPageHandle; @@ -647,6 +650,7 @@ extern CHAR16 *gAdjustNumber; extern CHAR16 *gSaveChanges; extern CHAR16 *gOptionMismatch; extern CHAR16 *gFormSuppress; +extern CHAR16 *gProtocolNotFound; extern CHAR16 gPromptBlockWidth; extern CHAR16 gOptionBlockWidth; diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf index 2edbd3ad1b..2a4cda41e3 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf +++ b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf @@ -1,7 +1,7 @@ ## @file # The DXE driver produces FORM BROWSER protocols defined in UEFI HII 2.1 specificatin. # -# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2013, 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 @@ -75,6 +75,7 @@ gEfiHiiDatabaseProtocolGuid ## CONSUMES gEfiUnicodeCollation2ProtocolGuid ## CONSUMES gEfiUserManagerProtocolGuid ## SOMETIMES_CONSUMES + gEfiDevicePathFromTextProtocolGuid ## SOMETIMES_CONSUMES [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport ## CONSUMES diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserStr.uni b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserStr.uni index b155a5577ca691dd6deb28e8f3336f29ad594601..bb6414d2063253f2bca5bfb00c999f37eada585c 100644 GIT binary patch delta 322 zcmcbTf1r4RAG0BY@y5XQhLaU!*rY=k{282q*oPsW!4F7>0BJWM9m?Q0`J#gCWC324 zdS`}whCGHchE#?kh7tw^hGHOD#E=OTO9%2wfU*hL^l~- GVFdt>w?Tsd delta 19 bcmX?5d?kN^AF~02<;KAEhMV6QUtt9RRObjz diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c index 4e83c8fae5..8ff90e1440 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c @@ -1,7 +1,7 @@ /** @file Utility functions for User Interface functions. -Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2013, 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 @@ -1970,55 +1970,6 @@ FormSetGuidToHiiHandle ( return HiiHandle; } -/** - Transfer the device path string to binary format. - - @param StringPtr The device path string info. - - @retval Device path binary info. - -**/ -EFI_DEVICE_PATH_PROTOCOL * -ConvertDevicePathFromText ( - IN CHAR16 *StringPtr - ) -{ - UINTN BufferSize; - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - CHAR16 TemStr[2]; - UINT8 *DevicePathBuffer; - UINTN Index; - UINT8 DigitUint8; - - ASSERT (StringPtr != NULL); - - BufferSize = StrLen (StringPtr) / 2; - DevicePath = AllocatePool (BufferSize); - ASSERT (DevicePath != NULL); - - // - // Convert from Device Path String to DevicePath Buffer in the reverse order. - // - DevicePathBuffer = (UINT8 *) DevicePath; - for (Index = 0; StringPtr[Index] != L'\0'; Index ++) { - TemStr[0] = StringPtr[Index]; - DigitUint8 = (UINT8) StrHexToUint64 (TemStr); - if (DigitUint8 == 0 && TemStr[0] != L'0') { - // - // Invalid Hex Char as the tail. - // - break; - } - if ((Index & 1) == 0) { - DevicePathBuffer [Index/2] = DigitUint8; - } else { - DevicePathBuffer [Index/2] = (UINT8) ((DevicePathBuffer [Index/2] << 4) + DigitUint8); - } - } - - return DevicePath; -} - /** Process the goto op code, update the info in the selection structure. @@ -2064,16 +2015,32 @@ ProcessGotoOpCode ( if (Selection->Form->ModalForm) { return Status; } + // // Goto another Hii Package list // - Selection->Action = UI_ACTION_REFRESH_FORMSET; - DevicePath = ConvertDevicePathFromText (StringPtr); - - Selection->Handle = DevicePathToHiiHandle (DevicePath); - FreePool (DevicePath); - FreePool (StringPtr); + if (mPathFromText != NULL) { + DevicePath = mPathFromText->ConvertTextToDevicePath(StringPtr); + if (DevicePath != NULL) { + Selection->Handle = DevicePathToHiiHandle (DevicePath); + FreePool (DevicePath); + } + FreePool (StringPtr); + } else { + // + // Not found the EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL protocol. + // + do { + CreateDialog (4, TRUE, 0, NULL, &Key, gEmptyString, gProtocolNotFound, gPressEnter, gEmptyString); + } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN); + if (Repaint != NULL) { + *Repaint = TRUE; + } + FreePool (StringPtr); + return Status; + } + Selection->Action = UI_ACTION_REFRESH_FORMSET; if (Selection->Handle == NULL) { // // If target Hii Handle not found, exit diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h index ac016bbed8..4c3b314f0e 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h @@ -1,7 +1,7 @@ /** @file Private structure, MACRO and function definitions for User Interface related functionalities. -Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2013, 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 @@ -1048,17 +1048,4 @@ EvaluateExpressionList ( IN FORM_BROWSER_FORM *Form OPTIONAL ); -/** - Transfer the device path string to binary format. - - @param StringPtr The device path string info. - - @retval Device path binary info. - -**/ -EFI_DEVICE_PATH_PROTOCOL * -ConvertDevicePathFromText ( - IN CHAR16 *StringPtr - ); - #endif // _UI_H -- 2.39.5