12#define VENDOR_IDENTIFICATION_OFFSET 3
13#define VENDOR_IDENTIFICATION_LENGTH 8
14#define PRODUCT_IDENTIFICATION_OFFSET 11
15#define PRODUCT_IDENTIFICATION_LENGTH 16
17CONST UINT16 mBmUsbLangId = 0x0409;
18CHAR16 mBmUefiPrefix[] = L
"UEFI ";
20CHAR16 mBootDescGenericManufacturer[] = L
"Generic";
21CHAR16 mBootDescSd[] = L
"SD Device";
22CHAR16 mBootDescEmmc[] = L
"eMMC Device";
23CHAR16 mBootDescEmmcUserData[] = L
"eMMC User Data";
24CHAR16 mBootDescEmmcBoot1[] = L
"eMMC Boot 1";
25CHAR16 mBootDescEmmcBoot2[] = L
"eMMC Boot 2";
26CHAR16 mBootDescEmmcGp1[] = L
"eMMC GP 1";
27CHAR16 mBootDescEmmcGp2[] = L
"eMMC GP 2";
28CHAR16 mBootDescEmmcGp3[] = L
"eMMC GP 3";
29CHAR16 mBootDescEmmcGp4[] = L
"eMMC GP 4";
37 { 0x01, L
"Panasonic" },
38 { 0x02, L
"Toshiba/Kingston/Viking" },
40 { 0x08, L
"Silicon Power" },
41 { 0x18, L
"Infineon" },
42 { 0x1b, L
"Transcend/Samsung" },
43 { 0x1c, L
"Transcend" },
44 { 0x1d, L
"Corsair/AData" },
45 { 0x1e, L
"Transcend" },
46 { 0x1f, L
"Kingston" },
47 { 0x27, L
"Delkin/Phison" },
50 { 0x31, L
"Silicon Power" },
51 { 0x33, L
"STMicroelectronics" },
52 { 0x41, L
"Kingston" },
53 { 0x6f, L
"STMicroelectronics" },
54 { 0x74, L
"Transcend" },
56 { 0x82, L
"Gobe/Sony" },
57 { 0x9c, L
"Angelbird/Hoodman" },
62 { 0x02, L
"Kingston/SanDisk" },
70 { 0x2c, L
"Kingston" },
71 { 0x70, L
"Kingston" },
106 ASSERT (DevicePath !=
NULL);
112 return BmAcpiFloppyBoot;
119 return BmHardwareDeviceBoot;
145 return BmMessageAtapiBoot;
149 return BmMessageSataBoot;
153 return BmMessageUsbBoot;
157 return BmMessageScsiBoot;
179 for (Index = 0, ActualIndex = 0; Str[Index] != L
'\0'; Index++) {
180 if ((Str[Index] != L
' ') || ((ActualIndex > 0) && (Str[ActualIndex - 1] != L
' '))) {
181 Str[ActualIndex++] = Str[Index];
185 Str[ActualIndex] = L
'\0';
205 for (Index = 0; Index < Count; ++Index) {
206 Temp = Source[Index];
207 Source[Index] = Source[Length - 1 - Index];
208 Source[Length - 1 - Index] = Temp;
230 List = IsMmc ? mMmcManufacturers : mSdManufacturers;
231 Count = IsMmc ?
ARRAY_SIZE (mMmcManufacturers)
234 for (Index = 0; Index < Count; ++Index) {
235 if (List[Index].Id == Id) {
236 return List[Index].Name;
240 return mBootDescGenericManufacturer;
256 case EmmcPartitionUserData:
257 return mBootDescEmmcUserData;
258 case EmmcPartitionBoot1:
259 return mBootDescEmmcBoot1;
260 case EmmcPartitionBoot2:
261 return mBootDescEmmcBoot2;
262 case EmmcPartitionGP1:
263 return mBootDescEmmcGp1;
264 case EmmcPartitionGP2:
265 return mBootDescEmmcGp2;
266 case EmmcPartitionGP3:
267 return mBootDescEmmcGp3;
268 case EmmcPartitionGP4:
269 return mBootDescEmmcGp4;
274 return mBootDescEmmc;
290 IN CHAR16 *ManufacturerName,
291 IN UINT8 *ProductName,
292 IN UINT8 ProductNameLength,
293 IN UINT8 SerialNumber[4],
294 IN CHAR16 *DeviceType
300 DescSize =
StrSize (ManufacturerName) -
sizeof (CHAR16)
302 + ProductNameLength *
sizeof (CHAR16)
304 +
sizeof (UINT32) * 2 *
sizeof (CHAR16)
318 L
"%s %.*a %02x%02x%02x%02x %s",
362 Status =
gBS->HandleProtocol (
364 &gEfiDiskInfoProtocolGuid,
367 if (EFI_ERROR (Status)) {
380 if (!EFI_ERROR (Status)) {
381 Description =
AllocateZeroPool ((ModelNameLength + SerialNumberLength + 2) *
sizeof (CHAR16));
382 ASSERT (Description !=
NULL);
383 for (Index = 0; Index + 1 < ModelNameLength; Index += 2) {
384 Description[Index] = (CHAR16)IdentifyData.
ModelName[Index + 1];
385 Description[Index + 1] = (CHAR16)IdentifyData.
ModelName[Index];
389 Description[Length++] = L
' ';
391 for (Index = 0; Index + 1 < SerialNumberLength; Index += 2) {
392 Description[Length + Index] = (CHAR16)IdentifyData.
SerialNo[Index + 1];
393 Description[Length + Index + 1] = (CHAR16)IdentifyData.
SerialNo[Index];
397 Description[Length++] = L
'\0';
398 ASSERT (Length == ModelNameLength + SerialNumberLength + 2);
411 if (!EFI_ERROR (Status)) {
412 Description =
AllocateZeroPool ((VENDOR_IDENTIFICATION_LENGTH + PRODUCT_IDENTIFICATION_LENGTH + 2) *
sizeof (CHAR16));
413 ASSERT (Description !=
NULL);
420 StrPtr = (CHAR8 *)(&InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSET]);
421 Temp = StrPtr[VENDOR_IDENTIFICATION_LENGTH];
422 StrPtr[VENDOR_IDENTIFICATION_LENGTH] =
'\0';
424 StrPtr[VENDOR_IDENTIFICATION_LENGTH] = Temp;
429 Description[VENDOR_IDENTIFICATION_LENGTH] = L
' ';
431 StrPtr = (CHAR8 *)(&InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFSET]);
432 StrPtr[PRODUCT_IDENTIFICATION_LENGTH] =
'\0';
433 AsciiStrToUnicodeStrS (StrPtr, Description + VENDOR_IDENTIFICATION_LENGTH + 1, PRODUCT_IDENTIFICATION_LENGTH + 1);
439 if (DevicePath ==
NULL) {
452 BufferSize =
sizeof (
SD_CID);
453 Status = DiskInfo->
Inquiry (DiskInfo, &SdCid, &BufferSize);
454 if (EFI_ERROR (Status)) {
462 SdCid.ProductSerialNumber,
467 Status = DiskInfo->
Inquiry (DiskInfo, &EmmcCid, &BufferSize);
468 if (EFI_ERROR (Status)) {
472 Description = mBootDescEmmc;
483 EmmcCid.ProductSerialNumber,
511 CHAR16 *Manufacturer;
513 CHAR16 *SerialNumber;
518 Status =
gBS->HandleProtocol (
520 &gEfiUsbIoProtocolGuid,
523 if (EFI_ERROR (Status)) {
529 Status = UsbIo->UsbGetDeviceDescriptor (UsbIo, &DevDesc);
530 if (EFI_ERROR (Status)) {
534 Status = UsbIo->UsbGetStringDescriptor (
537 DevDesc.StrManufacturer,
540 if (EFI_ERROR (Status)) {
541 Manufacturer = &NullChar;
544 Status = UsbIo->UsbGetStringDescriptor (
550 if (EFI_ERROR (Status)) {
554 Status = UsbIo->UsbGetStringDescriptor (
557 DevDesc.StrSerialNumber,
560 if (EFI_ERROR (Status)) {
561 SerialNumber = &NullChar;
564 if ((Manufacturer == &NullChar) &&
565 (Product == &NullChar) &&
566 (SerialNumber == &NullChar)
574 ASSERT (Description !=
NULL);
575 StrCatS (Description, DescMaxSize/
sizeof (CHAR16), Manufacturer);
576 StrCatS (Description, DescMaxSize/
sizeof (CHAR16), L
" ");
578 StrCatS (Description, DescMaxSize/
sizeof (CHAR16), Product);
579 StrCatS (Description, DescMaxSize/
sizeof (CHAR16), L
" ");
581 StrCatS (Description, DescMaxSize/
sizeof (CHAR16), SerialNumber);
583 if (Manufacturer != &NullChar) {
587 if (Product != &NullChar) {
591 if (SerialNumber != &NullChar) {
619 UINTN DescriptionSize;
621 Status =
gBS->OpenProtocol (
623 &gEfiLoadFileProtocolGuid,
627 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
629 if (EFI_ERROR (Status)) {
633 Status =
gBS->OpenProtocol (
635 &gEfiDevicePathProtocolGuid,
636 (VOID **)&DevicePath,
639 EFI_OPEN_PROTOCOL_GET_PROTOCOL
641 if (EFI_ERROR (Status) || (DevicePath ==
NULL)) {
735 DescriptionSize =
sizeof (L
"HTTPv6 (MAC:112233445566 VLAN65535)");
737 ASSERT (Description !=
NULL);
742 L
"%sv%d (MAC:%02x%02x%02x%02x%02x%02x)" :
743 L
"%sv%d (MAC:%02x%02x%02x%02x%02x%02x VLAN%d)",
744 (Uri ==
NULL) ? L
"PXE" : L
"HTTP",
775 Status =
gBS->HandleProtocol (Handle, &gEfiLoadFileProtocolGuid, (VOID **)&LoadFile);
776 if (EFI_ERROR (Status)) {
784 Status =
gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&FilePath);
785 if (!EFI_ERROR (Status)) {
786 DevicePathNode = FilePath;
789 Description = (CHAR16 *)(DevicePathNode + 1);
797 if (Description !=
NULL) {
827 Status =
gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath.DevPath);
828 if (EFI_ERROR (Status)) {
832 Status =
gBS->LocateDevicePath (&gEfiNvmExpressPassThruProtocolGuid, &DevicePath.DevPath, &Handle);
833 if (EFI_ERROR (Status) ||
846 Status =
gBS->HandleProtocol (Handle, &gEfiNvmExpressPassThruProtocolGuid, (VOID **)&NvmePassthru);
853 Command.Cdw0.Opcode = NVME_ADMIN_IDENTIFY_CMD;
859 CommandPacket.NvmeCmd = &Command;
860 CommandPacket.NvmeCompletion = &Completion;
861 CommandPacket.TransferBuffer = &ControllerData;
862 CommandPacket.TransferLength =
sizeof (ControllerData);
864 CommandPacket.QueueType = NVME_ADMIN_QUEUE;
869 Command.Flags = CDW10_VALID;
871 Status = NvmePassthru->PassThru (
877 if (EFI_ERROR (Status)) {
887 if (Description !=
NULL) {
889 for (Index = 0; Index <
ARRAY_SIZE (ControllerData.Mn); Index++) {
890 *(Char++) = (CHAR16)ControllerData.Mn[Index];
894 for (Index = 0; Index <
ARRAY_SIZE (ControllerData.Sn); Index++) {
895 *(Char++) = (CHAR16)ControllerData.Sn[Index];
903 DevicePath.NvmeNamespace->NamespaceId,
930 case BmAcpiFloppyBoot:
931 Description = L
"Floppy";
934 case BmMessageAtapiBoot:
935 case BmMessageSataBoot:
936 Status =
gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
941 Description = BlockIo->Media->RemovableMedia ? L
"DVD/CDROM" : L
"Hard Drive";
944 case BmMessageUsbBoot:
945 Description = L
"USB Device";
948 case BmMessageScsiBoot:
949 Description = L
"SCSI Device";
952 case BmHardwareDeviceBoot:
953 Status =
gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
954 if (!EFI_ERROR (Status)) {
955 Description = BlockIo->Media->RemovableMedia ? L
"Removable Disk" : L
"Hard Drive";
957 Description = L
"Misc Device";
963 Status =
gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
964 if (!EFI_ERROR (Status)) {
965 Description = L
"Non-Block Boot Device";
967 Description = L
"Misc Device";
994 for ( Link =
GetFirstNode (&mPlatformBootDescriptionHandlers)
995 ; !
IsNull (&mPlatformBootDescriptionHandlers, Link)
996 ; Link =
GetNextNode (&mPlatformBootDescriptionHandlers, Link)
1000 if (Entry->Handler == Handler) {
1001 return EFI_ALREADY_STARTED;
1006 if (Entry ==
NULL) {
1007 return EFI_OUT_OF_RESOURCES;
1010 Entry->Signature = BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE;
1011 Entry->Handler = Handler;
1012 InsertTailList (&mPlatformBootDescriptionHandlers, &Entry->Link);
1016BM_GET_BOOT_DESCRIPTION mBmBootDescriptionHandlers[] = {
1039 CHAR16 *Description;
1040 CHAR16 *DefaultDescription;
1047 DefaultDescription =
NULL;
1048 for (Index = 0; Index <
ARRAY_SIZE (mBmBootDescriptionHandlers); Index++) {
1049 DefaultDescription = mBmBootDescriptionHandlers[Index](Handle);
1050 if (DefaultDescription !=
NULL) {
1056 ASSERT (Temp !=
NULL);
1057 StrCpyS (Temp, (
StrSize (DefaultDescription) +
sizeof (mBmUefiPrefix)) /
sizeof (CHAR16), mBmUefiPrefix);
1058 StrCatS (Temp, (
StrSize (DefaultDescription) +
sizeof (mBmUefiPrefix)) /
sizeof (CHAR16), DefaultDescription);
1060 DefaultDescription = Temp;
1065 ASSERT (DefaultDescription !=
NULL);
1070 for ( Link =
GetFirstNode (&mPlatformBootDescriptionHandlers)
1071 ; !
IsNull (&mPlatformBootDescriptionHandlers, Link)
1072 ; Link =
GetNextNode (&mPlatformBootDescriptionHandlers, Link)
1076 Description = Entry->Handler (Handle, DefaultDescription);
1077 if (Description !=
NULL) {
1083 return DefaultDescription;
1096 UINTN BootOptionCount
1101 UINTN DescriptionSize;
1102 UINTN MaxSuffixSize;
1106 if (BootOptionCount == 0) {
1114 MaxSuffixSize =
sizeof (CHAR16);
1115 for (Index = BootOptionCount; Index != 0; Index = Index / 10) {
1116 MaxSuffixSize +=
sizeof (CHAR16);
1120 ASSERT (Visited !=
NULL);
1122 for (Base = 0; Base < BootOptionCount; Base++) {
1123 if (!Visited[Base]) {
1125 Visited[Base] =
TRUE;
1126 DescriptionSize =
StrSize (BootOptions[Base].Description);
1127 for (Index = Base + 1; Index < BootOptionCount; Index++) {
1128 if (!Visited[Index] && (
StrCmp (BootOptions[Base].Description, BootOptions[Index].Description) == 0)) {
1129 Visited[Index] =
TRUE;
1131 FreePool (BootOptions[Index].Description);
1132 BootOptions[Index].Description =
AllocatePool (DescriptionSize + MaxSuffixSize);
1134 BootOptions[Index].Description,
1135 DescriptionSize + MaxSuffixSize,
1137 BootOptions[Base].Description,
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
RETURN_STATUS EFIAPI StrCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)
RETURN_STATUS EFIAPI AsciiStrToUnicodeStrS(IN CONST CHAR8 *Source, OUT CHAR16 *Destination, IN UINTN DestMax)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
CHAR16 * BmGetNvmeDescription(IN EFI_HANDLE Handle)
VOID BmMakeBootOptionDescriptionUnique(EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions, UINTN BootOptionCount)
CHAR16 * BmGetSdMmcManufacturerName(IN UINT8 Id, IN BOOLEAN IsMmc)
CHAR16 * BmGetLoadFileDescription(IN EFI_HANDLE Handle)
CHAR16 * BmGetEmmcTypeDescription(CONTROLLER_DEVICE_PATH *DevicePath)
CHAR16 * BmGetNetworkDescription(IN EFI_HANDLE Handle)
CHAR16 * BmGetUsbDescription(IN EFI_HANDLE Handle)
CHAR16 * BmGetSdMmcDescription(IN CHAR16 *ManufacturerName, IN UINT8 *ProductName, IN UINT8 ProductNameLength, IN UINT8 SerialNumber[4], IN CHAR16 *DeviceType)
CHAR16 * BmGetBootDescription(IN EFI_HANDLE Handle)
BM_BOOT_TYPE BmDevicePathType(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
CHAR16 * BmGetDescriptionFromDiskInfo(IN EFI_HANDLE Handle)
VOID BmEliminateExtraSpaces(IN CHAR16 *Str)
CHAR16 * BmGetMiscDescription(IN EFI_HANDLE Handle)
EFI_STATUS EFIAPI EfiBootManagerRegisterBootDescriptionHandler(IN EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER Handler)
VOID BmSwapBytes(IN UINT8 *Source, IN UINTN Length)
#define MEDIA_FILEPATH_DP
#define HARDWARE_DEVICE_PATH
#define MSG_DEVICE_LOGICAL_UNIT_DP
#define MSG_NVME_NAMESPACE_DP
#define MESSAGING_DEVICE_PATH
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
BOOLEAN EFIAPI IsDevicePathEndType(IN CONST VOID *Node)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
RETURN_STATUS EFIAPI UnicodeValueToStringS(IN OUT CHAR16 *Buffer, IN UINTN BufferSize, IN UINTN Flags, IN INT64 Value, IN UINTN Width)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
#define ARRAY_SIZE(Array)
#define ASSERT_EFI_ERROR(StatusParameter)
#define CR(Record, TYPE, Field, TestSignature)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
#define MAXIMUM_VALUE_CHARACTERS
CHAR16 *(EFIAPI * EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER)(IN EFI_HANDLE Handle, IN CONST CHAR16 *DefaultDescription)
#define EFI_TIMER_PERIOD_SECONDS(Seconds)
EFI_DISK_INFO_INQUIRY Inquiry
EFI_DISK_INFO_IDENTIFY Identify
CHAR8 SerialNo[20]
word 10~19
CHAR8 ModelName[40]
word 27~46
EFI_MAC_ADDRESS MacAddress