X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FBdsDxe%2FBootMngr%2FBootManager.c;h=f86d55594b90437f63cd85304fb03aea9f776c27;hp=80af8e18033f61a84a3c7b0bdfe5dd72154ce89a;hb=847240774030f9da79140a9d515a64ec817eb6eb;hpb=b7b0dca207fd89af69dac1eda05e5cd2adbe8cc1 diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c index 80af8e1803..f86d55594b 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c @@ -1,8 +1,8 @@ /** @file The platform boot manager reference implementation -Copyright (c) 2004 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials +Copyright (c) 2004 - 2011, 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 @@ -15,9 +15,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "BootManager.h" UINT16 mKeyInput; -EFI_GUID mBootManagerGuid = BOOT_MANAGER_FORMSET_GUID; -LIST_ENTRY *mBootOptionsList; +LIST_ENTRY mBootOptionsList; BDS_COMMON_OPTION *gOption; +CHAR16 *mDeviceTypeStr[] = { + L"Legacy BEV", + L"Legacy Floppy", + L"Legacy Hard Drive", + L"Legacy CD ROM", + L"Legacy PCMCIA", + L"Legacy USB", + L"Legacy Embedded Network", + L"Legacy Unknown Device" +}; + HII_VENDOR_DEVICE_PATH mBootManagerHiiVendorDevicePath = { { @@ -29,10 +39,7 @@ HII_VENDOR_DEVICE_PATH mBootManagerHiiVendorDevicePath = { (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) } }, - // - // {1DDDBE15-481D-4d2b-8277-B191EAF66525} - // - { 0x1dddbe15, 0x481d, 0x4d2b, { 0x82, 0x77, 0xb1, 0x91, 0xea, 0xf6, 0x65, 0x25 } } + BOOT_MANAGER_FORMSET_GUID }, { END_DEVICE_PATH_TYPE, @@ -56,7 +63,7 @@ BOOT_MANAGER_CALLBACK_DATA gBootManagerPrivate = { }; /** - This call back funtion is registered with Boot Manager formset. + This call back function is registered with Boot Manager formset. When user selects a boot option, this call back function will be triggered. The boot option is saved for later processing. @@ -88,40 +95,47 @@ BootManagerCallback ( LIST_ENTRY *Link; UINT16 KeyCount; - if ((Value == NULL) || (ActionRequest == NULL)) { - return EFI_INVALID_PARAMETER; - } - - // - // Initialize the key count - // - KeyCount = 0; + if (Action == EFI_BROWSER_ACTION_CHANGED) { + if ((Value == NULL) || (ActionRequest == NULL)) { + return EFI_INVALID_PARAMETER; + } - for (Link = mBootOptionsList->ForwardLink; Link != mBootOptionsList; Link = Link->ForwardLink) { - Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); + // + // Initialize the key count + // + KeyCount = 0; - KeyCount++; + for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) { + Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); - gOption = Option; + KeyCount++; - // - // Is this device the one chosen? - // - if (KeyCount == QuestionId) { - // - // Assigning the returned Key to a global allows the original routine to know what was chosen - // - mKeyInput = QuestionId; + gOption = Option; // - // Request to exit SendForm(), so that we could boot the selected option + // Is this device the one chosen? // - *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; - break; + if (KeyCount == QuestionId) { + // + // Assigning the returned Key to a global allows the original routine to know what was chosen + // + mKeyInput = QuestionId; + + // + // Request to exit SendForm(), so that we could boot the selected option + // + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + break; + } } + + return EFI_SUCCESS; } - return EFI_SUCCESS; + // + // All other action return unsupported. + // + return EFI_UNSUPPORTED; } /** @@ -157,7 +171,7 @@ InitializeBootManager ( // Publish our HII data // gBootManagerPrivate.HiiHandle = HiiAddPackages ( - &mBootManagerGuid, + &gBootManagerFormSetGuid, gBootManagerPrivate.DriverHandle, BootManagerVfrBin, BdsDxeStrings, @@ -172,7 +186,7 @@ InitializeBootManager ( } /** - This funtion invokees Boot Manager. If all devices have not a chance to be connected, + This function invokes Boot Manager. If all devices have not a chance to be connected, the connect all will be triggered. It then enumerate all boot options. If a boot option from the Boot Manager page is selected, Boot Manager will boot from this boot option. @@ -190,7 +204,6 @@ CallBootManager ( UINTN ExitDataSize; EFI_STRING_ID Token; EFI_INPUT_KEY Key; - LIST_ENTRY BdsBootOptionList; CHAR16 *HelpString; EFI_STRING_ID HelpToken; UINT16 *TempStr; @@ -201,10 +214,13 @@ CallBootManager ( VOID *EndOpCodeHandle; EFI_IFR_GUID_LABEL *StartLabel; EFI_IFR_GUID_LABEL *EndLabel; - CHAR16 *BootStringNumber; + UINT16 DeviceType; + BOOLEAN IsLegacyOption; + BOOLEAN NeedEndOp; - gOption = NULL; - InitializeListHead (&BdsBootOptionList); + DeviceType = (UINT16) -1; + gOption = NULL; + InitializeListHead (&mBootOptionsList); // // Connect all prior to entering the platform setup menu. @@ -213,14 +229,8 @@ CallBootManager ( BdsLibConnectAllDriversToAllControllers (); gConnectAllHappened = TRUE; } - // - // BugBug: Here we can not remove the legacy refresh macro, so we need - // get the boot order every time from "BootOrder" variable. - // Recreate the boot option list base on the BootOrder variable - // - BdsLibEnumerateAllBootOption (&BdsBootOptionList); - mBootOptionsList = &BdsBootOptionList; + BdsLibEnumerateAllBootOption (&mBootOptionsList); HiiHandle = gBootManagerPrivate.HiiHandle; @@ -248,8 +258,8 @@ CallBootManager ( EndLabel->Number = LABEL_BOOT_OPTION_END; mKeyInput = 0; - - for (Link = BdsBootOptionList.ForwardLink; Link != &BdsBootOptionList; Link = Link->ForwardLink) { + NeedEndOp = FALSE; + for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) { Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); // @@ -263,47 +273,40 @@ CallBootManager ( if ((Option->Attribute & LOAD_OPTION_HIDDEN) != 0) { continue; } - + // - // Replace description string with UNI file string. + // Group the legacy boot option in the sub title created dynamically // - BootStringNumber = AllocateZeroPool (StrSize (Option->Description)); - ASSERT (BootStringNumber != NULL); - - if (StrStr (Option->Description, DESCRIPTION_FLOPPY) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_FLOPPY) + 1; - Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)); - } else if (StrStr (Option->Description, DESCRIPTION_DVD) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_DVD) + 1; - Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_DVD)); - - } else if (StrStr (Option->Description, DESCRIPTION_USB) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_USB) + 1; - Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)); - - } else if (StrStr (Option->Description, DESCRIPTION_SCSI) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_SCSI) + 1; - Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)); - - } else if (StrStr (Option->Description, DESCRIPTION_MISC) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_MISC) + 1; - Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC)); - - } else if (StrStr (Option->Description, DESCRIPTION_NETWORK) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_NETWORK) + 1; - Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_NETWORK)); - - } else if (StrStr (Option->Description, DESCRIPTION_NON_BLOCK) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_NON_BLOCK) + 1; - Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)); + IsLegacyOption = (BOOLEAN) ( + (DevicePathType (Option->DevicePath) == BBS_DEVICE_PATH) && + (DevicePathSubType (Option->DevicePath) == BBS_BBS_DP) + ); + + if (!IsLegacyOption && NeedEndOp) { + NeedEndOp = FALSE; + HiiCreateEndOpCode (StartOpCodeHandle); } - ASSERT (Option->Description != NULL); - if (StrnCmp (BootStringNumber, L"0", 1) != 0) { - StrCat (Option->Description, L" "); - StrCat (Option->Description, BootStringNumber); + if (IsLegacyOption && DeviceType != ((BBS_BBS_DEVICE_PATH *) Option->DevicePath)->DeviceType) { + if (NeedEndOp) { + HiiCreateEndOpCode (StartOpCodeHandle); + } + + DeviceType = ((BBS_BBS_DEVICE_PATH *) Option->DevicePath)->DeviceType; + Token = HiiSetString ( + HiiHandle, + 0, + mDeviceTypeStr[ + MIN (DeviceType & 0xF, sizeof (mDeviceTypeStr) / sizeof (mDeviceTypeStr[0]) - 1) + ], + NULL + ); + HiiCreateSubTitleOpCode (StartOpCodeHandle, Token, 0, 0, 1); + NeedEndOp = TRUE; } - + + ASSERT (Option->Description != NULL); + Token = HiiSetString (HiiHandle, 0, Option->Description, NULL); TempStr = DevicePathToStr (Option->DevicePath); @@ -325,9 +328,13 @@ CallBootManager ( ); } + if (NeedEndOp) { + HiiCreateEndOpCode (StartOpCodeHandle); + } + HiiUpdateForm ( HiiHandle, - &mBootManagerGuid, + &gBootManagerFormSetGuid, BOOT_MANAGER_FORM_ID, StartOpCodeHandle, EndOpCodeHandle @@ -341,7 +348,7 @@ CallBootManager ( gFormBrowser2, &HiiHandle, 1, - &mBootManagerGuid, + &gBootManagerFormSetGuid, 0, NULL, &ActionRequest @@ -355,7 +362,7 @@ CallBootManager ( } // - //Will leave browser, check any reset required change is applied? if yes, reset system + // Will leave browser, check any reset required change is applied? if yes, reset system // SetupResetReminder ();