]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLib / DevicePathToText.c
index 0774fd8c17a4b24d3c3ce1d7099d2250058925c0..7d8d304f6f00050daf626c723abd027b47f7b2eb 100644 (file)
@@ -2,7 +2,7 @@
   DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
 \r
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
-Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<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
@@ -42,6 +42,7 @@ UefiDevicePathLibCatPrint (
 \r
   VA_START (Args, Fmt);\r
   Count = SPrintLength (Fmt, Args);\r
+  VA_END(Args);\r
 \r
   if ((Str->Count + (Count + 1)) * sizeof (CHAR16) > Str->Capacity) {\r
     Str->Capacity = (Str->Count + (Count + 1) * 2) * sizeof (CHAR16);\r
@@ -52,9 +53,10 @@ UefiDevicePathLibCatPrint (
                  );\r
     ASSERT (Str->Str != NULL);\r
   }\r
+  VA_START (Args, Fmt);\r
   UnicodeVSPrint (&Str->Str[Str->Count], Str->Capacity - Str->Count * sizeof (CHAR16), Fmt, Args);\r
   Str->Count += Count;\r
-  \r
+\r
   VA_END (Args);\r
   return Str->Str;\r
 }\r
@@ -433,7 +435,7 @@ DevPathToTextAcpiEx (
 \r
   //\r
   // Converts EISA identification to string.\r
-  // \r
+  //\r
   UnicodeSPrint (\r
     HIDText,\r
     sizeof (HIDText),\r
@@ -822,6 +824,37 @@ DevPathToTextSd (
     );\r
 }\r
 \r
+/**\r
+  Converts a EMMC (Embedded MMC) device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextEmmc (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  EMMC_DEVICE_PATH             *Emmc;\r
+\r
+  Emmc = DevPath;\r
+  UefiDevicePathLibCatPrint (\r
+    Str,\r
+    L"eMMC(0x%x)",\r
+    Emmc->SlotNumber\r
+    );\r
+}\r
+\r
 /**\r
   Converts a 1394 device path structure to its string representative.\r
 \r
@@ -1331,7 +1364,7 @@ DevPathToTextIPv6 (
     UefiDevicePathLibCatPrint (Str, L")");\r
     return ;\r
   }\r
-  \r
+\r
   UefiDevicePathLibCatPrint (Str, L",");\r
   CatNetworkProtocol (Str, IPDevPath->Protocol);\r
 \r
@@ -1506,18 +1539,20 @@ DevPathToTextiSCSI (
 {\r
   ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
   UINT16                      Options;\r
+  UINTN                       Index;\r
 \r
   ISCSIDevPath = DevPath;\r
   UefiDevicePathLibCatPrint (\r
     Str,\r
-    L"iSCSI(%a,0x%x,0x%lx,",\r
+    L"iSCSI(%a,0x%x,0x",\r
     ISCSIDevPath->TargetName,\r
-    ISCSIDevPath->TargetPortalGroupTag,\r
-    ISCSIDevPath->Lun\r
+    ISCSIDevPath->TargetPortalGroupTag\r
     );\r
-\r
+  for (Index = 0; Index < sizeof (ISCSIDevPath->Lun) / sizeof (UINT8); Index++) {\r
+    UefiDevicePathLibCatPrint (Str, L"%02x", ((UINT8 *)&ISCSIDevPath->Lun)[Index]);\r
+  }\r
   Options = ISCSIDevPath->LoginOption;\r
-  UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
+  UefiDevicePathLibCatPrint (Str, L",%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
   UefiDevicePathLibCatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
   if (((Options >> 11) & 0x0001) != 0) {\r
     UefiDevicePathLibCatPrint (Str, L"%s,", L"None");\r
@@ -1585,12 +1620,12 @@ DevPathToTextBluetooth (
   UefiDevicePathLibCatPrint (\r
     Str,\r
     L"Bluetooth(%02x%02x%02x%02x%02x%02x)",\r
-    Bluetooth->BD_ADDR.Address[5],\r
-    Bluetooth->BD_ADDR.Address[4],\r
-    Bluetooth->BD_ADDR.Address[3],\r
-    Bluetooth->BD_ADDR.Address[2],\r
+    Bluetooth->BD_ADDR.Address[0],\r
     Bluetooth->BD_ADDR.Address[1],\r
-    Bluetooth->BD_ADDR.Address[0]\r
+    Bluetooth->BD_ADDR.Address[2],\r
+    Bluetooth->BD_ADDR.Address[3],\r
+    Bluetooth->BD_ADDR.Address[4],\r
+    Bluetooth->BD_ADDR.Address[5]\r
     );\r
 }\r
 \r
@@ -1616,9 +1651,96 @@ DevPathToTextWiFi (
   )\r
 {\r
   WIFI_DEVICE_PATH      *WiFi;\r
+  UINT8                 SSId[33];\r
 \r
   WiFi = DevPath;\r
-  UefiDevicePathLibCatPrint (Str, L"Wi-Fi(%a)", WiFi->SSId);\r
+\r
+  SSId[32] = '\0';\r
+  CopyMem (SSId, WiFi->SSId, 32);\r
+\r
+  UefiDevicePathLibCatPrint (Str, L"Wi-Fi(%a)", SSId);\r
+}\r
+\r
+/**\r
+  Converts a Bluetooth device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextBluetoothLE (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  BLUETOOTH_LE_DEVICE_PATH  *BluetoothLE;\r
+\r
+  BluetoothLE = DevPath;\r
+  UefiDevicePathLibCatPrint (\r
+    Str,\r
+    L"BluetoothLE(%02x%02x%02x%02x%02x%02x,0x%02x)",\r
+    BluetoothLE->Address.Address[0],\r
+    BluetoothLE->Address.Address[1],\r
+    BluetoothLE->Address.Address[2],\r
+    BluetoothLE->Address.Address[3],\r
+    BluetoothLE->Address.Address[4],\r
+    BluetoothLE->Address.Address[5],\r
+    BluetoothLE->Address.Type\r
+    );\r
+}\r
+\r
+/**\r
+  Converts a DNS device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextDns (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  DNS_DEVICE_PATH  *DnsDevPath;\r
+  UINT32           DnsServerIpCount;\r
+  UINT32           DnsServerIpIndex;\r
+\r
+  DnsDevPath     = DevPath;\r
+  DnsServerIpCount = (UINT32) (DevicePathNodeLength(DnsDevPath) - sizeof (EFI_DEVICE_PATH_PROTOCOL) - sizeof (DnsDevPath->IsIPv6)) / sizeof (EFI_IP_ADDRESS);\r
+\r
+  UefiDevicePathLibCatPrint (Str, L"Dns(");\r
+\r
+  for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) {\r
+    if (DnsDevPath->IsIPv6 == 0x00) {\r
+      CatIPv4Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v4));\r
+    } else {\r
+      CatIPv6Address (Str, &(DnsDevPath->DnsServerIp[DnsServerIpIndex].v6));\r
+    }\r
+\r
+    if (DnsServerIpIndex < DnsServerIpCount - 1) {\r
+      UefiDevicePathLibCatPrint (Str, L",");\r
+    }\r
+  }\r
+\r
+  UefiDevicePathLibCatPrint (Str, L")");\r
 }\r
 \r
 /**\r
@@ -2134,6 +2256,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLib
   {MESSAGING_DEVICE_PATH, MSG_NVME_NAMESPACE_DP,            DevPathToTextNVMe           },\r
   {MESSAGING_DEVICE_PATH, MSG_UFS_DP,                       DevPathToTextUfs            },\r
   {MESSAGING_DEVICE_PATH, MSG_SD_DP,                        DevPathToTextSd             },\r
+  {MESSAGING_DEVICE_PATH, MSG_EMMC_DP,                      DevPathToTextEmmc           },\r
   {MESSAGING_DEVICE_PATH, MSG_1394_DP,                      DevPathToText1394           },\r
   {MESSAGING_DEVICE_PATH, MSG_USB_DP,                       DevPathToTextUsb            },\r
   {MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP,                  DevPathToTextUsbWWID        },\r
@@ -2149,9 +2272,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLib
   {MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,                    DevPathToTextVendor         },\r
   {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP,                     DevPathToTextiSCSI          },\r
   {MESSAGING_DEVICE_PATH, MSG_VLAN_DP,                      DevPathToTextVlan           },\r
+  {MESSAGING_DEVICE_PATH, MSG_DNS_DP,                       DevPathToTextDns            },\r
   {MESSAGING_DEVICE_PATH, MSG_URI_DP,                       DevPathToTextUri            },\r
   {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP,                 DevPathToTextBluetooth      },\r
   {MESSAGING_DEVICE_PATH, MSG_WIFI_DP,                      DevPathToTextWiFi           },\r
+  {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP,              DevPathToTextBluetoothLE    },\r
   {MEDIA_DEVICE_PATH,     MEDIA_HARDDRIVE_DP,               DevPathToTextHardDrive      },\r
   {MEDIA_DEVICE_PATH,     MEDIA_CDROM_DP,                   DevPathToTextCDROM          },\r
   {MEDIA_DEVICE_PATH,     MEDIA_VENDOR_DP,                  DevPathToTextVendor         },\r
@@ -2284,14 +2409,14 @@ UefiDevicePathLibConvertDevicePathToText (
         UefiDevicePathLibCatPrint (&Str, L"/");\r
       }\r
     }\r
-    \r
+\r
     AlignedNode = AllocateCopyPool (DevicePathNodeLength (Node), Node);\r
     //\r
     // Print this node of the device path\r
     //\r
     ToText (&Str, AlignedNode, DisplayOnly, AllowShortcuts);\r
     FreePool (AlignedNode);\r
-    \r
+\r
     //\r
     // Next device path node\r
     //\r