* [PATCH] MdePkg/DevicePathLib: Reverse the byte order of BD_ADDR for Bluetooth
@ 2017-05-27 2:31 Hao Wu
2017-05-27 4:30 ` Ni, Ruiyu
0 siblings, 1 reply; 2+ messages in thread
From: Hao Wu @ 2017-05-27 2:31 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Ruiyu Ni, Michael D Kinney, Liming Gao
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.
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c | 37 ++++++--------------
MdePkg/Library/UefiDevicePathLib/DevicePathToText.c | 12 +++----
2 files changed, 17 insertions(+), 32 deletions(-)
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index 4322b6c0f2..187c1cc4dc 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -2635,35 +2635,20 @@ DevPathFromTextBluetooth (
)
{
CHAR16 *BluetoothStr;
- CHAR16 *Walker;
- CHAR16 *TempNumBuffer;
- UINTN TempBufferSize;
- INT32 Index;
BLUETOOTH_DEVICE_PATH *BluetoothDp;
BluetoothStr = GetNextParamStr (&TextDeviceNode);
- BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (
- MESSAGING_DEVICE_PATH,
- MSG_BLUETOOTH_DP,
- (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)
- );
-
- Index = sizeof (BLUETOOTH_ADDRESS) - 1;
- Walker = BluetoothStr;
- while (!IS_NULL(*Walker) && Index >= 0) {
- TempBufferSize = 2 * sizeof(CHAR16) + StrSize(L"0x");
- TempNumBuffer = AllocateZeroPool (TempBufferSize);
- if (TempNumBuffer == NULL) {
- break;
- }
- StrCpyS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), L"0x");
- StrnCatS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), Walker, 2);
- BluetoothDp->BD_ADDR.Address[Index] = (UINT8)Strtoi (TempNumBuffer);
- FreePool (TempNumBuffer);
- Walker += 2;
- Index--;
- }
-
+ BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_BLUETOOTH_DP,
+ (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)
+ );
+ StrHexToBytes (
+ BluetoothStr,
+ sizeof (BLUETOOTH_ADDRESS) * 2,
+ BluetoothDp->BD_ADDR.Address,
+ sizeof (BLUETOOTH_ADDRESS)
+ );
return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;
}
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index 87eca23526..f45d3dd338 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -2,7 +2,7 @@
DevicePathToText protocol as defined in the UEFI 2.0 specification.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
-Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1618,12 +1618,12 @@ DevPathToTextBluetooth (
UefiDevicePathLibCatPrint (
Str,
L"Bluetooth(%02x%02x%02x%02x%02x%02x)",
- Bluetooth->BD_ADDR.Address[5],
- Bluetooth->BD_ADDR.Address[4],
- Bluetooth->BD_ADDR.Address[3],
- Bluetooth->BD_ADDR.Address[2],
+ Bluetooth->BD_ADDR.Address[0],
Bluetooth->BD_ADDR.Address[1],
- Bluetooth->BD_ADDR.Address[0]
+ Bluetooth->BD_ADDR.Address[2],
+ Bluetooth->BD_ADDR.Address[3],
+ Bluetooth->BD_ADDR.Address[4],
+ Bluetooth->BD_ADDR.Address[5]
);
}
--
2.12.0.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] MdePkg/DevicePathLib: Reverse the byte order of BD_ADDR for Bluetooth
2017-05-27 2:31 [PATCH] MdePkg/DevicePathLib: Reverse the byte order of BD_ADDR for Bluetooth Hao Wu
@ 2017-05-27 4:30 ` Ni, Ruiyu
0 siblings, 0 replies; 2+ messages in thread
From: Ni, Ruiyu @ 2017-05-27 4:30 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Kinney, Michael D, Gao, Liming
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Thanks/Ray
> -----Original Message-----
> From: Wu, Hao A
> Sent: Saturday, May 27, 2017 10:32 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>;
> Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
> <liming.gao@intel.com>
> Subject: [PATCH] MdePkg/DevicePathLib: Reverse the byte order of
> BD_ADDR for Bluetooth
>
> 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.
>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
> MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c | 37 ++++++------
> --------
> MdePkg/Library/UefiDevicePathLib/DevicePathToText.c | 12 +++----
> 2 files changed, 17 insertions(+), 32 deletions(-)
>
> diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
> b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
> index 4322b6c0f2..187c1cc4dc 100644
> --- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
> +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
> @@ -2635,35 +2635,20 @@ DevPathFromTextBluetooth (
> )
> {
> CHAR16 *BluetoothStr;
> - CHAR16 *Walker;
> - CHAR16 *TempNumBuffer;
> - UINTN TempBufferSize;
> - INT32 Index;
> BLUETOOTH_DEVICE_PATH *BluetoothDp;
>
> BluetoothStr = GetNextParamStr (&TextDeviceNode);
> - BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (
> - MESSAGING_DEVICE_PATH,
> - MSG_BLUETOOTH_DP,
> - (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)
> - );
> -
> - Index = sizeof (BLUETOOTH_ADDRESS) - 1;
> - Walker = BluetoothStr;
> - while (!IS_NULL(*Walker) && Index >= 0) {
> - TempBufferSize = 2 * sizeof(CHAR16) + StrSize(L"0x");
> - TempNumBuffer = AllocateZeroPool (TempBufferSize);
> - if (TempNumBuffer == NULL) {
> - break;
> - }
> - StrCpyS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), L"0x");
> - StrnCatS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), Walker, 2);
> - BluetoothDp->BD_ADDR.Address[Index] = (UINT8)Strtoi
> (TempNumBuffer);
> - FreePool (TempNumBuffer);
> - Walker += 2;
> - Index--;
> - }
> -
> + BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (
> + MESSAGING_DEVICE_PATH,
> + MSG_BLUETOOTH_DP,
> + (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)
> + );
> + StrHexToBytes (
> + BluetoothStr,
> + sizeof (BLUETOOTH_ADDRESS) * 2,
> + BluetoothDp->BD_ADDR.Address,
> + sizeof (BLUETOOTH_ADDRESS)
> + );
> return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;
> }
>
> diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
> b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
> index 87eca23526..f45d3dd338 100644
> --- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
> +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
> @@ -2,7 +2,7 @@
> DevicePathToText protocol as defined in the UEFI 2.0 specification.
>
> (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
> -Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD
> License
> which accompanies this distribution. The full text of the license may be
> found at
> @@ -1618,12 +1618,12 @@ DevPathToTextBluetooth (
> UefiDevicePathLibCatPrint (
> Str,
> L"Bluetooth(%02x%02x%02x%02x%02x%02x)",
> - Bluetooth->BD_ADDR.Address[5],
> - Bluetooth->BD_ADDR.Address[4],
> - Bluetooth->BD_ADDR.Address[3],
> - Bluetooth->BD_ADDR.Address[2],
> + Bluetooth->BD_ADDR.Address[0],
> Bluetooth->BD_ADDR.Address[1],
> - Bluetooth->BD_ADDR.Address[0]
> + Bluetooth->BD_ADDR.Address[2],
> + Bluetooth->BD_ADDR.Address[3],
> + Bluetooth->BD_ADDR.Address[4],
> + Bluetooth->BD_ADDR.Address[5]
> );
> }
>
> --
> 2.12.0.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-27 4:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-27 2:31 [PATCH] MdePkg/DevicePathLib: Reverse the byte order of BD_ADDR for Bluetooth Hao Wu
2017-05-27 4:30 ` Ni, Ruiyu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox