]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/DevicePath: Add BluetoothLe device path node support
authorRuiyu Ni <ruiyu.ni@intel.com>
Tue, 6 Jun 2017 02:03:09 +0000 (10:03 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Wed, 7 Jun 2017 00:46:20 +0000 (08:46 +0800)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
MdePkg/Include/IndustryStandard/Bluetooth.h
MdePkg/Include/Protocol/DevicePath.h
MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
MdePkg/Library/UefiDevicePathLib/DevicePathToText.c

index 7dc9d558dc4f7dddc0c1fee77672586727d1029b..caea3ac03487d1a921f17e0bff2cf9ccc51230b3 100644 (file)
@@ -2,7 +2,7 @@
   This file contains the Bluetooth definitions that are consumed by drivers.\r
   These definitions are from Bluetooth Core Specification Version 4.0 June, 2010\r
 \r
-  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -38,6 +38,21 @@ typedef struct {
   UINT16     MajorServiceClass:11;\r
 } BLUETOOTH_CLASS_OF_DEVICE;\r
 \r
+///\r
+/// BLUETOOTH_LE_ADDRESS\r
+///\r
+typedef struct {\r
+  ///\r
+  /// 48-bit Bluetooth device address\r
+  ///\r
+  UINT8      Address[6];\r
+  ///\r
+  /// 0x00 - Public Device Address\r
+  /// 0x01 - Random Device Address\r
+  ///\r
+  UINT8      Type;\r
+} BLUETOOTH_LE_ADDRESS;\r
+\r
 #pragma pack()\r
 \r
 #define BLUETOOTH_HCI_COMMAND_LOCAL_READABLE_NAME_MAX_SIZE    248\r
index aa7aec793e3132429b1053df3f5e9ec8e12d276e..220fa90765326c3c327b747b9061b4d9228374cc 100644 (file)
@@ -5,7 +5,7 @@
   from a software point of view. The path must persist from boot to boot, so \r
   it can not contain things like PCI bus numbers that change from boot to boot.\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -938,6 +938,15 @@ typedef struct {
   UINT8                           SSId[32];\r
 } WIFI_DEVICE_PATH;\r
 \r
+///\r
+/// Bluetooth LE Device Path SubType.\r
+///\r
+#define MSG_BLUETOOTH_LE_DP       0x1E\r
+typedef struct {\r
+  EFI_DEVICE_PATH_PROTOCOL        Header;\r
+  BLUETOOTH_LE_ADDRESS            Address;\r
+} BLUETOOTH_LE_DEVICE_PATH;\r
+\r
 //\r
 // Media Device Path\r
 //\r
index 187c1cc4dc5df3086ca07690d6227cca886bed00..f50c11cfa2e7d593903d5ffc73108b8b5690edee 100644 (file)
@@ -2691,6 +2691,39 @@ DevPathFromTextWiFi (
   return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;\r
 }\r
 \r
+/**\r
+  Converts a text device path node to Bluetooth LE device path structure.\r
+\r
+  @param TextDeviceNode  The input Text device path node.\r
+\r
+  @return A pointer to the newly-created Bluetooth LE device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextBluetoothLE (\r
+  IN CHAR16 *TextDeviceNode\r
+  )\r
+{\r
+  CHAR16                     *BluetoothLeAddrStr;\r
+  CHAR16                     *BluetoothLeAddrTypeStr;\r
+  BLUETOOTH_LE_DEVICE_PATH   *BluetoothLeDp;\r
+\r
+  BluetoothLeAddrStr     = GetNextParamStr (&TextDeviceNode);\r
+  BluetoothLeAddrTypeStr = GetNextParamStr (&TextDeviceNode);\r
+  BluetoothLeDp = (BLUETOOTH_LE_DEVICE_PATH *) CreateDeviceNode (\r
+                                                 MESSAGING_DEVICE_PATH,\r
+                                                 MSG_BLUETOOTH_LE_DP,\r
+                                                 (UINT16) sizeof (BLUETOOTH_LE_DEVICE_PATH)\r
+                                                 );\r
+\r
+  BluetoothLeDp->Address.Type = (UINT8) Strtoi (BluetoothLeAddrTypeStr);\r
+  StrHexToBytes (\r
+    BluetoothLeAddrStr, sizeof (BluetoothLeDp->Address.Address) * 2,\r
+    BluetoothLeDp->Address.Address, sizeof (BluetoothLeDp->Address.Address)\r
+    );\r
+  return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothLeDp;\r
+}\r
+\r
 /**\r
   Converts a text device path node to URI device path structure.\r
 \r
@@ -3367,6 +3400,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
   {L"Uri",                     DevPathFromTextUri                     },\r
   {L"Bluetooth",               DevPathFromTextBluetooth               },\r
   {L"Wi-Fi",                   DevPathFromTextWiFi                    },\r
+  {L"BluetoothLE",             DevPathFromTextBluetoothLE             },\r
   {L"MediaPath",               DevPathFromTextMediaPath               },\r
   {L"HD",                      DevPathFromTextHD                      },\r
   {L"CDROM",                   DevPathFromTextCDROM                   },\r
index f45d3dd338c0a893093a9ee94649e7acedb38c7c..b8d9491885177a1c929bd433704476696517121e 100644 (file)
@@ -1659,6 +1659,43 @@ DevPathToTextWiFi (
   UefiDevicePathLibCatPrint (Str, L"Wi-Fi(%a)", SSId);\r
 }\r
 \r
+/**\r
+  Converts a Bluetooth device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+**/\r
+VOID\r
+DevPathToTextBluetoothLE (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  BLUETOOTH_LE_DEVICE_PATH  *BluetoothLE;\r
+\r
+  BluetoothLE = DevPath;\r
+  UefiDevicePathLibCatPrint (\r
+    Str,\r
+    L"BluetoothLE(%02x%02x%02x%02x%02x%02x,0x%02x)",\r
+    BluetoothLE->Address.Address[0],\r
+    BluetoothLE->Address.Address[1],\r
+    BluetoothLE->Address.Address[2],\r
+    BluetoothLE->Address.Address[3],\r
+    BluetoothLE->Address.Address[4],\r
+    BluetoothLE->Address.Address[5],\r
+    BluetoothLE->Address.Type\r
+    );\r
+}\r
+\r
 /**\r
   Converts a URI device path structure to its string representative.\r
 \r
@@ -2191,6 +2228,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const DEVICE_PATH_TO_TEXT_TABLE mUefiDevicePathLib
   {MESSAGING_DEVICE_PATH, MSG_URI_DP,                       DevPathToTextUri            },\r
   {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_DP,                 DevPathToTextBluetooth      },\r
   {MESSAGING_DEVICE_PATH, MSG_WIFI_DP,                      DevPathToTextWiFi           },\r
+  {MESSAGING_DEVICE_PATH, MSG_BLUETOOTH_LE_DP,              DevPathToTextBluetoothLE    },\r
   {MEDIA_DEVICE_PATH,     MEDIA_HARDDRIVE_DP,               DevPathToTextHardDrive      },\r
   {MEDIA_DEVICE_PATH,     MEDIA_CDROM_DP,                   DevPathToTextCDROM          },\r
   {MEDIA_DEVICE_PATH,     MEDIA_VENDOR_DP,                  DevPathToTextVendor         },\r