diff options
author | Jose Luis Duran <jlduran@gmail.com> | 2022-02-24 00:03:10 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2022-02-27 16:12:21 +0000 |
commit | 0081638344b48c70fdf5da4e5a5bf9e9f672d7ca (patch) | |
tree | e348a348a2edc8fe8eb901ec63b4d2732f6eea74 /lib/libefivar | |
parent | 7ca6daff6a43f11fb93831e0970fb8bfb5d0833a (diff) | |
download | src-0081638344b48c70fdf5da4e5a5bf9e9f672d7ca.tar.gz src-0081638344b48c70fdf5da4e5a5bf9e9f672d7ca.zip |
libefivar: 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.
Obtained from: https://github.com/tianocore/edk2/commit/4fc8277133fb011d028b4e0a42444ab6f552d0b9
Pull Request: https://github.com/freebsd/freebsd-src/pull/581
Diffstat (limited to 'lib/libefivar')
-rw-r--r-- | lib/libefivar/efivar-dp-format.c | 12 | ||||
-rw-r--r-- | lib/libefivar/efivar-dp-parse.c | 37 |
2 files changed, 17 insertions, 32 deletions
diff --git a/lib/libefivar/efivar-dp-format.c b/lib/libefivar/efivar-dp-format.c index 14f6adc2fd98..eaff7754019c 100644 --- a/lib/libefivar/efivar-dp-format.c +++ b/lib/libefivar/efivar-dp-format.c @@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$"); 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 @@ -1680,12 +1680,12 @@ DevPathToTextBluetooth ( UefiDevicePathLibCatPrint ( Str, "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] ); } diff --git a/lib/libefivar/efivar-dp-parse.c b/lib/libefivar/efivar-dp-parse.c index 02c32971f4c6..ea78d5a1f930 100644 --- a/lib/libefivar/efivar-dp-parse.c +++ b/lib/libefivar/efivar-dp-parse.c @@ -2781,35 +2781,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("0x"); - TempNumBuffer = AllocateZeroPool (TempBufferSize); - if (TempNumBuffer == NULL) { - break; - } - StrCpyS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), "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; } |