]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
MdePkg: Add bluetooth devicepath handling in device path library.
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLib / DevicePathFromText.c
index 6ec0a4c0bdbc2956387a135924bc0befdb9f379b..dec084c313fed7a67a26e490659551a9dd20ba66 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r
 \r
-Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2013 - 2015, 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
@@ -1809,6 +1809,37 @@ DevPathFromTextNVMe (
   return (EFI_DEVICE_PATH_PROTOCOL *) Nvme;\r
 }\r
 \r
+/**\r
+  Converts a text device path node to UFS device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created UFS device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextUfs (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16            *PunStr;\r
+  CHAR16            *LunStr;\r
+  UFS_DEVICE_PATH   *Ufs;\r
+\r
+  PunStr = GetNextParamStr (&TextDeviceNode);\r
+  LunStr = GetNextParamStr (&TextDeviceNode);\r
+  Ufs    = (UFS_DEVICE_PATH *) CreateDeviceNode (\r
+                                 MESSAGING_DEVICE_PATH,\r
+                                 MSG_UFS_DP,\r
+                                 (UINT16) sizeof (UFS_DEVICE_PATH)\r
+                                 );\r
+\r
+  Ufs->Pun = (UINT8) Strtoi (PunStr);\r
+  Ufs->Lun = (UINT8) Strtoi (LunStr);\r
+\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) Ufs;\r
+}\r
+\r
 /**\r
   Converts a text device path node to Debug Port device path structure.\r
 \r
@@ -2665,6 +2696,51 @@ DevPathFromTextVlan (
   return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;\r
 }\r
 \r
+/**\r
+  Converts a text device path node to Bluetooth device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Bluetooth device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextBluetooth (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                  *BluetoothStr;\r
+  CHAR16                  *Walker;\r
+  CHAR16                  *TempNumBuffer;\r
+  UINTN                   TempBufferSize;\r
+  INT32                   Index;\r
+  BLUETOOTH_DEVICE_PATH   *BluetoothDp;\r
+\r
+  BluetoothStr = GetNextParamStr (&TextDeviceNode);\r
+  BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (\r
+                                   MESSAGING_DEVICE_PATH,\r
+                                   MSG_BLUETOOTH_DP,\r
+                                   (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)\r
+                                   );\r
+\r
+  Index = sizeof (BLUETOOTH_ADDRESS) - 1;\r
+  while (!IS_NULL(BluetoothStr) && Index >= 0) {\r
+    Walker = SplitStr (&BluetoothStr, L':');\r
+    TempBufferSize = StrSize (Walker) + StrLen (L"0x") * sizeof (CHAR16);\r
+    TempNumBuffer = AllocateZeroPool (TempBufferSize);\r
+    if (TempNumBuffer == NULL) {\r
+      break;\r
+    }\r
+    StrnCpy (TempNumBuffer, L"0x", TempBufferSize / sizeof (CHAR16));\r
+    StrnCat (TempNumBuffer + StrLen (L"0x"), Walker, TempBufferSize / sizeof (CHAR16) - StrLen (L"0x") );\r
+    BluetoothDp->BD_ADDR.Address[Index] = (UINT8)Strtoi (TempNumBuffer);\r
+    FreePool (TempNumBuffer);\r
+    Index--;\r
+  }\r
+  \r
+  return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;\r
+}\r
+\r
 /**\r
   Converts a media text device path node to media device path structure.\r
 \r
@@ -3079,6 +3155,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
   {L"SAS",                     DevPathFromTextSAS                     },\r
   {L"SasEx",                   DevPathFromTextSasEx                   },\r
   {L"NVMe",                    DevPathFromTextNVMe                    },\r
+  {L"UFS",                     DevPathFromTextUfs                     },\r
   {L"DebugPort",               DevPathFromTextDebugPort               },\r
   {L"MAC",                     DevPathFromTextMAC                     },\r
   {L"IPv4",                    DevPathFromTextIPv4                    },\r
@@ -3104,7 +3181,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
   {L"Unit",                    DevPathFromTextUnit                    },\r
   {L"iSCSI",                   DevPathFromTextiSCSI                   },\r
   {L"Vlan",                    DevPathFromTextVlan                    },\r
-\r
+  {L"Bluetooth",               DevPathFromTextBluetooth               },\r
   {L"MediaPath",               DevPathFromTextMediaPath               },\r
   {L"HD",                      DevPathFromTextHD                      },\r
   {L"CDROM",                   DevPathFromTextCDROM                   },\r