/** @file\r
Library functions which relate with boot option description.\r
\r
-Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#include "InternalBm.h"\r
\r
-#define VENDOR_IDENTIFICATION_OFFSET 3\r
-#define VENDOR_IDENTIFICATION_LENGTH 8\r
-#define PRODUCT_IDENTIFICATION_OFFSET 11\r
-#define PRODUCT_IDENTIFICATION_LENGTH 16\r
+#define VENDOR_IDENTIFICATION_OFFSET 3\r
+#define VENDOR_IDENTIFICATION_LENGTH 8\r
+#define PRODUCT_IDENTIFICATION_OFFSET 11\r
+#define PRODUCT_IDENTIFICATION_LENGTH 16\r
\r
-CONST UINT16 mBmUsbLangId = 0x0409; // English\r
-CHAR16 mBmUefiPrefix[] = L"UEFI ";\r
+CONST UINT16 mBmUsbLangId = 0x0409; // English\r
+CHAR16 mBmUefiPrefix[] = L"UEFI ";\r
\r
-LIST_ENTRY mPlatformBootDescriptionHandlers = INITIALIZE_LIST_HEAD_VARIABLE (mPlatformBootDescriptionHandlers);\r
+LIST_ENTRY mPlatformBootDescriptionHandlers = INITIALIZE_LIST_HEAD_VARIABLE (mPlatformBootDescriptionHandlers);\r
\r
/**\r
For a bootable Device path, return its boot type.\r
**/\r
BM_BOOT_TYPE\r
BmDevicePathType (\r
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
)\r
{\r
- EFI_DEVICE_PATH_PROTOCOL *Node;\r
- EFI_DEVICE_PATH_PROTOCOL *NextNode;\r
+ EFI_DEVICE_PATH_PROTOCOL *Node;\r
+ EFI_DEVICE_PATH_PROTOCOL *NextNode;\r
\r
ASSERT (DevicePath != NULL);\r
\r
for (Node = DevicePath; !IsDevicePathEndType (Node); Node = NextDevicePathNode (Node)) {\r
switch (DevicePathType (Node)) {\r
-\r
case ACPI_DEVICE_PATH:\r
- if (EISA_ID_TO_NUM (((ACPI_HID_DEVICE_PATH *) Node)->HID) == 0x0604) {\r
+ if (EISA_ID_TO_NUM (((ACPI_HID_DEVICE_PATH *)Node)->HID) == 0x0604) {\r
return BmAcpiFloppyBoot;\r
}\r
+\r
break;\r
\r
case HARDWARE_DEVICE_PATH:\r
if (DevicePathSubType (Node) == HW_CONTROLLER_DP) {\r
return BmHardwareDeviceBoot;\r
}\r
+\r
break;\r
\r
case MESSAGING_DEVICE_PATH:\r
do {\r
NextNode = NextDevicePathNode (NextNode);\r
} while (\r
- (DevicePathType (NextNode) == MESSAGING_DEVICE_PATH) &&\r
- (DevicePathSubType(NextNode) == MSG_DEVICE_LOGICAL_UNIT_DP)\r
- );\r
+ (DevicePathType (NextNode) == MESSAGING_DEVICE_PATH) &&\r
+ (DevicePathSubType (NextNode) == MSG_DEVICE_LOGICAL_UNIT_DP)\r
+ );\r
\r
//\r
// If the device path not only point to driver device, it is not a messaging device path,\r
}\r
\r
switch (DevicePathSubType (Node)) {\r
- case MSG_ATAPI_DP:\r
- return BmMessageAtapiBoot;\r
- break;\r
+ case MSG_ATAPI_DP:\r
+ return BmMessageAtapiBoot;\r
+ break;\r
\r
- case MSG_SATA_DP:\r
- return BmMessageSataBoot;\r
- break;\r
+ case MSG_SATA_DP:\r
+ return BmMessageSataBoot;\r
+ break;\r
\r
- case MSG_USB_DP:\r
- return BmMessageUsbBoot;\r
- break;\r
+ case MSG_USB_DP:\r
+ return BmMessageUsbBoot;\r
+ break;\r
\r
- case MSG_SCSI_DP:\r
- return BmMessageScsiBoot;\r
- break;\r
+ case MSG_SCSI_DP:\r
+ return BmMessageScsiBoot;\r
+ break;\r
}\r
}\r
}\r
**/\r
VOID\r
BmEliminateExtraSpaces (\r
- IN CHAR16 *Str\r
+ IN CHAR16 *Str\r
)\r
{\r
- UINTN Index;\r
- UINTN ActualIndex;\r
+ UINTN Index;\r
+ UINTN ActualIndex;\r
\r
for (Index = 0, ActualIndex = 0; Str[Index] != L'\0'; Index++) {\r
if ((Str[Index] != L' ') || ((ActualIndex > 0) && (Str[ActualIndex - 1] != L' '))) {\r
Str[ActualIndex++] = Str[Index];\r
}\r
}\r
+\r
Str[ActualIndex] = L'\0';\r
}\r
\r
**/\r
CHAR16 *\r
BmGetDescriptionFromDiskInfo (\r
- IN EFI_HANDLE Handle\r
+ IN EFI_HANDLE Handle\r
)\r
{\r
- UINTN Index;\r
- EFI_STATUS Status;\r
- EFI_DISK_INFO_PROTOCOL *DiskInfo;\r
- UINT32 BufferSize;\r
- EFI_ATAPI_IDENTIFY_DATA IdentifyData;\r
- EFI_SCSI_INQUIRY_DATA InquiryData;\r
- CHAR16 *Description;\r
- UINTN Length;\r
- CONST UINTN ModelNameLength = 40;\r
- CONST UINTN SerialNumberLength = 20;\r
- CHAR8 *StrPtr;\r
- UINT8 Temp;\r
-\r
- Description = NULL;\r
+ UINTN Index;\r
+ EFI_STATUS Status;\r
+ EFI_DISK_INFO_PROTOCOL *DiskInfo;\r
+ UINT32 BufferSize;\r
+ EFI_ATAPI_IDENTIFY_DATA IdentifyData;\r
+ EFI_SCSI_INQUIRY_DATA InquiryData;\r
+ CHAR16 *Description;\r
+ UINTN Length;\r
+ CONST UINTN ModelNameLength = 40;\r
+ CONST UINTN SerialNumberLength = 20;\r
+ CHAR8 *StrPtr;\r
+ UINT8 Temp;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ Description = NULL;\r
\r
Status = gBS->HandleProtocol (\r
Handle,\r
&gEfiDiskInfoProtocolGuid,\r
- (VOID **) &DiskInfo\r
+ (VOID **)&DiskInfo\r
);\r
if (EFI_ERROR (Status)) {\r
return NULL;\r
}\r
\r
if (CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoAhciInterfaceGuid) ||\r
- CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoIdeInterfaceGuid)) {\r
- BufferSize = sizeof (EFI_ATAPI_IDENTIFY_DATA);\r
- Status = DiskInfo->Identify (\r
- DiskInfo,\r
- &IdentifyData,\r
- &BufferSize\r
- );\r
+ CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoIdeInterfaceGuid))\r
+ {\r
+ BufferSize = sizeof (EFI_ATAPI_IDENTIFY_DATA);\r
+ Status = DiskInfo->Identify (\r
+ DiskInfo,\r
+ &IdentifyData,\r
+ &BufferSize\r
+ );\r
if (!EFI_ERROR (Status)) {\r
Description = AllocateZeroPool ((ModelNameLength + SerialNumberLength + 2) * sizeof (CHAR16));\r
ASSERT (Description != NULL);\r
for (Index = 0; Index + 1 < ModelNameLength; Index += 2) {\r
- Description[Index] = (CHAR16) IdentifyData.ModelName[Index + 1];\r
- Description[Index + 1] = (CHAR16) IdentifyData.ModelName[Index];\r
+ Description[Index] = (CHAR16)IdentifyData.ModelName[Index + 1];\r
+ Description[Index + 1] = (CHAR16)IdentifyData.ModelName[Index];\r
}\r
\r
- Length = Index;\r
+ Length = Index;\r
Description[Length++] = L' ';\r
\r
for (Index = 0; Index + 1 < SerialNumberLength; Index += 2) {\r
- Description[Length + Index] = (CHAR16) IdentifyData.SerialNo[Index + 1];\r
- Description[Length + Index + 1] = (CHAR16) IdentifyData.SerialNo[Index];\r
+ Description[Length + Index] = (CHAR16)IdentifyData.SerialNo[Index + 1];\r
+ Description[Length + Index + 1] = (CHAR16)IdentifyData.SerialNo[Index];\r
}\r
- Length += Index;\r
+\r
+ Length += Index;\r
Description[Length++] = L'\0';\r
ASSERT (Length == ModelNameLength + SerialNumberLength + 2);\r
\r
BmEliminateExtraSpaces (Description);\r
}\r
} else if (CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoScsiInterfaceGuid)) {\r
- BufferSize = sizeof (EFI_SCSI_INQUIRY_DATA);\r
- Status = DiskInfo->Inquiry (\r
- DiskInfo,\r
- &InquiryData,\r
- &BufferSize\r
- );\r
+ BufferSize = sizeof (EFI_SCSI_INQUIRY_DATA);\r
+ Status = DiskInfo->Inquiry (\r
+ DiskInfo,\r
+ &InquiryData,\r
+ &BufferSize\r
+ );\r
if (!EFI_ERROR (Status)) {\r
Description = AllocateZeroPool ((VENDOR_IDENTIFICATION_LENGTH + PRODUCT_IDENTIFICATION_LENGTH + 2) * sizeof (CHAR16));\r
ASSERT (Description != NULL);\r
// EFI_SCSI_INQUIRY_DATA.Reserved_5_95[11 - 26] save the product identification,\r
// Here combine the vendor identification and product identification to the description.\r
//\r
- StrPtr = (CHAR8 *) (&InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSET]);\r
- Temp = StrPtr[VENDOR_IDENTIFICATION_LENGTH];\r
+ StrPtr = (CHAR8 *)(&InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSET]);\r
+ Temp = StrPtr[VENDOR_IDENTIFICATION_LENGTH];\r
StrPtr[VENDOR_IDENTIFICATION_LENGTH] = '\0';\r
AsciiStrToUnicodeStrS (StrPtr, Description, VENDOR_IDENTIFICATION_LENGTH + 1);\r
StrPtr[VENDOR_IDENTIFICATION_LENGTH] = Temp;\r
//\r
Description[VENDOR_IDENTIFICATION_LENGTH] = L' ';\r
\r
- StrPtr = (CHAR8 *) (&InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFSET]);\r
+ StrPtr = (CHAR8 *)(&InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFSET]);\r
StrPtr[PRODUCT_IDENTIFICATION_LENGTH] = '\0';\r
AsciiStrToUnicodeStrS (StrPtr, Description + VENDOR_IDENTIFICATION_LENGTH + 1, PRODUCT_IDENTIFICATION_LENGTH + 1);\r
\r
BmEliminateExtraSpaces (Description);\r
}\r
+ } else if (CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoSdMmcInterfaceGuid)) {\r
+ DevicePath = DevicePathFromHandle (Handle);\r
+ if (DevicePath == NULL) {\r
+ return NULL;\r
+ }\r
+\r
+ while (!IsDevicePathEnd (DevicePath) && (DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH)) {\r
+ DevicePath = NextDevicePathNode (DevicePath);\r
+ }\r
+\r
+ if (IsDevicePathEnd (DevicePath)) {\r
+ return NULL;\r
+ }\r
+\r
+ if (DevicePathSubType (DevicePath) == MSG_SD_DP) {\r
+ Description = L"SD Device";\r
+ } else if (DevicePathSubType (DevicePath) == MSG_EMMC_DP) {\r
+ Description = L"eMMC Device";\r
+ } else {\r
+ return NULL;\r
+ }\r
+\r
+ Description = AllocateCopyPool (StrSize (Description), Description);\r
}\r
\r
return Description;\r
**/\r
CHAR16 *\r
BmGetUsbDescription (\r
- IN EFI_HANDLE Handle\r
+ IN EFI_HANDLE Handle\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_USB_IO_PROTOCOL *UsbIo;\r
- CHAR16 NullChar;\r
- CHAR16 *Manufacturer;\r
- CHAR16 *Product;\r
- CHAR16 *SerialNumber;\r
- CHAR16 *Description;\r
- EFI_USB_DEVICE_DESCRIPTOR DevDesc;\r
- UINTN DescMaxSize;\r
+ EFI_STATUS Status;\r
+ EFI_USB_IO_PROTOCOL *UsbIo;\r
+ CHAR16 NullChar;\r
+ CHAR16 *Manufacturer;\r
+ CHAR16 *Product;\r
+ CHAR16 *SerialNumber;\r
+ CHAR16 *Description;\r
+ EFI_USB_DEVICE_DESCRIPTOR DevDesc;\r
+ UINTN DescMaxSize;\r
\r
Status = gBS->HandleProtocol (\r
Handle,\r
&gEfiUsbIoProtocolGuid,\r
- (VOID **) &UsbIo\r
+ (VOID **)&UsbIo\r
);\r
if (EFI_ERROR (Status)) {\r
return NULL;\r
if ((Manufacturer == &NullChar) &&\r
(Product == &NullChar) &&\r
(SerialNumber == &NullChar)\r
- ) {\r
+ )\r
+ {\r
return NULL;\r
}\r
\r
DescMaxSize = StrSize (Manufacturer) + StrSize (Product) + StrSize (SerialNumber);\r
Description = AllocateZeroPool (DescMaxSize);\r
ASSERT (Description != NULL);\r
- StrCatS (Description, DescMaxSize/sizeof(CHAR16), Manufacturer);\r
- StrCatS (Description, DescMaxSize/sizeof(CHAR16), L" ");\r
+ StrCatS (Description, DescMaxSize/sizeof (CHAR16), Manufacturer);\r
+ StrCatS (Description, DescMaxSize/sizeof (CHAR16), L" ");\r
\r
- StrCatS (Description, DescMaxSize/sizeof(CHAR16), Product);\r
- StrCatS (Description, DescMaxSize/sizeof(CHAR16), L" ");\r
+ StrCatS (Description, DescMaxSize/sizeof (CHAR16), Product);\r
+ StrCatS (Description, DescMaxSize/sizeof (CHAR16), L" ");\r
\r
- StrCatS (Description, DescMaxSize/sizeof(CHAR16), SerialNumber);\r
+ StrCatS (Description, DescMaxSize/sizeof (CHAR16), SerialNumber);\r
\r
if (Manufacturer != &NullChar) {\r
FreePool (Manufacturer);\r
}\r
+\r
if (Product != &NullChar) {\r
FreePool (Product);\r
}\r
+\r
if (SerialNumber != &NullChar) {\r
FreePool (SerialNumber);\r
}\r
**/\r
CHAR16 *\r
BmGetNetworkDescription (\r
- IN EFI_HANDLE Handle\r
+ IN EFI_HANDLE Handle\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- MAC_ADDR_DEVICE_PATH *Mac;\r
- VLAN_DEVICE_PATH *Vlan;\r
- EFI_DEVICE_PATH_PROTOCOL *Ip;\r
- EFI_DEVICE_PATH_PROTOCOL *Uri;\r
- CHAR16 *Description;\r
- UINTN DescriptionSize;\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ MAC_ADDR_DEVICE_PATH *Mac;\r
+ VLAN_DEVICE_PATH *Vlan;\r
+ EFI_DEVICE_PATH_PROTOCOL *Ip;\r
+ EFI_DEVICE_PATH_PROTOCOL *Uri;\r
+ CHAR16 *Description;\r
+ UINTN DescriptionSize;\r
\r
Status = gBS->OpenProtocol (\r
Handle,\r
Status = gBS->OpenProtocol (\r
Handle,\r
&gEfiDevicePathProtocolGuid,\r
- (VOID **) &DevicePath,\r
+ (VOID **)&DevicePath,\r
gImageHandle,\r
Handle,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
// ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)\r
//\r
// The HTTP device path is like:\r
- // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)/Uri(...)\r
- // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)/Uri(...)\r
+ // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)]/Uri(...)\r
+ // ....../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]/Uri(...)\r
//\r
while (!IsDevicePathEnd (DevicePath) &&\r
((DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH) ||\r
(DevicePathSubType (DevicePath) != MSG_MAC_ADDR_DP))\r
- ) {\r
+ )\r
+ {\r
DevicePath = NextDevicePathNode (DevicePath);\r
}\r
\r
return NULL;\r
}\r
\r
- Mac = (MAC_ADDR_DEVICE_PATH *) DevicePath;\r
+ Mac = (MAC_ADDR_DEVICE_PATH *)DevicePath;\r
DevicePath = NextDevicePathNode (DevicePath);\r
\r
//\r
//\r
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&\r
(DevicePathSubType (DevicePath) == MSG_VLAN_DP)\r
- ) {\r
- Vlan = (VLAN_DEVICE_PATH *) DevicePath;\r
+ )\r
+ {\r
+ Vlan = (VLAN_DEVICE_PATH *)DevicePath;\r
DevicePath = NextDevicePathNode (DevicePath);\r
} else {\r
Vlan = NULL;\r
//\r
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&\r
(DevicePathSubType (DevicePath) == MSG_WIFI_DP)\r
- ) {\r
+ )\r
+ {\r
DevicePath = NextDevicePathNode (DevicePath);\r
}\r
\r
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&\r
((DevicePathSubType (DevicePath) == MSG_IPv4_DP) ||\r
(DevicePathSubType (DevicePath) == MSG_IPv6_DP))\r
- ) {\r
- Ip = DevicePath;\r
+ )\r
+ {\r
+ Ip = DevicePath;\r
DevicePath = NextDevicePathNode (DevicePath);\r
} else {\r
Ip = NULL;\r
}\r
\r
+ //\r
+ // Skip the optional DNS node\r
+ //\r
+ if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&\r
+ (DevicePathSubType (DevicePath) == MSG_DNS_DP)\r
+ )\r
+ {\r
+ DevicePath = NextDevicePathNode (DevicePath);\r
+ }\r
+\r
//\r
// Locate the URI node\r
//\r
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&\r
(DevicePathSubType (DevicePath) == MSG_URI_DP)\r
- ) {\r
- Uri = DevicePath;\r
+ )\r
+ {\r
+ Uri = DevicePath;\r
DevicePath = NextDevicePathNode (DevicePath);\r
} else {\r
Uri = NULL;\r
Description = AllocatePool (DescriptionSize);\r
ASSERT (Description != NULL);\r
UnicodeSPrint (\r
- Description, DescriptionSize,\r
+ Description,\r
+ DescriptionSize,\r
(Vlan == NULL) ?\r
L"%sv%d (MAC:%02x%02x%02x%02x%02x%02x)" :\r
L"%sv%d (MAC:%02x%02x%02x%02x%02x%02x VLAN%d)",\r
(Uri == NULL) ? L"PXE" : L"HTTP",\r
((Ip == NULL) || (DevicePathSubType (Ip) == MSG_IPv4_DP)) ? 4 : 6,\r
- Mac->MacAddress.Addr[0], Mac->MacAddress.Addr[1], Mac->MacAddress.Addr[2],\r
- Mac->MacAddress.Addr[3], Mac->MacAddress.Addr[4], Mac->MacAddress.Addr[5],\r
+ Mac->MacAddress.Addr[0],\r
+ Mac->MacAddress.Addr[1],\r
+ Mac->MacAddress.Addr[2],\r
+ Mac->MacAddress.Addr[3],\r
+ Mac->MacAddress.Addr[4],\r
+ Mac->MacAddress.Addr[5],\r
(Vlan == NULL) ? 0 : Vlan->VlanId\r
);\r
return Description;\r
**/\r
CHAR16 *\r
BmGetLoadFileDescription (\r
- IN EFI_HANDLE Handle\r
+ IN EFI_HANDLE Handle\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_DEVICE_PATH_PROTOCOL *FilePath;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;\r
- CHAR16 *Description;\r
- EFI_LOAD_FILE_PROTOCOL *LoadFile;\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *FilePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;\r
+ CHAR16 *Description;\r
+ EFI_LOAD_FILE_PROTOCOL *LoadFile;\r
\r
Status = gBS->HandleProtocol (Handle, &gEfiLoadFileProtocolGuid, (VOID **)&LoadFile);\r
if (EFI_ERROR (Status)) {\r
// Get the file name\r
//\r
Description = NULL;\r
- Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&FilePath);\r
+ Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&FilePath);\r
if (!EFI_ERROR (Status)) {\r
DevicePathNode = FilePath;\r
while (!IsDevicePathEnd (DevicePathNode)) {\r
- if (DevicePathNode->Type == MEDIA_DEVICE_PATH && DevicePathNode->SubType == MEDIA_FILEPATH_DP) {\r
+ if ((DevicePathNode->Type == MEDIA_DEVICE_PATH) && (DevicePathNode->SubType == MEDIA_FILEPATH_DP)) {\r
Description = (CHAR16 *)(DevicePathNode + 1);\r
break;\r
}\r
+\r
DevicePathNode = NextDevicePathNode (DevicePathNode);\r
}\r
}\r
**/\r
CHAR16 *\r
BmGetNvmeDescription (\r
- IN EFI_HANDLE Handle\r
+ IN EFI_HANDLE Handle\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *NvmePassthru;\r
- EFI_DEV_PATH_PTR DevicePath;\r
- EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;\r
- EFI_NVM_EXPRESS_COMMAND Command;\r
- EFI_NVM_EXPRESS_COMPLETION Completion;\r
- NVME_ADMIN_CONTROLLER_DATA ControllerData;\r
- CHAR16 *Description;\r
- CHAR16 *Char;\r
- UINTN Index;\r
-\r
- Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **) &DevicePath.DevPath);\r
+ EFI_STATUS Status;\r
+ EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *NvmePassthru;\r
+ EFI_DEV_PATH_PTR DevicePath;\r
+ EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;\r
+ EFI_NVM_EXPRESS_COMMAND Command;\r
+ EFI_NVM_EXPRESS_COMPLETION Completion;\r
+ NVME_ADMIN_CONTROLLER_DATA ControllerData;\r
+ CHAR16 *Description;\r
+ CHAR16 *Char;\r
+ UINTN Index;\r
+\r
+ Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath.DevPath);\r
if (EFI_ERROR (Status)) {\r
return NULL;\r
}\r
Status = gBS->LocateDevicePath (&gEfiNvmExpressPassThruProtocolGuid, &DevicePath.DevPath, &Handle);\r
if (EFI_ERROR (Status) ||\r
(DevicePathType (DevicePath.DevPath) != MESSAGING_DEVICE_PATH) ||\r
- (DevicePathSubType (DevicePath.DevPath) != MSG_NVME_NAMESPACE_DP)) {\r
+ (DevicePathSubType (DevicePath.DevPath) != MSG_NVME_NAMESPACE_DP))\r
+ {\r
//\r
// Do not return description when the Handle is not a child of NVME controller.\r
//\r
//\r
// Send ADMIN_IDENTIFY command to NVME controller to get the model and serial number.\r
//\r
- Status = gBS->HandleProtocol (Handle, &gEfiNvmExpressPassThruProtocolGuid, (VOID **) &NvmePassthru);\r
+ Status = gBS->HandleProtocol (Handle, &gEfiNvmExpressPassThruProtocolGuid, (VOID **)&NvmePassthru);\r
ASSERT_EFI_ERROR (Status);\r
\r
- ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));\r
- ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));\r
- ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));\r
+ ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));\r
+ ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));\r
+ ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));\r
\r
Command.Cdw0.Opcode = NVME_ADMIN_IDENTIFY_CMD;\r
//\r
// According to Nvm Express 1.1 spec Figure 38, When not used, the field shall be cleared to 0h.\r
// For the Identify command, the Namespace Identifier is only used for the Namespace data structure.\r
//\r
- Command.Nsid = 0;\r
+ Command.Nsid = 0;\r
CommandPacket.NvmeCmd = &Command;\r
CommandPacket.NvmeCompletion = &Completion;\r
CommandPacket.TransferBuffer = &ControllerData;\r
//\r
// Set bit 0 (Cns bit) to 1 to identify a controller\r
//\r
- Command.Cdw10 = 1;\r
- Command.Flags = CDW10_VALID;\r
+ Command.Cdw10 = 1;\r
+ Command.Flags = CDW10_VALID;\r
\r
Status = NvmePassthru->PassThru (\r
- NvmePassthru,\r
- 0,\r
- &CommandPacket,\r
- NULL\r
- );\r
+ NvmePassthru,\r
+ 0,\r
+ &CommandPacket,\r
+ NULL\r
+ );\r
if (EFI_ERROR (Status)) {\r
return NULL;\r
}\r
(ARRAY_SIZE (ControllerData.Mn) + 1\r
+ ARRAY_SIZE (ControllerData.Sn) + 1\r
+ MAXIMUM_VALUE_CHARACTERS + 1\r
- ) * sizeof (CHAR16));\r
+ ) * sizeof (CHAR16)\r
+ );\r
if (Description != NULL) {\r
Char = Description;\r
for (Index = 0; Index < ARRAY_SIZE (ControllerData.Mn); Index++) {\r
- *(Char++) = (CHAR16) ControllerData.Mn[Index];\r
+ *(Char++) = (CHAR16)ControllerData.Mn[Index];\r
}\r
+\r
*(Char++) = L' ';\r
for (Index = 0; Index < ARRAY_SIZE (ControllerData.Sn); Index++) {\r
- *(Char++) = (CHAR16) ControllerData.Sn[Index];\r
+ *(Char++) = (CHAR16)ControllerData.Sn[Index];\r
}\r
+\r
*(Char++) = L' ';\r
UnicodeValueToStringS (\r
- Char, sizeof (CHAR16) * (MAXIMUM_VALUE_CHARACTERS + 1),\r
- 0, DevicePath.NvmeNamespace->NamespaceId, 0\r
+ Char,\r
+ sizeof (CHAR16) * (MAXIMUM_VALUE_CHARACTERS + 1),\r
+ 0,\r
+ DevicePath.NvmeNamespace->NamespaceId,\r
+ 0\r
);\r
BmEliminateExtraSpaces (Description);\r
}\r
**/\r
CHAR16 *\r
BmGetMiscDescription (\r
- IN EFI_HANDLE Handle\r
+ IN EFI_HANDLE Handle\r
)\r
{\r
- EFI_STATUS Status;\r
- CHAR16 *Description;\r
- EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;\r
+ EFI_STATUS Status;\r
+ CHAR16 *Description;\r
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;\r
\r
switch (BmDevicePathType (DevicePathFromHandle (Handle))) {\r
- case BmAcpiFloppyBoot:\r
- Description = L"Floppy";\r
- break;\r
-\r
- case BmMessageAtapiBoot:\r
- case BmMessageSataBoot:\r
- Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);\r
- ASSERT_EFI_ERROR (Status);\r
- //\r
- // Assume a removable SATA device should be the DVD/CD device\r
- //\r
- Description = BlockIo->Media->RemovableMedia ? L"DVD/CDROM" : L"Hard Drive";\r
- break;\r
+ case BmAcpiFloppyBoot:\r
+ Description = L"Floppy";\r
+ break;\r
\r
- case BmMessageUsbBoot:\r
- Description = L"USB Device";\r
- break;\r
+ case BmMessageAtapiBoot:\r
+ case BmMessageSataBoot:\r
+ Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);\r
+ ASSERT_EFI_ERROR (Status);\r
+ //\r
+ // Assume a removable SATA device should be the DVD/CD device\r
+ //\r
+ Description = BlockIo->Media->RemovableMedia ? L"DVD/CDROM" : L"Hard Drive";\r
+ break;\r
\r
- case BmMessageScsiBoot:\r
- Description = L"SCSI Device";\r
- break;\r
+ case BmMessageUsbBoot:\r
+ Description = L"USB Device";\r
+ break;\r
\r
- case BmHardwareDeviceBoot:\r
- Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);\r
- if (!EFI_ERROR (Status)) {\r
- Description = BlockIo->Media->RemovableMedia ? L"Removable Disk" : L"Hard Drive";\r
- } else {\r
- Description = L"Misc Device";\r
- }\r
- break;\r
+ case BmMessageScsiBoot:\r
+ Description = L"SCSI Device";\r
+ break;\r
\r
- default:\r
- Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **) &Fs);\r
- if (!EFI_ERROR (Status)) {\r
- Description = L"Non-Block Boot Device";\r
- } else {\r
- Description = L"Misc Device";\r
- }\r
- break;\r
+ case BmHardwareDeviceBoot:\r
+ Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);\r
+ if (!EFI_ERROR (Status)) {\r
+ Description = BlockIo->Media->RemovableMedia ? L"Removable Disk" : L"Hard Drive";\r
+ } else {\r
+ Description = L"Misc Device";\r
+ }\r
+\r
+ break;\r
+\r
+ default:\r
+ Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);\r
+ if (!EFI_ERROR (Status)) {\r
+ Description = L"Non-Block Boot Device";\r
+ } else {\r
+ Description = L"Misc Device";\r
+ }\r
+\r
+ break;\r
}\r
\r
return AllocateCopyPool (StrSize (Description), Description);\r
IN EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER Handler\r
)\r
{\r
- LIST_ENTRY *Link;\r
- BM_BOOT_DESCRIPTION_ENTRY *Entry;\r
+ LIST_ENTRY *Link;\r
+ BM_BOOT_DESCRIPTION_ENTRY *Entry;\r
\r
for ( Link = GetFirstNode (&mPlatformBootDescriptionHandlers)\r
- ; !IsNull (&mPlatformBootDescriptionHandlers, Link)\r
- ; Link = GetNextNode (&mPlatformBootDescriptionHandlers, Link)\r
- ) {\r
+ ; !IsNull (&mPlatformBootDescriptionHandlers, Link)\r
+ ; Link = GetNextNode (&mPlatformBootDescriptionHandlers, Link)\r
+ )\r
+ {\r
Entry = CR (Link, BM_BOOT_DESCRIPTION_ENTRY, Link, BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE);\r
if (Entry->Handler == Handler) {\r
return EFI_ALREADY_STARTED;\r
return EFI_SUCCESS;\r
}\r
\r
-BM_GET_BOOT_DESCRIPTION mBmBootDescriptionHandlers[] = {\r
+BM_GET_BOOT_DESCRIPTION mBmBootDescriptionHandlers[] = {\r
BmGetUsbDescription,\r
BmGetDescriptionFromDiskInfo,\r
BmGetNetworkDescription,\r
**/\r
CHAR16 *\r
BmGetBootDescription (\r
- IN EFI_HANDLE Handle\r
+ IN EFI_HANDLE Handle\r
)\r
{\r
- LIST_ENTRY *Link;\r
- BM_BOOT_DESCRIPTION_ENTRY *Entry;\r
- CHAR16 *Description;\r
- CHAR16 *DefaultDescription;\r
- CHAR16 *Temp;\r
- UINTN Index;\r
+ LIST_ENTRY *Link;\r
+ BM_BOOT_DESCRIPTION_ENTRY *Entry;\r
+ CHAR16 *Description;\r
+ CHAR16 *DefaultDescription;\r
+ CHAR16 *Temp;\r
+ UINTN Index;\r
\r
//\r
// Firstly get the default boot description\r
//\r
DefaultDescription = NULL;\r
for (Index = 0; Index < ARRAY_SIZE (mBmBootDescriptionHandlers); Index++) {\r
- DefaultDescription = mBmBootDescriptionHandlers[Index] (Handle);\r
+ DefaultDescription = mBmBootDescriptionHandlers[Index](Handle);\r
if (DefaultDescription != NULL) {\r
//\r
// Avoid description confusion between UEFI & Legacy boot option by adding "UEFI " prefix\r
break;\r
}\r
}\r
+\r
ASSERT (DefaultDescription != NULL);\r
\r
//\r
// Secondly query platform for the better boot description\r
//\r
for ( Link = GetFirstNode (&mPlatformBootDescriptionHandlers)\r
- ; !IsNull (&mPlatformBootDescriptionHandlers, Link)\r
- ; Link = GetNextNode (&mPlatformBootDescriptionHandlers, Link)\r
- ) {\r
- Entry = CR (Link, BM_BOOT_DESCRIPTION_ENTRY, Link, BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE);\r
+ ; !IsNull (&mPlatformBootDescriptionHandlers, Link)\r
+ ; Link = GetNextNode (&mPlatformBootDescriptionHandlers, Link)\r
+ )\r
+ {\r
+ Entry = CR (Link, BM_BOOT_DESCRIPTION_ENTRY, Link, BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE);\r
Description = Entry->Handler (Handle, DefaultDescription);\r
if (Description != NULL) {\r
FreePool (DefaultDescription);\r
**/\r
VOID\r
BmMakeBootOptionDescriptionUnique (\r
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,\r
- UINTN BootOptionCount\r
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,\r
+ UINTN BootOptionCount\r
)\r
{\r
- UINTN Base;\r
- UINTN Index;\r
- UINTN DescriptionSize;\r
- UINTN MaxSuffixSize;\r
- BOOLEAN *Visited;\r
- UINTN MatchCount;\r
+ UINTN Base;\r
+ UINTN Index;\r
+ UINTN DescriptionSize;\r
+ UINTN MaxSuffixSize;\r
+ BOOLEAN *Visited;\r
+ UINTN MatchCount;\r
\r
if (BootOptionCount == 0) {\r
return;\r
Visited[Base] = TRUE;\r
DescriptionSize = StrSize (BootOptions[Base].Description);\r
for (Index = Base + 1; Index < BootOptionCount; Index++) {\r
- if (!Visited[Index] && StrCmp (BootOptions[Base].Description, BootOptions[Index].Description) == 0) {\r
+ if (!Visited[Index] && (StrCmp (BootOptions[Base].Description, BootOptions[Index].Description) == 0)) {\r
Visited[Index] = TRUE;\r
MatchCount++;\r
FreePool (BootOptions[Index].Description);\r
BootOptions[Index].Description = AllocatePool (DescriptionSize + MaxSuffixSize);\r
UnicodeSPrint (\r
- BootOptions[Index].Description, DescriptionSize + MaxSuffixSize,\r
+ BootOptions[Index].Description,\r
+ DescriptionSize + MaxSuffixSize,\r
L"%s %d",\r
- BootOptions[Base].Description, MatchCount\r
+ BootOptions[Base].Description,\r
+ MatchCount\r
);\r
}\r
}\r