]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/DevicePathLib: Reverse the byte order of BD_ADDR for Bluetooth
authorHao Wu <hao.a.wu@intel.com>
Sat, 27 May 2017 02:22:33 +0000 (10:22 +0800)
committerHao Wu <hao.a.wu@intel.com>
Wed, 31 May 2017 02:28:41 +0000 (10:28 +0800)
For the following two functions:
DevPathFromTextBluetooth()
DevPathToTextBluetooth()

The Bluetooth device address "UINT8  Address[6]" is displayed with the
order from Address[5] to Address[0]. This commit reverses the order.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
MdePkg/Library/UefiDevicePathLib/DevicePathToText.c

index 4322b6c0f28cf0903e321a97a058546afe55677b..187c1cc4dc5df3086ca07690d6227cca886bed00 100644 (file)
@@ -2635,35 +2635,20 @@ DevPathFromTextBluetooth (
   )\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
-  Walker = BluetoothStr;\r
-  while (!IS_NULL(*Walker) && Index >= 0) {\r
-    TempBufferSize = 2 * sizeof(CHAR16) + StrSize(L"0x");\r
-    TempNumBuffer = AllocateZeroPool (TempBufferSize);\r
-    if (TempNumBuffer == NULL) {\r
-      break;\r
-    }\r
-    StrCpyS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), L"0x");\r
-    StrnCatS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), Walker, 2);\r
-    BluetoothDp->BD_ADDR.Address[Index] = (UINT8)Strtoi (TempNumBuffer);\r
-    FreePool (TempNumBuffer);\r
-    Walker += 2;\r
-    Index--;\r
-  }\r
-  \r
+  BluetoothDp  = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (\r
+                                             MESSAGING_DEVICE_PATH,\r
+                                             MSG_BLUETOOTH_DP,\r
+                                             (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)\r
+                                             );\r
+  StrHexToBytes (\r
+    BluetoothStr,\r
+    sizeof (BLUETOOTH_ADDRESS) * 2,\r
+    BluetoothDp->BD_ADDR.Address,\r
+    sizeof (BLUETOOTH_ADDRESS)\r
+    );\r
   return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;\r
 }\r
 \r
index 87eca2352689a8d71d450831fd72eb54f59975e8..f45d3dd338c0a893093a9ee94649e7acedb38c7c 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 - 2017, 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
@@ -1618,12 +1618,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