]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
Fix several bugs in the implementation of converting SAS/SASEX device path node from...
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePathToText.c
index 1f90f64204a79b370aad39734307686a1934a93b..3d9d7c7a7ecb3945e5bd038fd42dc13b6abf22a4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DevicePathToText protocol as defined in the UEFI 2.0 specification.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, 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
@@ -234,23 +234,26 @@ DevPathToTextVendor (
           ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort\r
           );\r
         Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology);\r
-        if ((Info & 0x0f) == 0) {\r
+        if (((Info & 0x0f) == 0) && ((Info & BIT7) == 0)) {\r
           CatPrint (Str, L"NoTopology,0,0,0,");\r
-        } else if (((Info & 0x0f) == 1) || ((Info & 0x0f) == 2)) {\r
+        } else if (((Info & 0x0f) <= 2) && ((Info & BIT7) == 0)) {\r
           CatPrint (\r
             Str,\r
             L"%s,%s,%s,",\r
-            ((Info & (0x1 << 4)) != 0) ? L"SATA" : L"SAS",\r
-            ((Info & (0x1 << 5)) != 0) ? L"External" : L"Internal",\r
-            ((Info & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct"\r
+            ((Info & BIT4) != 0) ? L"SATA" : L"SAS",\r
+            ((Info & BIT5) != 0) ? L"External" : L"Internal",\r
+            ((Info & BIT6) != 0) ? L"Expanded" : L"Direct"\r
             );\r
           if ((Info & 0x0f) == 1) {\r
             CatPrint (Str, L"0,");\r
           } else {\r
-            CatPrint (Str, L"0x%x,", (Info >> 8) & 0xff);\r
+            //\r
+            // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256\r
+            //\r
+            CatPrint (Str, L"0x%x,", ((Info >> 8) & 0xff) + 1);\r
           }\r
         } else {\r
-          CatPrint (Str, L"0,0,0,0,");\r
+          CatPrint (Str, L"0x%x,0,0,0,", Info);\r
         }\r
 \r
         CatPrint (Str, L"0x%x)", ((SAS_DEVICE_PATH *) Vendor)->Reserved);\r
@@ -689,23 +692,26 @@ DevPathToTextSasEx (
   }\r
   CatPrint (Str, L",0x%x,", SasEx->RelativeTargetPort);\r
 \r
-  if ((SasEx->DeviceTopology & 0x0f) == 0) {\r
+  if (((SasEx->DeviceTopology & 0x0f) == 0) && ((SasEx->DeviceTopology & BIT7) == 0)) {\r
     CatPrint (Str, L"NoTopology,0,0,0");\r
-  } else if (((SasEx->DeviceTopology & 0x0f) == 1) || ((SasEx->DeviceTopology & 0x0f) == 2)) {\r
+  } else if (((SasEx->DeviceTopology & 0x0f) <= 2) && ((SasEx->DeviceTopology & BIT7) == 0)) {\r
     CatPrint (\r
       Str,\r
       L"%s,%s,%s,",\r
-      ((SasEx->DeviceTopology & (0x1 << 4)) != 0) ? L"SATA" : L"SAS",\r
-      ((SasEx->DeviceTopology & (0x1 << 5)) != 0) ? L"External" : L"Internal",\r
-      ((SasEx->DeviceTopology & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct"\r
+      ((SasEx->DeviceTopology & BIT4) != 0) ? L"SATA" : L"SAS",\r
+      ((SasEx->DeviceTopology & BIT5) != 0) ? L"External" : L"Internal",\r
+      ((SasEx->DeviceTopology & BIT6) != 0) ? L"Expanded" : L"Direct"\r
       );\r
     if ((SasEx->DeviceTopology & 0x0f) == 1) {\r
       CatPrint (Str, L"0");\r
     } else {\r
-      CatPrint (Str, L"0x%x", (SasEx->DeviceTopology >> 8) & 0xff);\r
+      //\r
+      // Value 0x0 thru 0xFF -> Drive 1 thru Drive 256\r
+      //\r
+      CatPrint (Str, L"0x%x", ((SasEx->DeviceTopology >> 8) & 0xff) + 1);\r
     }\r
   } else {\r
-    CatPrint (Str, L"0,0,0,0");\r
+    CatPrint (Str, L"0x%x,0,0,0", SasEx->DeviceTopology);\r
   }\r
 \r
   CatPrint (Str, L")");\r