git: e8fc7f11896a - main - libefivar: Add BluetoothLe device path node support
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 27 Feb 2022 16:47:39 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=e8fc7f11896a3a3a6937198c60756a0f142e0bb0
commit e8fc7f11896a3a3a6937198c60756a0f142e0bb0
Author: Jose Luis Duran <jlduran@gmail.com>
AuthorDate: 2022-02-23 20:55:23 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-02-27 16:12:25 +0000
libefivar: Add BluetoothLe device path node support
Obtained from: https://github.com/tianocore/edk2/commit/ff5623e990782ad62c5f6943087ebafb17afe8ba
Pull Request: https://github.com/freebsd/freebsd-src/pull/581
---
lib/libefivar/efivar-dp-format.c | 38 ++++++++++++++++++++++++++++++++++++++
lib/libefivar/efivar-dp-parse.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+)
diff --git a/lib/libefivar/efivar-dp-format.c b/lib/libefivar/efivar-dp-format.c
index eaff7754019c..667a794b34db 100644
--- a/lib/libefivar/efivar-dp-format.c
+++ b/lib/libefivar/efivar-dp-format.c
@@ -1721,6 +1721,43 @@ DevPathToTextWiFi (
UefiDevicePathLibCatPrint (Str, "Wi-Fi(%s)", SSId);
}
+/**
+ Converts a Bluetooth device path structure to its string representative.
+
+ @param Str The string representative of input device.
+ @param DevPath The input device path structure.
+ @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
+ of the display node is used, where applicable. If DisplayOnly
+ is FALSE, then the longer text representation of the display node
+ is used.
+ @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
+ representation for a device node can be used, where applicable.
+
+**/
+static VOID
+DevPathToTextBluetoothLE (
+ IN OUT POOL_PRINT *Str,
+ IN VOID *DevPath,
+ IN BOOLEAN DisplayOnly,
+ IN BOOLEAN AllowShortcuts
+ )
+{
+ BLUETOOTH_LE_DEVICE_PATH *BluetoothLE;
+
+ BluetoothLE = DevPath;
+ UefiDevicePathLibCatPrint (
+ Str,
+ "BluetoothLE(%02x%02x%02x%02x%02x%02x,0x%02x)",
+ BluetoothLE->Address.Address[0],
+ BluetoothLE->Address.Address[1],
+ BluetoothLE->Address.Address[2],
+ BluetoothLE->Address.Address[3],
+ BluetoothLE->Address.Address[4],
+ BluetoothLE->Address.Address[5],
+ BluetoothLE->Address.Type
+ );
+}
+
/**
Converts a URI device path structure to its string representative.
@@ -2257,6 +2294,7 @@ static const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLibToTextTable[] = {
{MESSAGING_DEVICE_PATH, MSG_URI_DP, DevPathToTextUri },
{MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP, DevPathToTextBluetooth },
{MESSAGING_DEVICE_PATH, MSG_WIFI_DP, DevPathToTextWiFi },
+ {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP, DevPathToTextBluetoothLE },
{MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, DevPathToTextHardDrive },
{MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, DevPathToTextCDROM },
{MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP, DevPathToTextVendor },
diff --git a/lib/libefivar/efivar-dp-parse.c b/lib/libefivar/efivar-dp-parse.c
index ea78d5a1f930..80270aad1d5c 100644
--- a/lib/libefivar/efivar-dp-parse.c
+++ b/lib/libefivar/efivar-dp-parse.c
@@ -2838,6 +2838,40 @@ DevPathFromTextWiFi (
return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;
}
+/**
+ Converts a text device path node to Bluetooth LE device path structure.
+
+ @param TextDeviceNode The input Text device path node.
+
+ @return A pointer to the newly-created Bluetooth LE device path structure.
+
+**/
+static
+EFI_DEVICE_PATH_PROTOCOL *
+DevPathFromTextBluetoothLE (
+ IN CHAR16 *TextDeviceNode
+ )
+{
+ CHAR16 *BluetoothLeAddrStr;
+ CHAR16 *BluetoothLeAddrTypeStr;
+ BLUETOOTH_LE_DEVICE_PATH *BluetoothLeDp;
+
+ BluetoothLeAddrStr = GetNextParamStr (&TextDeviceNode);
+ BluetoothLeAddrTypeStr = GetNextParamStr (&TextDeviceNode);
+ BluetoothLeDp = (BLUETOOTH_LE_DEVICE_PATH *) CreateDeviceNode (
+ MESSAGING_DEVICE_PATH,
+ MSG_BLUETOOTH_LE_DP,
+ (UINT16) sizeof (BLUETOOTH_LE_DEVICE_PATH)
+ );
+
+ BluetoothLeDp->Address.Type = (UINT8) Strtoi (BluetoothLeAddrTypeStr);
+ StrHexToBytes (
+ BluetoothLeAddrStr, sizeof (BluetoothLeDp->Address.Address) * 2,
+ BluetoothLeDp->Address.Address, sizeof (BluetoothLeDp->Address.Address)
+ );
+ return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothLeDp;
+}
+
/**
Converts a text device path node to URI device path structure.
@@ -3544,6 +3578,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
{"Uri", DevPathFromTextUri },
{"Bluetooth", DevPathFromTextBluetooth },
{"Wi-Fi", DevPathFromTextWiFi },
+ {"BluetoothLE", DevPathFromTextBluetoothLE },
{"MediaPath", DevPathFromTextMediaPath },
{"HD", DevPathFromTextHD },
{"CDROM", DevPathFromTextCDROM },