X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FBdsDxe%2FBootMngr%2FBootManager.c;h=f86d55594b90437f63cd85304fb03aea9f776c27;hp=615c189d8daf1bd644b20c1075aec4028aa447df;hb=847240774030f9da79140a9d515a64ec817eb6eb;hpb=f6f910dd125144707e3516bbb517b8ec7a388c06 diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c index 615c189d8d..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; - } + if (Action == EFI_BROWSER_ACTION_CHANGED) { + if ((Value == NULL) || (ActionRequest == NULL)) { + return EFI_INVALID_PARAMETER; + } - // - // Initialize the key count - // - KeyCount = 0; + // + // Initialize the key count + // + KeyCount = 0; - for (Link = mBootOptionsList->ForwardLink; Link != mBootOptionsList; Link = Link->ForwardLink) { - Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); + for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) { + Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); - KeyCount++; + KeyCount++; - gOption = Option; - - // - // 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; } /** @@ -129,7 +143,8 @@ BootManagerCallback ( Registers HII packages for the Boot Manger to HII Database. It also registers the browser call back function. - @return Status of gBS->InstallMultipleProtocolInterfaces() and gHiiDatabase->NewPackageList() + @retval EFI_SUCCESS HII packages for the Boot Manager were registered successfully. + @retval EFI_OUT_OF_RESOURCES HII packages for the Boot Manager failed to be registered. **/ EFI_STATUS @@ -138,7 +153,6 @@ InitializeBootManager ( ) { EFI_STATUS Status; - EFI_HII_PACKAGE_LIST_HEADER *PackageList; // // Install Device Path Protocol and Config Access protocol to driver handle @@ -156,22 +170,23 @@ InitializeBootManager ( // // Publish our HII data // - PackageList = HiiLibPreparePackageList (2, &mBootManagerGuid, BootManagerVfrBin, BdsDxeStrings); - ASSERT (PackageList != NULL); - - Status = gHiiDatabase->NewPackageList ( - gHiiDatabase, - PackageList, - gBootManagerPrivate.DriverHandle, - &gBootManagerPrivate.HiiHandle - ); - FreePool (PackageList); - + gBootManagerPrivate.HiiHandle = HiiAddPackages ( + &gBootManagerFormSetGuid, + gBootManagerPrivate.DriverHandle, + BootManagerVfrBin, + BdsDxeStrings, + NULL + ); + if (gBootManagerPrivate.HiiHandle == NULL) { + Status = EFI_OUT_OF_RESOURCES; + } else { + Status = EFI_SUCCESS; + } return Status; } /** - 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. @@ -185,21 +200,27 @@ CallBootManager ( EFI_STATUS Status; BDS_COMMON_OPTION *Option; LIST_ENTRY *Link; - EFI_HII_UPDATE_DATA UpdateData; CHAR16 *ExitData; UINTN ExitDataSize; EFI_STRING_ID Token; EFI_INPUT_KEY Key; - LIST_ENTRY BdsBootOptionList; CHAR16 *HelpString; EFI_STRING_ID HelpToken; UINT16 *TempStr; EFI_HII_HANDLE HiiHandle; EFI_BROWSER_ACTION_REQUEST ActionRequest; UINTN TempSize; - - gOption = NULL; - InitializeListHead (&BdsBootOptionList); + VOID *StartOpCodeHandle; + VOID *EndOpCodeHandle; + EFI_IFR_GUID_LABEL *StartLabel; + EFI_IFR_GUID_LABEL *EndLabel; + UINT16 DeviceType; + BOOLEAN IsLegacyOption; + BOOLEAN NeedEndOp; + + DeviceType = (UINT16) -1; + gOption = NULL; + InitializeListHead (&mBootOptionsList); // // Connect all prior to entering the platform setup menu. @@ -208,28 +229,37 @@ 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; // // Allocate space for creation of UpdateData Buffer // - UpdateData.BufferSize = 0x1000; - UpdateData.Offset = 0; - UpdateData.Data = AllocateZeroPool (0x1000); - ASSERT (UpdateData.Data != NULL); + StartOpCodeHandle = HiiAllocateOpCodeHandle (); + ASSERT (StartOpCodeHandle != NULL); - mKeyInput = 0; + EndOpCodeHandle = HiiAllocateOpCodeHandle (); + ASSERT (EndOpCodeHandle != NULL); + + // + // Create Hii Extend Label OpCode as the start opcode + // + StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); + StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; + StartLabel->Number = LABEL_BOOT_OPTION; + + // + // Create Hii Extend Label OpCode as the end opcode + // + EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL)); + EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; + EndLabel->Number = LABEL_BOOT_OPTION_END; - for (Link = BdsBootOptionList.ForwardLink; Link != &BdsBootOptionList; Link = Link->ForwardLink) { + mKeyInput = 0; + NeedEndOp = FALSE; + for (Link = GetFirstNode (&mBootOptionsList); !IsNull (&mBootOptionsList, Link); Link = GetNextNode (&mBootOptionsList, Link)) { Option = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE); // @@ -240,11 +270,44 @@ CallBootManager ( // // Don't display the boot option marked as LOAD_OPTION_HIDDEN // - if (Option->Attribute & LOAD_OPTION_HIDDEN) { + if ((Option->Attribute & LOAD_OPTION_HIDDEN) != 0) { continue; } - HiiLibNewString (HiiHandle, &Token, Option->Description); + // + // Group the legacy boot option in the sub title created dynamically + // + IsLegacyOption = (BOOLEAN) ( + (DevicePathType (Option->DevicePath) == BBS_DEVICE_PATH) && + (DevicePathSubType (Option->DevicePath) == BBS_BBS_DP) + ); + + if (!IsLegacyOption && NeedEndOp) { + NeedEndOp = FALSE; + HiiCreateEndOpCode (StartOpCodeHandle); + } + + 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); TempSize = StrSize (TempStr); @@ -253,34 +316,39 @@ CallBootManager ( StrCat (HelpString, L"Device Path : "); StrCat (HelpString, TempStr); - HiiLibNewString (HiiHandle, &HelpToken, HelpString); + HelpToken = HiiSetString (HiiHandle, 0, HelpString, NULL); - CreateActionOpCode ( + HiiCreateActionOpCode ( + StartOpCodeHandle, mKeyInput, Token, HelpToken, EFI_IFR_FLAG_CALLBACK, - 0, - &UpdateData + 0 ); } - IfrLibUpdateForm ( + if (NeedEndOp) { + HiiCreateEndOpCode (StartOpCodeHandle); + } + + HiiUpdateForm ( HiiHandle, - &mBootManagerGuid, + &gBootManagerFormSetGuid, BOOT_MANAGER_FORM_ID, - LABEL_BOOT_OPTION, - FALSE, - &UpdateData + StartOpCodeHandle, + EndOpCodeHandle ); - FreePool (UpdateData.Data); + + HiiFreeOpCodeHandle (StartOpCodeHandle); + HiiFreeOpCodeHandle (EndOpCodeHandle); ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; Status = gFormBrowser2->SendForm ( gFormBrowser2, &HiiHandle, 1, - NULL, + &gBootManagerFormSetGuid, 0, NULL, &ActionRequest @@ -294,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 ();