]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Add bluetooth devicepath handling in device path library.
authorQiu Shumin <shumin.qiu@intel.com>
Wed, 6 May 2015 02:41:37 +0000 (02:41 +0000)
committershenshushi <shenshushi@Edk2>
Wed, 6 May 2015 02:41:37 +0000 (02:41 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17312 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.h

index f688c1af7494ef3c5f61d6ae8526698269452795..dec084c313fed7a67a26e490659551a9dd20ba66 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r
 \r
 /** @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
 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
@@ -2696,6 +2696,51 @@ DevPathFromTextVlan (
   return (EFI_DEVICE_PATH_PROTOCOL *) Vlan;\r
 }\r
 \r
   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
 /**\r
   Converts a media text device path node to media device path structure.\r
 \r
@@ -3136,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
   {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
   {L"MediaPath",               DevPathFromTextMediaPath               },\r
   {L"HD",                      DevPathFromTextHD                      },\r
   {L"CDROM",                   DevPathFromTextCDROM                   },\r
index 2dbbddaf097088379a6bde0e893ba8fe775ecf33..af1a6d675e5111080ce96614f8deb4b6f22978da 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
 \r
 /** @file\r
   DevicePathToText 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
 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
@@ -1494,6 +1494,42 @@ DevPathToTextVlan (
   UefiDevicePathLibCatPrint (Str, L"Vlan(%d)", Vlan->VlanId);\r
 }\r
 \r
   UefiDevicePathLibCatPrint (Str, L"Vlan(%d)", Vlan->VlanId);\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
+DevPathToTextBluetooth (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  BLUETOOTH_DEVICE_PATH  *Bluetooth;\r
+\r
+  Bluetooth = DevPath;\r
+  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[1],\r
+    Bluetooth->BD_ADDR.Address[0]\r
+    );\r
+}\r
+\r
 /**\r
   Converts a Hard drive device path structure to its string representative.\r
 \r
 /**\r
   Converts a Hard drive device path structure to its string representative.\r
 \r
@@ -1912,6 +1948,7 @@ 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_VENDOR_DP,                    DevPathToTextVendor         },\r
   {MESSAGING_DEVICE_PATH, MSG_ISCSI_DP,                     DevPathToTextiSCSI          },\r
   {MESSAGING_DEVICE_PATH, MSG_VLAN_DP,                      DevPathToTextVlan           },\r
+  {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP,                 DevPathToTextBluetooth      },\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
   {MEDIA_DEVICE_PATH,     MEDIA_HARDDRIVE_DP,               DevPathToTextHardDrive      },\r
   {MEDIA_DEVICE_PATH,     MEDIA_CDROM_DP,                   DevPathToTextCDROM          },\r
   {MEDIA_DEVICE_PATH,     MEDIA_VENDOR_DP,                  DevPathToTextVendor         },\r
index 233844cfcc287caac3262f9cd5d0c44ef336bfc1..72587c6ebb13eb76567b0e5033d62c183e193317 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Definition for Device Path library.\r
 \r
 /** @file\r
   Definition for Device Path library.\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
 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
@@ -28,6 +28,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/DevicePathLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/DevicePathLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <IndustryStandard/Bluetooth.h>\r
 \r
 #define IS_COMMA(a)                ((a) == L',')\r
 #define IS_HYPHEN(a)               ((a) == L'-')\r
 \r
 #define IS_COMMA(a)                ((a) == L',')\r
 #define IS_HYPHEN(a)               ((a) == L'-')\r