libefivar: Add BluetoothLe device path node support

Obtained from:	ff5623e990
Pull Request:   https://github.com/freebsd/freebsd-src/pull/581
This commit is contained in:
Jose Luis Duran 2022-02-23 17:55:23 -03:00 committed by Warner Losh
parent 0081638344
commit e8fc7f1189
2 changed files with 73 additions and 0 deletions

View file

@ -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 },

View file

@ -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 },