public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch 0/3] MdePkg/UefiDevicePathLib: Enahncement for Sata/Usbxx/AcpiExp device path
@ 2018-10-12  2:18 Dandan Bi
  2018-10-12  2:18 ` [patch 1/3] MdePkg: Handle Sata device path when optional para is not specified Dandan Bi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dandan Bi @ 2018-10-12  2:18 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ruiyu Ni, Michael D Kinney, Liming Gao

https://bugzilla.tianocore.org/show_bug.cgi?id=1243

This pacth series is mainly to do the enahncement for
Sata/Usbxx/AcpiExp device path to handle the cases when some
optional paremeter is not specified in the text device path.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Dandan Bi (3):
  MdePkg: Handle Sata device path when optional para is not specified
  MdePkg: Handle USBxxx device path when optional para is not specified
  MdePkg: Handle AcpiExp device path when optional para is not specified

 .../UefiDevicePathLib/DevicePathFromText.c    | 51 ++++++++++++++++---
 .../UefiDevicePathLib/DevicePathToText.c      | 23 ++++++---
 2 files changed, 60 insertions(+), 14 deletions(-)

-- 
2.18.0.windows.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [patch 1/3] MdePkg: Handle Sata device path when optional para is not specified
  2018-10-12  2:18 [patch 0/3] MdePkg/UefiDevicePathLib: Enahncement for Sata/Usbxx/AcpiExp device path Dandan Bi
@ 2018-10-12  2:18 ` Dandan Bi
  2018-10-12  2:18 ` [patch 2/3] MdePkg: Handle USBxxx " Dandan Bi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dandan Bi @ 2018-10-12  2:18 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ruiyu Ni, Michael D Kinney, Liming Gao

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1243

Sata device path format:Sata(HPN, PMPN, LUN)
According to UEFI Spec, the PMPN is an integer between
0 and 65535 and is optional. If not provided, the default is 0xFFFF.

This commit is to do the enhancement for Sata 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>
---
 MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index c5f3764fc0..7e33160ee9 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -3414,11 +3414,19 @@ DevPathFromTextSata (
                                 MESSAGING_DEVICE_PATH,
                                 MSG_SATA_DP,
                                 (UINT16) sizeof (SATA_DEVICE_PATH)
                                 );
   Sata->HBAPortNumber            = (UINT16) Strtoi (Param1);
-  Sata->PortMultiplierPortNumber = (UINT16) Strtoi (Param2);
+
+  //
+  // According to UEFI spec, if PMPN is not provided, the default is 0xFFFF
+  //
+  if (*Param2 == L'\0' ) {
+    Sata->PortMultiplierPortNumber = 0xFFFF;
+  } else {
+    Sata->PortMultiplierPortNumber = (UINT16) Strtoi (Param2);
+  }
   Sata->Lun                      = (UINT16) Strtoi (Param3);
 
   return (EFI_DEVICE_PATH_PROTOCOL *) Sata;
 }
 
-- 
2.18.0.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [patch 2/3] MdePkg: Handle USBxxx device path when optional para is not specified
  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
  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
  3 siblings, 0 replies; 5+ messages in thread
From: Dandan Bi @ 2018-10-12  2:18 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ruiyu Ni, Michael D Kinney, Liming Gao

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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [patch 3/3] MdePkg: Handle AcpiExp device path when optional para is not specified
  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 ` [patch 2/3] MdePkg: Handle USBxxx " Dandan Bi
@ 2018-10-12  2:18 ` Dandan Bi
  2018-10-24  3:51 ` [patch 0/3] MdePkg/UefiDevicePathLib: Enahncement for Sata/Usbxx/AcpiExp device path Ni, Ruiyu
  3 siblings, 0 replies; 5+ messages in thread
From: Dandan Bi @ 2018-10-12  2:18 UTC (permalink / raw)
  To: edk2-devel; +Cc: Ruiyu Ni, Michael D Kinney, Liming Gao

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1243

AcpiExp text device path: AcpiExp(HID,CID,UIDSTR)
And according to UEFI spec, the CID parameter is optional
and has a default value of 0. But current implementation
miss to check following cases for the AcpiExp.
FromText:when text device is AcpiExp(HID,,UIDSTR)/AcpiExp(HID,0,UIDSTR)
ToText: when the CID is 0 in the node structure

This commit is to do the enhancement.

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    | 11 ++++++++-
 .../UefiDevicePathLib/DevicePathToText.c      | 23 +++++++++++++------
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
index 4b49e341c7..b759146b72 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
@@ -917,11 +917,20 @@ DevPathFromTextAcpiExp (
                                                   ACPI_EXTENDED_DP,
                                                   Length
                                                   );
 
   AcpiEx->HID = EisaIdFromText (HIDStr);
-  AcpiEx->CID = EisaIdFromText (CIDStr);
+  //
+  // According to UEFI spec, the CID parametr is optional and has a default value of 0.
+  // So when the CID parametr is not specified or specified as 0 in the text device node.
+  // Set the CID to 0 in the ACPI extension device path structure.
+  //
+  if (*CIDStr == L'\0' || *CIDStr == L'0') {
+    AcpiEx->CID = 0;
+  } else {
+    AcpiEx->CID = EisaIdFromText (CIDStr);
+  }
   AcpiEx->UID = 0;
 
   AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
   //
   // HID string is NULL
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
index 7ad9eadf6c..cdcdb3623a 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathToText.c
@@ -478,17 +478,26 @@ DevPathToTextAcpiEx (
 
   if ((*HIDStr == '\0') && (*CIDStr == '\0') && (*UIDStr != '\0')) {
     //
     // use AcpiExp()
     //
-    UefiDevicePathLibCatPrint (
-      Str,
-      L"AcpiExp(%s,%s,%a)",
-      HIDText,
-      CIDText,
-      UIDStr
-      );
+    if (AcpiEx->CID == 0) {
+      UefiDevicePathLibCatPrint (
+        Str,
+        L"AcpiExp(%s,0,%a)",
+        HIDText,
+        UIDStr
+       );
+    } else {
+      UefiDevicePathLibCatPrint (
+        Str,
+        L"AcpiExp(%s,%s,%a)",
+        HIDText,
+        CIDText,
+        UIDStr
+       );
+    }
   } else {
     if (AllowShortcuts) {
       //
       // display only
       //
-- 
2.18.0.windows.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch 0/3] MdePkg/UefiDevicePathLib: Enahncement for Sata/Usbxx/AcpiExp device path
  2018-10-12  2:18 [patch 0/3] MdePkg/UefiDevicePathLib: Enahncement for Sata/Usbxx/AcpiExp device path Dandan Bi
                   ` (2 preceding siblings ...)
  2018-10-12  2:18 ` [patch 3/3] MdePkg: Handle AcpiExp " Dandan Bi
@ 2018-10-24  3:51 ` Ni, Ruiyu
  3 siblings, 0 replies; 5+ messages in thread
From: Ni, Ruiyu @ 2018-10-24  3:51 UTC (permalink / raw)
  To: Dandan Bi, edk2-devel; +Cc: Michael D Kinney, Liming Gao

On 10/12/2018 10:18 AM, Dandan Bi wrote:
> https://bugzilla.tianocore.org/show_bug.cgi?id=1243
> 
> This pacth series is mainly to do the enahncement for
> Sata/Usbxx/AcpiExp device path to handle the cases when some
> optional paremeter is not specified in the text device path.
> 
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Dandan Bi (3):
>    MdePkg: Handle Sata device path when optional para is not specified
>    MdePkg: Handle USBxxx device path when optional para is not specified
>    MdePkg: Handle AcpiExp device path when optional para is not specified
> 
>   .../UefiDevicePathLib/DevicePathFromText.c    | 51 ++++++++++++++++---
>   .../UefiDevicePathLib/DevicePathToText.c      | 23 ++++++---
>   2 files changed, 60 insertions(+), 14 deletions(-)
> 
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

-- 
Thanks,
Ray


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-10-24  3:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [patch 2/3] MdePkg: Handle USBxxx " Dandan Bi
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox