);\r
\r
\r
-///\r
-/// Define the boot option default description \r
-///\r
-#define DESCRIPTION_FLOPPY L"EFI Floppy"\r
-#define DESCRIPTION_FLOPPY_NUM L"EFI Floppy %d"\r
-#define DESCRIPTION_DVD L"EFI DVD/CDROM"\r
-#define DESCRIPTION_DVD_NUM L"EFI DVD/CDROM %d"\r
-#define DESCRIPTION_USB L"EFI USB Device"\r
-#define DESCRIPTION_USB_NUM L"EFI USB Device %d"\r
-#define DESCRIPTION_SCSI L"EFI SCSI Device"\r
-#define DESCRIPTION_SCSI_NUM L"EFI SCSI Device %d"\r
-#define DESCRIPTION_MISC L"EFI Misc Device"\r
-#define DESCRIPTION_MISC_NUM L"EFI Misc Device %d"\r
-#define DESCRIPTION_NETWORK L"EFI Network"\r
-#define DESCRIPTION_NETWORK_NUM L"EFI Network %d" \r
-#define DESCRIPTION_NON_BLOCK L"EFI Non-Block Boot Device"\r
-#define DESCRIPTION_NON_BLOCK_NUM L"EFI Non-Block Boot Device %d"\r
-\r
///\r
/// Define the boot type which to classify the boot option type\r
/// Different boot option type could have different boot behavior\r
#define BDS_EFI_MESSAGE_ATAPI_BOOT 0x0301 // Type 03; Sub-Type 01\r
#define BDS_EFI_MESSAGE_SCSI_BOOT 0x0302 // Type 03; Sub-Type 02\r
#define BDS_EFI_MESSAGE_USB_DEVICE_BOOT 0x0305 // Type 03; Sub-Type 05\r
-#define BDS_EFI_MESSAGE_SATA_BOOT 0x0318 // Type 03; Sub-Type 18\r
+#define BDS_EFI_MESSAGE_SATA_BOOT 0x0312 // Type 03; Sub-Type 18\r
+#define BDS_EFI_MESSAGE_MAC_BOOT 0x030b // Type 03; Sub-Type 11\r
#define BDS_EFI_MESSAGE_MISC_BOOT 0x03FF\r
+\r
///\r
/// Media boot type\r
/// If a device path of boot option contain a media node, the boot option is media boot type\r
\r
switch (DevicePathType) {\r
case BDS_EFI_ACPI_FLOPPY_BOOT:\r
- UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_FLOPPY_NUM, FloppyNumber); \r
+ UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", FloppyNumber); \r
BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
FloppyNumber++;\r
break;\r
//\r
case BDS_EFI_MESSAGE_ATAPI_BOOT:\r
case BDS_EFI_MESSAGE_SATA_BOOT:\r
- UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_DVD_NUM, CdromNumber);\r
+ UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", CdromNumber);\r
BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
CdromNumber++;\r
break;\r
\r
case BDS_EFI_MESSAGE_USB_DEVICE_BOOT:\r
- UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_USB_NUM, UsbNumber);\r
+ UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", UsbNumber);\r
BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer);\r
UsbNumber++;\r
break;\r
\r
case BDS_EFI_MESSAGE_SCSI_BOOT:\r
- UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_SCSI_NUM, ScsiNumber);\r
+ UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", ScsiNumber);\r
BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer); \r
ScsiNumber++;\r
break;\r
\r
case BDS_EFI_MESSAGE_MISC_BOOT:\r
- UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_MISC_NUM, MiscNumber);\r
+ UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", MiscNumber);\r
BdsLibBuildOptionFromHandle (BlockIoHandles[Index], BdsBootOptionList, Buffer); \r
MiscNumber++;\r
break;\r
//\r
BdsLibDeleteOptionFromHandle (FileSystemHandles[Index]);\r
} else {\r
- UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_NON_BLOCK_NUM, NonBlockNumber);\r
+ UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI Non-Block Boot Device %d", NonBlockNumber);\r
BdsLibBuildOptionFromHandle (FileSystemHandles[Index], BdsBootOptionList, Buffer);\r
NonBlockNumber++;\r
}\r
);\r
\r
for (Index = 0; Index < NumberSimpleNetworkHandles; Index++) {\r
- UnicodeSPrint (Buffer, sizeof (Buffer), DESCRIPTION_NETWORK_NUM, Index);\r
+ UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", Index);\r
BdsLibBuildOptionFromHandle (SimpleNetworkHandles[Index], BdsBootOptionList, Buffer);\r
}\r
\r
)\r
{\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
-\r
+ \r
DevicePath = DevicePathFromHandle (Handle);\r
\r
//\r
return BDS_EFI_MEDIA_HD_BOOT;\r
} else if (DevicePathSubType (TempDevicePath) == MEDIA_CDROM_DP) {\r
return BDS_EFI_MEDIA_CDROM_BOOT;\r
- }\r
+ } \r
break;\r
case ACPI_DEVICE_PATH:\r
Acpi = (ACPI_HID_DEVICE_PATH *) TempDevicePath;\r
return BDS_EFI_MESSAGE_SCSI_BOOT;\r
} else if (DevicePathSubType(TempDevicePath) == MSG_SATA_DP) {\r
return BDS_EFI_MESSAGE_SATA_BOOT;\r
+ } else if (DevicePathSubType(TempDevicePath) == MSG_MAC_ADDR_DP) {\r
+ return BDS_EFI_MESSAGE_MAC_BOOT;\r
}\r
return BDS_EFI_MESSAGE_MISC_BOOT;\r
default:\r
return BDS_EFI_UNSUPPORT;\r
}\r
\r
-\r
-/** \r
- Check whether the descriptionis is conflict with the description reserved for\r
- auto-created boot options.\r
-\r
- @param Description The Description in a boot option\r
- \r
- @retval TRUE The description is conflict with the description reserved for\r
- auto-created boot options.\r
- @retval FALSE The description is not conflict with the description reserved.\r
- \r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-CheckDescritptionConflict (\r
- IN CHAR16 *Description\r
- )\r
-{\r
- if (Description == NULL) {\r
- return FALSE; \r
- }\r
- if ((CompareMem (Description, DESCRIPTION_FLOPPY, StrLen (DESCRIPTION_FLOPPY) * sizeof (CHAR16)) == 0) ||\r
- (CompareMem (Description, DESCRIPTION_DVD, StrLen (DESCRIPTION_DVD) * sizeof (CHAR16)) == 0) ||\r
- (CompareMem (Description, DESCRIPTION_USB, StrLen (DESCRIPTION_USB) * sizeof (CHAR16)) == 0) ||\r
- (CompareMem (Description, DESCRIPTION_SCSI, StrLen (DESCRIPTION_SCSI) * sizeof (CHAR16)) == 0) ||\r
- (CompareMem (Description, DESCRIPTION_MISC, StrLen (DESCRIPTION_MISC) * sizeof (CHAR16)) == 0) ||\r
- (CompareMem (Description, DESCRIPTION_NETWORK, StrLen (DESCRIPTION_NETWORK) * sizeof (CHAR16)) == 0)||\r
- (CompareMem (Description, DESCRIPTION_NON_BLOCK, StrLen (DESCRIPTION_NON_BLOCK) * sizeof (CHAR16)) == 0)) { \r
- return TRUE;\r
- }\r
-\r
- return FALSE;\r
-}\r
-\r
-\r
/**\r
Check whether the Device path in a boot option point to a valid bootable device,\r
And if CheckMedia is true, check the device is ready to boot now.\r
if (!EFI_ERROR (Status)) {\r
Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);\r
if (!EFI_ERROR (Status)) {\r
- if (!BlockIo->Media->RemovableMedia) {\r
- //\r
- // For the Fixed block devices, check its description whether conflict\r
- // with other auto-created boot options. BDS permit a boot option point to \r
- // Fixed block device, but not permit it use the description reserved for\r
- // auto-created boot options.\r
- // The check is to cover the bug, that replace a removable BlockIo device\r
- // with a fixed BlockIo device at the same port, but the removable device's\r
- // boot option can not be automatically deleted.\r
- //\r
- if (CheckDescritptionConflict (Description)) {\r
- return FALSE; \r
- }\r
- } \r
if (CheckMedia) {\r
//\r
// Test if it is ready to boot now\r
EFI_IFR_GUID_LABEL *StartLabel;\r
EFI_IFR_GUID_LABEL *EndLabel;\r
CHAR16 *BootStringNumber;\r
+ UINTN DevicePathType;\r
\r
gOption = NULL;\r
InitializeListHead (&BdsBootOptionList);\r
//\r
// Replace description string with UNI file string.\r
//\r
- BootStringNumber = AllocateZeroPool (StrSize (Option->Description));\r
- ASSERT (BootStringNumber != NULL);\r
+ BootStringNumber = NULL;\r
\r
- if (StrStr (Option->Description, DESCRIPTION_FLOPPY) != NULL) {\r
- BootStringNumber = Option->Description + StrLen (DESCRIPTION_FLOPPY) + 1;\r
+ DevicePathType = BdsGetBootTypeFromDevicePath (Option->DevicePath);\r
+ \r
+ //\r
+ // store number string of boot option temporary.\r
+ //\r
+ \r
+ switch (DevicePathType) {\r
+ case BDS_EFI_ACPI_FLOPPY_BOOT:\r
+ BootStringNumber = Option->Description;\r
Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY));\r
- } else if (StrStr (Option->Description, DESCRIPTION_DVD) != NULL) {\r
- BootStringNumber = Option->Description + StrLen (DESCRIPTION_DVD) + 1;\r
+ break;\r
+ case BDS_EFI_MEDIA_CDROM_BOOT:\r
+ BootStringNumber = Option->Description;\r
Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_DVD));\r
- \r
- } else if (StrStr (Option->Description, DESCRIPTION_USB) != NULL) {\r
- BootStringNumber = Option->Description + StrLen (DESCRIPTION_USB) + 1;\r
+ break;\r
+ case BDS_EFI_MESSAGE_USB_DEVICE_BOOT:\r
+ BootStringNumber = Option->Description;\r
Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_USB));\r
- \r
- } else if (StrStr (Option->Description, DESCRIPTION_SCSI) != NULL) {\r
- BootStringNumber = Option->Description + StrLen (DESCRIPTION_SCSI) + 1;\r
+ break;\r
+ case BDS_EFI_MESSAGE_SCSI_BOOT:\r
+ BootStringNumber = Option->Description;\r
Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI));\r
- \r
- } else if (StrStr (Option->Description, DESCRIPTION_MISC) != NULL) {\r
- BootStringNumber = Option->Description + StrLen (DESCRIPTION_MISC) + 1;\r
+ break;\r
+ case BDS_EFI_MESSAGE_MISC_BOOT:\r
+ BootStringNumber = Option->Description;\r
Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_MISC));\r
- \r
- } else if (StrStr (Option->Description, DESCRIPTION_NETWORK) != NULL) {\r
- BootStringNumber = Option->Description + StrLen (DESCRIPTION_NETWORK) + 1;\r
+ break;\r
+ case BDS_EFI_MESSAGE_MAC_BOOT:\r
+ BootStringNumber = Option->Description;\r
Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_NETWORK));\r
- \r
- } else if (StrStr (Option->Description, DESCRIPTION_NON_BLOCK) != NULL) {\r
- BootStringNumber = Option->Description + StrLen (DESCRIPTION_NON_BLOCK) + 1;\r
- Option->Description = GetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK));\r
+ break;\r
}\r
\r
ASSERT (Option->Description != NULL);\r
- if (StrnCmp (BootStringNumber, L"0", 1) != 0) {\r
- StrCat (Option->Description, L" ");\r
- StrCat (Option->Description, BootStringNumber);\r
+ if (BootStringNumber != NULL) {\r
+ if (StrnCmp (BootStringNumber, L"0", 1) != 0) {\r
+ StrCat (Option->Description, L" ");\r
+ StrCat (Option->Description, BootStringNumber);\r
+ }\r
+ \r
+ FreePool (BootStringNumber);\r
}\r
- \r
+ \r
Token = HiiSetString (HiiHandle, 0, Option->Description, NULL);\r
\r
TempStr = DevicePathToStr (Option->DevicePath);\r