aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Luis Duran <jlduran@gmail.com>2022-02-23 20:55:23 +0000
committerWarner Losh <imp@FreeBSD.org>2022-02-27 16:12:25 +0000
commite8fc7f11896a3a3a6937198c60756a0f142e0bb0 (patch)
treede4b15c4210416618f33f9346cb91394f112da83
parent0081638344b48c70fdf5da4e5a5bf9e9f672d7ca (diff)
downloadsrc-e8fc7f11896a3a3a6937198c60756a0f142e0bb0.tar.gz
src-e8fc7f11896a3a3a6937198c60756a0f142e0bb0.zip
libefivar: Add BluetoothLe device path node support
-rw-r--r--lib/libefivar/efivar-dp-format.c38
-rw-r--r--lib/libefivar/efivar-dp-parse.c35
2 files changed, 73 insertions, 0 deletions
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
@@ -1722,6 +1722,43 @@ DevPathToTextWiFi (
}
/**
+ 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.
@param Str The string representative of input device.
@@ -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
@@ -2839,6 +2839,40 @@ DevPathFromTextWiFi (
}
/**
+ 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.
@param TextDeviceNode The input Text device path node.
@@ -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 },