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...@intel.com>
Cc: Michael D Kinney <michael.d.kin...@intel.com>
Cc: Liming Gao <liming....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan...@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

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to