]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: Handle USBxxx device path when optional para is not specified
authorDandan Bi <dandan.bi@intel.com>
Fri, 12 Oct 2018 02:18:27 +0000 (10:18 +0800)
committerLiming Gao <liming.gao@intel.com>
Wed, 24 Oct 2018 14:15:56 +0000 (22:15 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1243

According to UEFI spec,
for the Messaging Device Path with USB Class SubType, some paras
are optional in the text device path.
Take UsbClass(VID,PID,Class,SubClass,Protocol) for example,
The VID is an integer between 0 and 65535 and is optional. The
default value is 0xFFFF.
The PID is an integer between 0 and 65535 and is optional. The
default value is 0xFFFF.
The Class is an integer between 0 and 255 and is optional. The
default value is 0xFF.
The SubClass is an integer between 0 and 255 and is optional. The
default value is 0xFF.
The Protocol is an integer between 0 and 255 and is optional. The
default value is 0xFF.
So if any the optional para is not specified in the text device,
we should set related para in the node structure to default value.

This commit is to do the enhancement for USB Class device path
when optional para is not specified

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c

index ca912b4eb067a0873f295d36665d1d2c90b3f19b..128eb70139d43728041d1539951530d6237d4075 100644 (file)
@@ -2061,22 +2061,42 @@ ConvertFromTextUsbClass (
   PIDStr      = GetNextParamStr (&TextDeviceNode);\r
   if (UsbClassText->ClassExist) {\r
     ClassStr = GetNextParamStr (&TextDeviceNode);\r
-    UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r
+    if (*ClassStr == L'\0') {\r
+      UsbClass->DeviceClass = 0xFF;\r
+    } else {\r
+      UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r
+    }\r
   } else {\r
     UsbClass->DeviceClass = UsbClassText->Class;\r
   }\r
   if (UsbClassText->SubClassExist) {\r
     SubClassStr = GetNextParamStr (&TextDeviceNode);\r
-    UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r
+    if (*SubClassStr == L'\0') {\r
+      UsbClass->DeviceSubClass = 0xFF;\r
+    } else {\r
+      UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r
+    }\r
   } else {\r
     UsbClass->DeviceSubClass = UsbClassText->SubClass;\r
   }\r
 \r
   ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
 \r
-  UsbClass->VendorId        = (UINT16) Strtoi (VIDStr);\r
-  UsbClass->ProductId       = (UINT16) Strtoi (PIDStr);\r
-  UsbClass->DeviceProtocol  = (UINT8) Strtoi (ProtocolStr);\r
+  if (*VIDStr == L'\0') {\r
+    UsbClass->VendorId        = 0xFFFF;\r
+  } else {\r
+    UsbClass->VendorId        = (UINT16) Strtoi (VIDStr);\r
+  }\r
+  if (*PIDStr == L'\0') {\r
+    UsbClass->ProductId       = 0xFFFF;\r
+  } else {\r
+    UsbClass->ProductId       = (UINT16) Strtoi (PIDStr);\r
+  }\r
+  if (*ProtocolStr == L'\0') {\r
+    UsbClass->DeviceProtocol  = 0xFF;\r
+  } else {\r
+    UsbClass->DeviceProtocol  = (UINT8) Strtoi (ProtocolStr);\r
+  }\r
 \r
   return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;\r
 }\r