diff --git a/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h b/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h index f17f4344b0..e2142db190 100644 --- a/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h +++ b/IntelFrameworkModulePkg/Include/Library/GenericBdsLib.h @@ -786,24 +786,6 @@ SetupResetReminder ( ); -/// -/// Define the boot option default description -/// -#define DESCRIPTION_FLOPPY L"EFI Floppy" -#define DESCRIPTION_FLOPPY_NUM L"EFI Floppy %d" -#define DESCRIPTION_DVD L"EFI DVD/CDROM" -#define DESCRIPTION_DVD_NUM L"EFI DVD/CDROM %d" -#define DESCRIPTION_USB L"EFI USB Device" -#define DESCRIPTION_USB_NUM L"EFI USB Device %d" -#define DESCRIPTION_SCSI L"EFI SCSI Device" -#define DESCRIPTION_SCSI_NUM L"EFI SCSI Device %d" -#define DESCRIPTION_MISC L"EFI Misc Device" -#define DESCRIPTION_MISC_NUM L"EFI Misc Device %d" -#define DESCRIPTION_NETWORK L"EFI Network" -#define DESCRIPTION_NETWORK_NUM L"EFI Network %d" -#define DESCRIPTION_NON_BLOCK L"EFI Non-Block Boot Device" -#define DESCRIPTION_NON_BLOCK_NUM L"EFI Non-Block Boot Device %d" - /// /// Define the boot type which to classify the boot option type /// Different boot option type could have different boot behavior @@ -822,8 +804,10 @@ SetupResetReminder ( #define BDS_EFI_MESSAGE_ATAPI_BOOT 0x0301 // Type 03; Sub-Type 01 #define BDS_EFI_MESSAGE_SCSI_BOOT 0x0302 // Type 03; Sub-Type 02 #define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05 -#define BDS_EFI_MESSAGE_SATA_BOOT 0x0318 // Type 03; Sub-Type 18 +#define BDS_EFI_MESSAGE_SATA_BOOT 0x0312 // Type 03; Sub-Type 18 +#define BDS_EFI_MESSAGE_MAC_BOOT 0x030b // Type 03; Sub-Type 11 #define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF + /// /// Media boot type /// If a device path of boot option contain a media node, the boot option is media boot type diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c index f5e7a153cc..188986a7c9 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c @@ -1008,7 +1008,7 @@ BdsLibEnumerateAllBootOption ( switch (DevicePathType) { case BDS_EFI_ACPI_FLOPPY_BOOT: - UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_FLOPPY_NUM, FloppyNumber); + UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", FloppyNumber); BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer); FloppyNumber++; break; @@ -1018,25 +1018,25 @@ BdsLibEnumerateAllBootOption ( // case BDS_EFI_MESSAGE_ATAPI_BOOT: case BDS_EFI_MESSAGE_SATA_BOOT: - UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_DVD_NUM, CdromNumber); + UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", CdromNumber); BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer); CdromNumber++; break; case BDS_EFI_MESSAGE_USB_DEVICE_BOOT: - UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_USB_NUM, UsbNumber); + UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", UsbNumber); BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer); UsbNumber++; break; case BDS_EFI_MESSAGE_SCSI_BOOT: - UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_SCSI_NUM, ScsiNumber); + UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", ScsiNumber); BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer); ScsiNumber++; break; case BDS_EFI_MESSAGE_MISC_BOOT: - UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_MISC_NUM, MiscNumber); + UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", MiscNumber); BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer); MiscNumber++; break; @@ -1098,7 +1098,7 @@ BdsLibEnumerateAllBootOption ( // BdsLibDeleteOptionFromHandle (FileSystemHandles[Index]); } else { - UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_NON_BLOCK_NUM, NonBlockNumber); + UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI Non-Block Boot Device %d", NonBlockNumber); BdsLibBuildOptionFromHandle (FileSystemHandles[Index], BdsBootOptionList, Buffer); NonBlockNumber++; } @@ -1120,7 +1120,7 @@ BdsLibEnumerateAllBootOption ( ); for (Index = 0; Index < NumberSimpleNetworkHandles; Index++) { - UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_NETWORK_NUM, Index); + UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", Index); BdsLibBuildOptionFromHandle (SimpleNetworkHandles[Index], BdsBootOptionList, Buffer); } @@ -1198,7 +1198,7 @@ BdsLibBuildOptionFromHandle ( ) { EFI_DEVICE_PATH_PROTOCOL *DevicePath; - + DevicePath = DevicePathFromHandle (Handle); // @@ -1575,7 +1575,7 @@ BdsGetBootTypeFromDevicePath ( return BDS_EFI_MEDIA_HD_BOOT; } else if (DevicePathSubType (TempDevicePath) == MEDIA_CDROM_DP) { return BDS_EFI_MEDIA_CDROM_BOOT; - } + } break; case ACPI_DEVICE_PATH: Acpi = (ACPI_HID_DEVICE_PATH *) TempDevicePath; @@ -1610,6 +1610,8 @@ BdsGetBootTypeFromDevicePath ( return BDS_EFI_MESSAGE_SCSI_BOOT; } else if (DevicePathSubType(TempDevicePath) == MSG_SATA_DP) { return BDS_EFI_MESSAGE_SATA_BOOT; + } else if (DevicePathSubType(TempDevicePath) == MSG_MAC_ADDR_DP) { + return BDS_EFI_MESSAGE_MAC_BOOT; } return BDS_EFI_MESSAGE_MISC_BOOT; default: @@ -1621,41 +1623,6 @@ BdsGetBootTypeFromDevicePath ( return BDS_EFI_UNSUPPORT; } - -/** - Check whether the descriptionis is conflict with the description reserved for - auto-created boot options. - - @param Description The Description in a boot option - - @retval TRUE The description is conflict with the description reserved for - auto-created boot options. - @retval FALSE The description is not conflict with the description reserved. - -**/ -BOOLEAN -EFIAPI -CheckDescritptionConflict ( - IN CHAR16 *Description - ) -{ - if (Description == NULL) { - return FALSE; - } - if ((CompareMem (Description, DESCRIPTION_FLOPPY, StrLen (DESCRIPTION_FLOPPY) * sizeof (CHAR16)) == 0) || - (CompareMem (Description, DESCRIPTION_DVD, StrLen (DESCRIPTION_DVD) * sizeof (CHAR16)) == 0) || - (CompareMem (Description, DESCRIPTION_USB, StrLen (DESCRIPTION_USB) * sizeof (CHAR16)) == 0) || - (CompareMem (Description, DESCRIPTION_SCSI, StrLen (DESCRIPTION_SCSI) * sizeof (CHAR16)) == 0) || - (CompareMem (Description, DESCRIPTION_MISC, StrLen (DESCRIPTION_MISC) * sizeof (CHAR16)) == 0) || - (CompareMem (Description, DESCRIPTION_NETWORK, StrLen (DESCRIPTION_NETWORK) * sizeof (CHAR16)) == 0)|| - (CompareMem (Description, DESCRIPTION_NON_BLOCK, StrLen (DESCRIPTION_NON_BLOCK) * sizeof (CHAR16)) == 0)) { - return TRUE; - } - - return FALSE; -} - - /** Check whether the Device path in a boot option point to a valid bootable device, And if CheckMedia is true, check the device is ready to boot now. @@ -1801,20 +1768,6 @@ BdsLibIsValidEFIBootOptDevicePathExt ( if (!EFI_ERROR (Status)) { Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo); if (!EFI_ERROR (Status)) { - if (!BlockIo->Media->RemovableMedia) { - // - // For the Fixed block devices, check its description whether conflict - // with other auto-created boot options. BDS permit a boot option point to - // Fixed block device, but not permit it use the description reserved for - // auto-created boot options. - // The check is to cover the bug, that replace a removable BlockIo device - // with a fixed BlockIo device at the same port, but the removable device's - // boot option can not be automatically deleted. - // - if (CheckDescritptionConflict (Description)) { - return FALSE; - } - } if (CheckMedia) { // // Test if it is ready to boot now diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h b/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h index c2cdcb1ab8..5193ec2d1f 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h @@ -111,21 +111,4 @@ BdsLibGetImageHeader ( OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr ); -/** - Check whether the descriptionis is conflict with the description reserved for - auto-created boot options. - - @param Description The Description in a boot option - - @retval TRUE The description is conflict with the description reserved for - auto-created boot options. - @retval FALSE The description is not conflict with the description reserved. - -**/ -BOOLEAN -EFIAPI -CheckDescritptionConflict ( - IN CHAR16 *Description - ); - #endif // _BDS_LIB_H_ diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c index 80af8e1803..af54de6926 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BootMngr/BootManager.c @@ -202,6 +202,7 @@ CallBootManager ( EFI_IFR_GUID_LABEL *StartLabel; EFI_IFR_GUID_LABEL *EndLabel; CHAR16 *BootStringNumber; + UINTN DevicePathType; gOption = NULL; InitializeListHead (&BdsBootOptionList); @@ -267,43 +268,51 @@ CallBootManager ( // // Replace description string with UNI file string. // - BootStringNumber = AllocateZeroPool (StrSize (Option->Description)); - ASSERT (BootStringNumber != NULL); + BootStringNumber = NULL; - if (StrStr (Option->Description, DESCRIPTION_FLOPPY) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_FLOPPY) + 1; + DevicePathType = BdsGetBootTypeFromDevicePath (Option->DevicePath); + + // + // store number string of boot option temporary. + // + + switch (DevicePathType) { + case BDS_EFI_ACPI_FLOPPY_BOOT: + BootStringNumber = Option->Description; Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)); - } else if (StrStr (Option->Description, DESCRIPTION_DVD) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_DVD) + 1; + break; + case BDS_EFI_MEDIA_CDROM_BOOT: + BootStringNumber = Option->Description; Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_DVD)); - - } else if (StrStr (Option->Description, DESCRIPTION_USB) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_USB) + 1; + break; + case BDS_EFI_MESSAGE_USB_DEVICE_BOOT: + BootStringNumber = Option->Description; Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)); - - } else if (StrStr (Option->Description, DESCRIPTION_SCSI) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_SCSI) + 1; + break; + case BDS_EFI_MESSAGE_SCSI_BOOT: + BootStringNumber = Option->Description; Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)); - - } else if (StrStr (Option->Description, DESCRIPTION_MISC) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_MISC) + 1; + break; + case BDS_EFI_MESSAGE_MISC_BOOT: + BootStringNumber = Option->Description; Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC)); - - } else if (StrStr (Option->Description, DESCRIPTION_NETWORK) != NULL) { - BootStringNumber = Option->Description + StrLen (DESCRIPTION_NETWORK) + 1; + break; + case BDS_EFI_MESSAGE_MAC_BOOT: + BootStringNumber = Option->Description; 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)); + break; } ASSERT (Option->Description != NULL); - if (StrnCmp (BootStringNumber, L"0", 1) != 0) { - StrCat (Option->Description, L" "); - StrCat (Option->Description, BootStringNumber); + if (BootStringNumber != NULL) { + if (StrnCmp (BootStringNumber, L"0", 1) != 0) { + StrCat (Option->Description, L" "); + StrCat (Option->Description, BootStringNumber); + } + + FreePool (BootStringNumber); } - + Token = HiiSetString (HiiHandle, 0, Option->Description, NULL); TempStr = DevicePathToStr (Option->DevicePath);