From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Ruiyu Ni <ruiyu.ni@intel.com>,
Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <liming.gao@intel.com>
Subject: [patch 2/3] MdePkg: Handle USBxxx device path when optional para is not specified
Date: Fri, 12 Oct 2018 10:18:27 +0800 [thread overview]
Message-ID: <20181012021828.30432-3-dandan.bi@intel.com> (raw)
In-Reply-To: <20181012021828.30432-1-dandan.bi@intel.com>
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>
---
.../UefiDevicePathLib/DevicePathFromText.c | 30 +++++++++++++++----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index 7e33160ee9..4b49e341c7 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -2059,26 +2059,46 @@ ConvertFromTextUsbClass (
VIDStr = GetNextParamStr (&TextDeviceNode);
PIDStr = GetNextParamStr (&TextDeviceNode);
if (UsbClassText->ClassExist) {
ClassStr = GetNextParamStr (&TextDeviceNode);
- UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);
+ if (*ClassStr == L'\0') {
+ UsbClass->DeviceClass = 0xFF;
+ } else {
+ UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);
+ }
} else {
UsbClass->DeviceClass = UsbClassText->Class;
}
if (UsbClassText->SubClassExist) {
SubClassStr = GetNextParamStr (&TextDeviceNode);
- UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);
+ if (*SubClassStr == L'\0') {
+ UsbClass->DeviceSubClass = 0xFF;
+ } else {
+ UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);
+ }
} else {
UsbClass->DeviceSubClass = UsbClassText->SubClass;
}
ProtocolStr = GetNextParamStr (&TextDeviceNode);
- UsbClass->VendorId = (UINT16) Strtoi (VIDStr);
- UsbClass->ProductId = (UINT16) Strtoi (PIDStr);
- UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);
+ if (*VIDStr == L'\0') {
+ UsbClass->VendorId = 0xFFFF;
+ } else {
+ UsbClass->VendorId = (UINT16) Strtoi (VIDStr);
+ }
+ if (*PIDStr == L'\0') {
+ UsbClass->ProductId = 0xFFFF;
+ } else {
+ UsbClass->ProductId = (UINT16) Strtoi (PIDStr);
+ }
+ if (*ProtocolStr == L'\0') {
+ UsbClass->DeviceProtocol = 0xFF;
+ } else {
+ UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;
}
--
2.18.0.windows.1
next prev parent reply other threads:[~2018-10-12 2:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-12 2:18 [patch 0/3] MdePkg/UefiDevicePathLib: Enahncement for Sata/Usbxx/AcpiExp device path Dandan Bi
2018-10-12 2:18 ` [patch 1/3] MdePkg: Handle Sata device path when optional para is not specified Dandan Bi
2018-10-12 2:18 ` Dandan Bi [this message]
2018-10-12 2:18 ` [patch 3/3] MdePkg: Handle AcpiExp " Dandan Bi
2018-10-24 3:51 ` [patch 0/3] MdePkg/UefiDevicePathLib: Enahncement for Sata/Usbxx/AcpiExp device path Ni, Ruiyu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181012021828.30432-3-dandan.bi@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox