]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
Roll back the changes in revision 14296 since it will cause iSCSI security authentica...
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePathFromText.c
index 11f5c159df449acb1482c1f9e3dbeb2e08b19cc5..f96bea14771f9e26091c89db4b57ff2921731698 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   DevicePathFromText 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
@@ -1636,6 +1636,7 @@ DevPathFromTextSAS (
   CHAR16          *DriveBayStr;\r
   CHAR16          *ReservedStr;\r
   UINT16          Info;\r
+  UINT16          Uint16;\r
   SAS_DEVICE_PATH *Sas;\r
 \r
   AddressStr  = GetNextParamStr (&TextDeviceNode);\r
@@ -1646,7 +1647,6 @@ DevPathFromTextSAS (
   ConnectStr  = GetNextParamStr (&TextDeviceNode);\r
   DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
   ReservedStr = GetNextParamStr (&TextDeviceNode);\r
-  Info        = 0x0000;\r
   Sas         = (SAS_DEVICE_PATH *) CreateDeviceNode (\r
                                        MESSAGING_DEVICE_PATH,\r
                                        MSG_VENDOR_DP,\r
@@ -1657,25 +1657,51 @@ DevPathFromTextSAS (
   Strtoi64 (AddressStr, &Sas->SasAddress);\r
   Strtoi64 (LunStr, &Sas->Lun);\r
   Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr);\r
-  if (StrCmp (SASSATAStr, L"NoTopology") != 0) {\r
-    if (StrCmp (DriveBayStr, L"0") == 0) {\r
-      Info |= 0x0001;\r
+\r
+  if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r
+    Info = 0x0;\r
+\r
+  } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r
+\r
+    Uint16 = (UINT16) Strtoi (DriveBayStr);\r
+    if (Uint16 == 0) {\r
+      Info = 0x1;\r
     } else {\r
-      Info |= 0x0002;\r
-      Info = (UINT16) (Info | (Strtoi (DriveBayStr) << 8));\r
+      Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r
     }\r
 \r
     if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
-      Info |= 0x0010;\r
+      Info |= BIT4;\r
     }\r
 \r
+    //\r
+    // Location is an integer between 0 and 1 or else\r
+    // the keyword Internal (0) or External (1).\r
+    //\r
     if (StrCmp (LocationStr, L"External") == 0) {\r
-      Info |= 0x0020;\r
+      Uint16 = 1;\r
+    } else if (StrCmp (LocationStr, L"Internal") == 0) {\r
+      Uint16 = 0;\r
+    } else {\r
+      Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r
     }\r
+    Info |= (Uint16 << 5);\r
 \r
+    //\r
+    // Connect is an integer between 0 and 3 or else\r
+    // the keyword Direct (0) or Expanded (1).\r
+    //\r
     if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
-      Info |= 0x0040;\r
+      Uint16 = 1;\r
+    } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r
+      Uint16 = 0;\r
+    } else {\r
+      Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r
     }\r
+    Info |= (Uint16 << 6);\r
+\r
+  } else {\r
+    Info = (UINT16) Strtoi (SASSATAStr);\r
   }\r
 \r
   Sas->DeviceTopology = Info;\r
@@ -1705,6 +1731,9 @@ DevPathFromTextSasEx (
   CHAR16            *ConnectStr;\r
   CHAR16            *DriveBayStr;\r
   UINT16            Info;\r
+  UINT16            Uint16;\r
+  UINT64            SasAddress;\r
+  UINT64            Lun;\r
   SASEX_DEVICE_PATH *SasEx;\r
 \r
   AddressStr  = GetNextParamStr (&TextDeviceNode);\r
@@ -1714,37 +1743,62 @@ DevPathFromTextSasEx (
   LocationStr = GetNextParamStr (&TextDeviceNode);\r
   ConnectStr  = GetNextParamStr (&TextDeviceNode);\r
   DriveBayStr = GetNextParamStr (&TextDeviceNode);\r
-  Info        = 0x0000;\r
   SasEx       = (SASEX_DEVICE_PATH *) CreateDeviceNode (\r
                                         MESSAGING_DEVICE_PATH,\r
                                         MSG_SASEX_DP,\r
                                         (UINT16) sizeof (SASEX_DEVICE_PATH)\r
                                         );\r
 \r
-  Strtoi64 (AddressStr, (UINT64 *) &SasEx->SasAddress);\r
-  Strtoi64 (LunStr,     (UINT64 *) &SasEx->Lun);\r
-  *(UINT64 *) &SasEx->SasAddress = SwapBytes64 (*(UINT64 *) &SasEx->SasAddress);\r
-  *(UINT64 *) &SasEx->Lun        = SwapBytes64 (*(UINT64 *) &SasEx->Lun);\r
+  Strtoi64 (AddressStr, &SasAddress);\r
+  Strtoi64 (LunStr,     &Lun);\r
+  WriteUnaligned64 ((UINT64 *) &SasEx->SasAddress, SwapBytes64 (SasAddress));\r
+  WriteUnaligned64 ((UINT64 *) &SasEx->Lun,        SwapBytes64 (Lun));\r
   SasEx->RelativeTargetPort      = (UINT16) Strtoi (RTPStr);\r
-  if (StrCmp (SASSATAStr, L"NoTopology") != 0) {\r
-    if (StrCmp (DriveBayStr, L"0") == 0) {\r
-      Info |= 0x0001;\r
+\r
+  if (StrCmp (SASSATAStr, L"NoTopology") == 0) {\r
+    Info = 0x0;\r
+\r
+  } else if ((StrCmp (SASSATAStr, L"SATA") == 0) || (StrCmp (SASSATAStr, L"SAS") == 0)) {\r
+\r
+    Uint16 = (UINT16) Strtoi (DriveBayStr);\r
+    if (Uint16 == 0) {\r
+      Info = 0x1;\r
     } else {\r
-      Info |= 0x0002;\r
-      Info = (UINT16) (Info | (Strtoi (DriveBayStr) << 8));\r
+      Info = (UINT16) (0x2 | ((Uint16 - 1) << 8));\r
     }\r
 \r
     if (StrCmp (SASSATAStr, L"SATA") == 0) {\r
-      Info |= 0x0010;\r
+      Info |= BIT4;\r
     }\r
 \r
+    //\r
+    // Location is an integer between 0 and 1 or else\r
+    // the keyword Internal (0) or External (1).\r
+    //\r
     if (StrCmp (LocationStr, L"External") == 0) {\r
-      Info |= 0x0020;\r
+      Uint16 = 1;\r
+    } else if (StrCmp (LocationStr, L"Internal") == 0) {\r
+      Uint16 = 0;\r
+    } else {\r
+      Uint16 = ((UINT16) Strtoi (LocationStr) & BIT0);\r
     }\r
+    Info |= (Uint16 << 5);\r
 \r
+    //\r
+    // Connect is an integer between 0 and 3 or else\r
+    // the keyword Direct (0) or Expanded (1).\r
+    //\r
     if (StrCmp (ConnectStr, L"Expanded") == 0) {\r
-      Info |= 0x0040;\r
+      Uint16 = 1;\r
+    } else if (StrCmp (ConnectStr, L"Direct") == 0) {\r
+      Uint16 = 0;\r
+    } else {\r
+      Uint16 = ((UINT16) Strtoi (ConnectStr) & (BIT0 | BIT1));\r
     }\r
+    Info |= (Uint16 << 6);\r
+\r
+  } else {\r
+    Info = (UINT16) Strtoi (SASSATAStr);\r
   }\r
 \r
   SasEx->DeviceTopology = Info;\r
@@ -2006,6 +2060,7 @@ DevPathFromTextUart (
 \r
   case L'S':\r
     Uart->Parity = 5;\r
+    break;\r
 \r
   default:\r
     Uart->Parity = 0xff;\r